Deterministically iterate status listeners#2109
Merged
robgjansen merged 4 commits intoshadow:mainfrom May 5, 2022
Merged
Conversation
Contributor
|
Running this patch, the "relay1" tor process in the tor minimal test generates the exact same strace log ( |
Member
Author
|
I ran two 5% Tor nets in our CI and the syscall counts are identical: I checked the json simulated performance stats files: The Tor simulated network performance stats are identical across the repeated trials: The Shadow resource usage stats varied, which is expected because the host hardware is not running a deterministic OS and we don't expect Shadow itself to run in the exact same amount of time. |
stevenengler
approved these changes
May 2, 2022
The new index will enable us to deterministically sort listeners.
6b61abf to
9faa33c
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Because hash table iterators are not guaranteed to provide deterministic ordering, we must assign our own deterministic order to the items held by the hash table and then iterate them in sorted order. This fixes two related areas in the code where
StatusListenerobjects were being iterated according to an undefined hash table order: in thedescriptorandfutexmodules.Deterministic hash table ordering tests are difficult on a small scale so no new tests have been added. It would be nice if in the future we can design a data structure like a ring where we can guarantee in-order traversal but also change the starting point of the iterator on every iteration so that the same listeners don't always get woken up first (potentially starving items at the end of the list).
refs #666