Replace busy-wait with sleep_for in StorageAttachmentGuard::Wait#240
Merged
anasdorbani merged 2 commits intodevfrom Mar 2, 2026
Merged
Replace busy-wait with sleep_for in StorageAttachmentGuard::Wait#240anasdorbani merged 2 commits intodevfrom
anasdorbani merged 2 commits intodevfrom
Conversation
Merged
…ntGuard::Wait Co-authored-by: anasdorbani <95044293+anasdorbani@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Address feedback on WASM support implementation
Replace busy-wait with sleep_for in StorageAttachmentGuard::Wait
Mar 2, 2026
anasdorbani
approved these changes
Mar 2, 2026
anasdorbani
approved these changes
Mar 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Replace CPU-burning busy-wait in Config::StorageAttachmentGuard::Wait with std::this_thread::sleep_for during storage attachment retries.
Changes:
- Replace spin loop with
std::this_thread::sleep_for(std::chrono::milliseconds(...)) - Add
#include <thread>to supportsleep_for - Add
_codeql_detected_source_rootfile
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/core/config/config.cpp | Replaces busy-wait loop with sleep_for to avoid pegging a CPU core during retry waits. |
| _codeql_detected_source_root | Adds a CodeQL source-root marker file to the repository. |
Comments suppressed due to low confidence (3)
src/core/config/config.cpp:149
- This file contains duplicated implementations of
Config::StorageAttachmentGuard::Wait(and nearby methods in the same regions). Even if these are under different compile-time branches, keeping two copies increases the risk of future drift. Consider factoring the shared logic into a single helper (or a single implementation selected via#if/#elsearound only the differing parts) so changes only need to be made once.
void Config::StorageAttachmentGuard::Wait(int milliseconds) {
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
}
src/core/config/config.cpp:202
- This file contains duplicated implementations of
Config::StorageAttachmentGuard::Wait(and nearby methods in the same regions). Even if these are under different compile-time branches, keeping two copies increases the risk of future drift. Consider factoring the shared logic into a single helper (or a single implementation selected via#if/#elsearound only the differing parts) so changes only need to be made once.
void Config::StorageAttachmentGuard::Wait(int milliseconds) {
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
}
_codeql_detected_source_root:1
_codeql_detected_source_rootlooks like a generated/tooling artifact (single-dot marker). If it’s produced by CodeQL or CI tooling, it generally shouldn’t be committed; prefer configuring CodeQL to detect the root via workflow settings, or add this file to.gitignoreand remove it from the PR to avoid persistent noise in future diffs.
anasdorbani
pushed a commit
that referenced
this pull request
Mar 3, 2026
anasdorbani
pushed a commit
that referenced
this pull request
Mar 3, 2026
anasdorbani
pushed a commit
that referenced
this pull request
Mar 10, 2026
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.
StorageAttachmentGuard::Waitwas implemented as a spin loop, burning a full CPU core for up to 10 seconds (10 retries × 1000ms) during storage attachment retries.Changes
src/core/config/config.cpp: Replace busy-wait spin loop withstd::this_thread::sleep_for, and add#include <thread>✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.