Fix unnecessary delay in the port tracking loop - #41472
Open
Feng Wang (chemwolf6922) wants to merge 2 commits into
Open
Fix unnecessary delay in the port tracking loop#41472Feng Wang (chemwolf6922) wants to merge 2 commits into
Feng Wang (chemwolf6922) wants to merge 2 commits into
Conversation
2 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes an unnecessary per-bind() delay in the Linux init port-tracking path by replacing the prior timeout/promise-based synchronization with a single event stream (seccomp notifications + periodic port refresh results), aiming to make the coordination between the main loop and the refresh worker deterministic and faster.
Changes:
- Refactored
GnsPortTrackerto useWaitableValue<std::variant<...>>for event delivery and a separateWaitableValue<bool>for refresh acknowledgements. - Removed the previous
std::promise/std::futurepolling and the associated short poll timeouts from the main loop. - Updated
WaitableValueto support move semantics for posted/retrieved values.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/linux/init/waitablevalue.h | Switches post/get/try_get to move-based storage/return to avoid unnecessary copies. |
| src/linux/init/GnsPortTracker.h | Replaces promise/future refresh plumbing with a TrackerEvent variant and new waitable signals. |
| src/linux/init/GnsPortTracker.cpp | Refactors the main loop into an event-driven design and removes timeout-based polling delays. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary of the Pull Request
Before this change, an additional 10ms delay was added in the port tracker loop presumably to make the main loop slower than the worker loop. So, the worker result does not get super dated. This is not reliable. And the 10ms delay also slows down every consecutive bind call.
This PR refactors the thread synchronization method. So, the timing between those two loops is more deterministic. And removes the performance penalty for all bind calls.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Measure 100 consecutive bind calls for different AF.
The extra UDP bind 0 time is from the
getsocknamepoll. Which is required.