Skip to content

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
ValveSoftware:masterfrom
Ibn-Butt-Toota:butt/only-insert-at-end-of-sender-map
Open

Ibn-Butt-Toota wants to merge 1 commit into
ValveSoftware:masterfrom
Ibn-Butt-Toota:butt/only-insert-at-end-of-sender-map

Conversation

@Ibn-Butt-Toota

Copy link
Copy Markdown

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() and insert() 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.

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).
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.

1 participant