-
Notifications
You must be signed in to change notification settings - Fork 89
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
chore(network): make streamhashmap not end #2249
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2249 +/- ##
==========================================
- Coverage 66.34% 66.33% -0.01%
==========================================
Files 139 139
Lines 18379 18374 -5
Branches 18379 18374 -5
==========================================
- Hits 12194 12189 -5
Misses 4890 4890
Partials 1295 1295 ☔ View full report in Codecov by Sentry. |
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.
Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @eitanm-starkware)
-- commits
line 2 at r1:
This is fix, not chore
crates/papyrus_network/src/utils.rs
line 39 at r1 (raw file):
pub fn insert(&mut self, key: K, value: V) -> Option<V> { self.finished_streams.remove(&key);
I think you can remove finished_streams entirely and just remove from the map all finished streams. Use HashMap::retain for that
crates/papyrus_network/src/utils.rs
line 58 at r1 (raw file):
} Poll::Pending => {} }
As a general rule of thumb, if there is a flow in which you return pending and don't call poll on some other future, you should be worried that your future can reach a status where it's never gets awake
In this case, it can happen if self.map is empty.
Add to the struct a field of type Vec called wakers_waiting_for_new_stream. Check at the start of the function if the map is empty. If yes, add cx.waker().clone() to this vector. Inside the insert function, call wake() on all the wakers in this vector and clear the vector (you can use drain(..) for that)
There are many examples for this in our code. Just look for the word waker
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ShahakShama)
crates/papyrus_network/src/utils.rs
line 39 at r1 (raw file):
Previously, ShahakShama wrote…
I think you can remove finished_streams entirely and just remove from the map all finished streams. Use HashMap::retain for that
Done.
crates/papyrus_network/src/utils.rs
line 58 at r1 (raw file):
Previously, ShahakShama wrote…
As a general rule of thumb, if there is a flow in which you return pending and don't call poll on some other future, you should be worried that your future can reach a status where it's never gets awake
In this case, it can happen if self.map is empty.
Add to the struct a field of type Vec called wakers_waiting_for_new_stream. Check at the start of the function if the map is empty. If yes, add cx.waker().clone() to this vector. Inside the insert function, call wake() on all the wakers in this vector and clear the vector (you can use drain(..) for that)
There are many examples for this in our code. Just look for the word waker
Done. had to use a set to track finished streams though
This change is