Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: reduce memory size of watch::Receiver #2191

Merged
merged 2 commits into from
Jan 29, 2020
Merged

sync: reduce memory size of watch::Receiver #2191

merged 2 commits into from
Jan 29, 2020

Conversation

seanmonstar
Copy link
Member

Motivation

The size of watch::Receiver was 4 words, when it could be smaller.

Solution

This reduces the mem::size_of::<watch::Receiver>() from 4 words to 2.

  • The id is now the pointer of the Arc<WatchInner>.
  • The ver is moved into the WatchInner.

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

The change to using Arc addresses instead of separate ID values seems good to me. I am not sure about the change that moves versions out of the Receiver struct into the Arc'd state, as I discussed in my comments. Let me know if I'm misunderstanding what's going on here?

tokio/src/sync/watch.rs Show resolved Hide resolved
tokio/src/sync/watch.rs Outdated Show resolved Hide resolved
tokio/src/sync/watch.rs Show resolved Hide resolved
This reduces the `mem::size_of::<watch::Receiver>()` from 4 words to 2.

- The `id` is now the pointer of the `Arc<WatchInner>`.
- The `ver` is moved into the `WatchInner`.
Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

LGTM, thanks. I am +1ing this, but we should resolve @Hawks's feedback before merging.

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

changing the version ops to Relaxed looks good to me, ship it!

@seanmonstar seanmonstar merged commit 116a18b into master Jan 29, 2020
@seanmonstar seanmonstar deleted the watch-diet branch January 29, 2020 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants