Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: Lightweight watcher#101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
rklaehn wants to merge5 commits intoentity-manager
base:entity-manager
Choose a base branch
Loading
fromlightweight-watcher

Conversation

rklaehn
Copy link
Collaborator

@rklaehnrklaehn commentedJul 9, 2025
edited
Loading

Description

In the current blobs I am using tokio::sync::watch for notifying the observers when the state for a hash has changed. This works, but is way more heavy than needed.

  1. tokio::sync::watch is optimized for a case where we have tons of watchers. It uses a giant BigNotify under the hood to solve the thundering herd problem. I think it will be much more common that you have a few tasks operating on a hash (frequently just one), and a few observers (frequently none).
  2. since we now know that all tasks for a hash run concurrently but not parallel, we can use the awesome AtomicRefCell instead of a full blown lock.

Breaking Changes

None

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following thestyle guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

Since we are guaranteed to be single threaded within the handler fns for asingle hash, we can use a much more lightweight watcher impl.Also, tokio::sync::watch is optimized for the case where there are a lotof parallel watchers, using a giant BigNotify internally. We want tooptimize for the case where there are just 0 or a few watchers, so we arenot that much concerned with the thundering herd problem.
@github-actionsGitHub Actions
Copy link

github-actionsbot commentedJul 9, 2025
edited
Loading

Documentation for this PR has been generated and is available at:https://n0-computer.github.io/iroh-blobs/pr/101/docs/iroh_blobs/

Last updated: 2025-07-11T06:43:43Z

@rklaehnrklaehn mentioned this pull requestJul 9, 2025
4 tasks
_state: entity_manager::ActiveEntityState<Self>,
_cause: entity_manager::ShutdownCause,
) {
async fn on_shutdown(state: HashContext, cause: ShutdownCause) {
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Unrelated change!

@n0botn0botbot added this toirohJul 9, 2025
@github-project-automationgithub-project-automationbot moved this to🏗 In progress inirohJul 9, 2025
@rklaehn
Copy link
CollaboratorAuthor

Did a very superficial bench with the linux kernel. Doesn't seem to make perf worse, but also not better (not that I expected that...)

@rklaehnrklaehn closed thisJul 9, 2025
@github-project-automationgithub-project-automationbot moved this from🏗 In progress to✅ Done inirohJul 9, 2025
@rklaehnrklaehn reopened thisJul 9, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
Status: ✅ Done
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@rklaehn

[8]ページ先頭

©2009-2025 Movatter.jp