Repository navigation
perf(nats): optimize user sync and bound queue processing - #892
Merged
x0sina merged 1 commit intoSep 12, 2026
Merged
Conversation
Reuse live key indexes, replay snapshots in bounded batches, and clear queues from cached keys and recent revisions. Bound bulk operations, safely compact old deletion markers, and preserve claim recovery across delayed notifications and reconnects. Add concurrency, recovery, compaction, and idle-traffic regression coverage.
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
8 of 11 tasks
7 of 11 tasks
x0sina
added a commit
that referenced
this pull request
Sep 12, 2026
) * feat(user): enhance user inbound tag retrieval and subscription update handling - Improved the `inbounds` method in the User model to efficiently gather inbound tags from enabled groups. - Updated user subscription update logic to queue updates for background processing, enhancing performance. - Refactored user status change notifications to streamline the process and ensure accurate user state management. - Introduced caching for usage coefficients to optimize node user statistics collection. - Enhanced subscription generation with caching mechanisms for improved performance. * fix: discard stale subscription updates and align FinalMask test (#886) * fix: read flushed subscription updates from a fresh snapshot (#888) * perf(nats): optimize user sync and bound queue processing (#892) Reuse live key indexes, replay snapshots in bounded batches, and clear queues from cached keys and recent revisions. Bound bulk operations, safely compact old deletion markers, and preserve claim recovery across delayed notifications and reconnects. Add concurrency, recovery, compaction, and idle-traffic regression coverage. * test(hosts): match FinalMask noise fixture to Xray array packet Keep the #889 payload ([1, 2, 255], no rand) so it agrees with the merged assertions after pref-boost picked up both that change and the older #886 sample. * fix(cleanup): add timeout handling for node-sync key compaction and improve logging - Introduced asyncio timeout for the compaction process to prevent indefinite blocking. - Added a warning log for timeout occurrences to ensure visibility of potential issues. - Updated Cache-Control header in subscription responses to "no-store" for better caching behavior. - Refactored subscription update buffer to use a drain lock for concurrent flush operations, improving reliability and performance. --------- Co-authored-by: DrSaeedHub <[email protected]>
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
Repeated queue discovery and reconnect cleanup replay historical deletion markers and create JetStream consumers even when little work is pending. Maintain one live key index per worker so initialized idle polls make no NATS requests, and clear node queues using cached candidates plus newer revisions.
Type of change
Checklist
Testing
With
DEBUG=false,TZ=UTC, andNATS_SERVER_BINARYpointing to NATS 2.10.29:git diff --checkpassed.Screenshots
Not applicable.
Notes for reviewers
The index discovers candidate keys only. Authoritative values and claim ownership still use JetStream reads and revision-checked operations. Compaction removes revisions only through an observed deletion marker, protecting concurrently recreated keys.
Bounded snapshots use the KV object's underlying JetStream context because the KV watch API exposes push delivery. Real-server tests cover snapshot lifecycle and ordered live subscription recovery. No database migrations or dependency changes are required.