Repository navigation
Conversation
Clear the pending local-change deadline after acquiring the round lock, before returning for disabled, paused or misconfigured sync. Otherwise a configuration change leaves an expired deadline that keeps the background scheduler runnable and consumes a CPU core even when sync is off. Cover all three early-return states and repeated local changes with a regression test.
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Author
|
I have read the CLA Document and I hereby sign the CLA |
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
Fix sustained CPU usage after a local configuration change when sync is disabled, paused, or cannot be initialized. No dependency upgrades or polling delays are needed.
Root cause
Sync::touch()records a dirty deadline (now + SETTLE). The background scheduler takes the earlier of this deadline and the next periodic poll.Sync::round()previously cleareddirtyonly afterensure()and the paused check. Its early returns for Off, Misconfigured, and Paused therefore left the dirty deadline behind. Once that deadline expired, every subsequent scheduler iteration calledsleep_until()on the same past instant. Scheduling the next periodic poll did not help, because the expired dirty deadline continued to win.Move the existing deadline consumption immediately after acquiring the round mutex, before these early returns. A
touch()during the asynchronous engine round still schedules a subsequent round, and the existing periodic polling/retry policy is unchanged.Reproduction and verification
Reproduced with the shipped 0.81.0 Linux binary using only synthetic configuration and a private temporary directory:
syncsection./syncreportingoff. No desktop client or gateway traffic is required.The new dirty-deadline regression assertion also fails on unmodified
main. With this fix, the same real-process reproduction using a locally built core remains at 0% CPU after the edit.The regression test covers Off, Paused, and Misconfigured early returns, including a second local change in each state.
Validation
cargo build --locked -p twcorecargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets -- -D warningscargo test --locked --workspace— 4,017 passed, 0 failed, 9 ignoredbash scripts/smoke.sh— 84 passed, 0 failedThe build reports an existing future-incompatibility warning in
proc-macro-error2 2.0.1; this change does not alter dependencies.