-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
time: avoid traversing entries in the time wheel twice #6718
Open
wathenjiang
wants to merge
11
commits into
tokio-rs:master
Choose a base branch
from
wathenjiang:fix-sharded-timer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
73d6560
Revert "time: revert "avoid traversing entries in the time wheel twic…
wathenjiang cd70a24
time: revert set_cached_when
wathenjiang 1410a9f
add #[cfg(not(loom))] for the reset_timer_and_drop test
wathenjiang 71f60d5
rm model in the reset_timer_and_drop test
wathenjiang 96fef56
Merge branch 'tokio-rs:master' into fix-sharded-timer
wathenjiang 004367c
revert some unnecessary modification && update some comments
wathenjiang 6aaeb88
Merge branch 'master' into fix-sharded-timer
wathenjiang b1cf26d
test: assert_ne MAX_SAFE_MILLIS_DURATION for test
wathenjiang 08a688a
time: remove MAX_SAFE_MILLIS_DURATION check
wathenjiang 36b8c07
time: move wheel state maintenance method
wathenjiang 955ec31
Merge branch 'master' into fix-sharded-timer
wathenjiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code doesn't call this. Why is it necessary now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I add
occupied_bit_maintain
now is that in the past, we would usetake_entries
to take all items from the linked list at once and then update the occupied bit. But now, we need to traverse the items one by one, which means we need to update the occupied bit after the traversal is completed. I think the difference here is that in the current version, the linked list is not necessarily empty, so I add this method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be accurate to say that this is an operation that must be called when we are done with
list
? Would it make sense for it to be part of the destructor ofEntryWaitersList
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to be called before
drop(lock)
inif !waker_list.can_push() {
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling
occupied_bit_maintain
beforedrop(lock)
inif !waker_list.can_push() {
makes sense to me. That is a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
set_elapsed
?I would really like to see a loom test where a timer is inserted during the
if !waker_list.can_push() { ... }
block. It's hard for me to tell whether it's correct.I think you can do the loom test along these lines:
Spawning the thread after registering the 32 timers should reduce the size of the loom test, since the region with more than 1 thread will be shorter. As long as the
if !waker_list.can_push() { ... }
block happens in the more-than-1-thread region of the test, it should work.