Repository navigation
Hint packets to be sent will be at the end of the sender map - #477
Open
Ibn-Butt-Toota wants to merge 1 commit into
Open
Ibn-Butt-Toota wants to merge 1 commit into
Ibn-Butt-Toota wants to merge 1 commit into
Conversation
Packets being sent will always be put at the end of the map that tracks packets the packets being sent. As such, we can save a couple (short) lookups by providing a hint for the insert that it should take place at the end of the map. The hint will do a check, and if valid, will do the insert at the hinted location, otherwise it will fall back and perform the normal tree walk to find the appropriate place to insert (this is the default behavior of insert w/o a a hint being provided).
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.
Packets being sent will always be put at the end of the map that tracks packets the packets being sent. As such, we can save a couple (short) lookups by providing a hint for the insert that it should take place at the end of the map. The hint will do a check, and if valid, will do the insert at the hinted location, otherwise it will fall back and perform the normal tree walk to find the appropriate place to insert (this is the default behavior of insert w/o a a hint being provided).
The tree walk is log_2(n) so it's pretty efficient anyways, and from what I could tell, most tree depths are usually very short too. Both the
lower_bound()andinsert()functions do the walk, so for the former I changed the assert to just check that the new packet has a greater seq number than the one at the end of the map.