Skip to content
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

use a ring buffer for the datagram queue #4223

Merged
merged 1 commit into from
Jan 1, 2024

Conversation

marten-seemann
Copy link
Member

@marten-seemann marten-seemann commented Dec 30, 2023

No description provided.

@marten-seemann marten-seemann added this to the v0.41 milestone Dec 30, 2023
Copy link

codecov bot commented Dec 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1fce81f) 83.97% compared to head (60db14b) 83.99%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4223      +/-   ##
==========================================
+ Coverage   83.97%   83.99%   +0.02%     
==========================================
  Files         149      149              
  Lines       15419    15421       +2     
==========================================
+ Hits        12948    12952       +4     
+ Misses       1972     1971       -1     
+ Partials      499      498       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@marten-seemann marten-seemann changed the base branch from datagram-queue-length to master January 1, 2024 03:59
@sukunrt
Copy link
Collaborator

sukunrt commented Jan 1, 2024

Sorry for the drive by comment. Just to point it out in case it was actually missed. Please ignore if not relevant.

Is a Peek followed by a Pop threadsafe considering that we only synchronise the calls individually and not the whole Peek + Pop operation?
I can't see any issues currently because it seems to be called only from the connection run loop go routine.

@marten-seemann
Copy link
Member Author

Sorry for the drive by comment.

Thanks for reviewing!

Is a Peek followed by a Pop threadsafe considering that we only synchronise the calls individually and not the whole Peek + Pop operation?

The entire RingBuffer is not thread-safe (it doesn't try to: it doesn't even contain a mutex). It's the caller's responsibility to synchronize access.

I believe the datagramQueue does that: Peek will return a non-nil frame iff there's actually a frame queued. While it's possible that new frames are added between the Peek and Pop call, the only way that frame could disappear via Pop call, there's no other way to dequeue / delete a frame from the queue. Do you see any problem with that logic?

@sukunrt
Copy link
Collaborator

sukunrt commented Jan 1, 2024

This makes sense.
Only Add happens from a different goroutine. Peek and Pop happen from the same goroutine so we will always Pop the element we received from Peek since Add puts it at the back of the queue.

@marten-seemann marten-seemann merged commit 22b7f77 into master Jan 1, 2024
18 checks passed
@marten-seemann marten-seemann deleted the datagram-queue-ringbuffer branch January 3, 2024 05:19
nanokatze pushed a commit to nanokatze/quic-go that referenced this pull request Feb 1, 2024
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.

None yet

3 participants