Add progressive backoff to wait_for_available_thread()#107
Merged
jke000 merged 11 commits intoBS_thread_poolfrom Feb 11, 2026
Merged
Add progressive backoff to wait_for_available_thread()#107jke000 merged 11 commits intoBS_thread_poolfrom
jke000 merged 11 commits intoBS_thread_poolfrom
Conversation
Closed
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
…heck Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Apply changes based on feedback for BS::thread_pool PR
Add progressive backoff to wait_for_available_thread()
Feb 11, 2026
jke000
added a commit
that referenced
this pull request
Feb 17, 2026
* Update threading code to use BS::thread_pool. * update Makefiles to use C++ 20 * fix typos in LICENSE * remove NOTICE file; update windows-build.yml to use VS2022 to compile; map negative value to single worker thread * Throw exception when ThreadPool::doJob() called before initialization (#103) * Initial plan * Add error handling to doJob() to prevent silent work dropping Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Complete implementation of doJob() error handling Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Remove unused thread tracking members from Threading class (#104) * Initial plan * Remove unused _threadMapMutex and _threads members Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Update MSToolkit/VisualStudio/extern/zlibstat.vcxproj Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update CometSearch/Threading.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update CometSearch/ThreadPool.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Initial plan (#105) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> * Remove unused EndThread() function from Threading interface (#106) * Initial plan * Remove unused EndThread() function from Threading interface Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Remove build artifacts that were accidentally committed Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Add progressive backoff to wait_for_available_thread() (#107) * Initial plan * Add progressive backoff to wait_for_available_thread to reduce CPU usage Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Cap attempts counter to prevent overflow in wait_for_available_thread Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Simplify wait_for_available_thread by removing unnecessary overflow check Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Add counter cap to prevent overflow in wait_for_available_thread Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Clarify comment for counter cap in wait_for_available_thread Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Use std::min for cleaner counter cap in wait_for_available_thread Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Simplify counter logic by removing unnecessary cap Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Make backoff constants static constexpr for clarity Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Final progress update Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * Remove build artifacts that shouldn't be committed Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> * threadpool update; confirmed working for both VS and Linux * remove fflush(); let the system handle buffering and flushing when writing the output files * get rid of _codeql_detected_source_root and add it to .gitignore --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: jke000 <9449681+jke000@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
The
wait_for_available_thread()function was a tight busy-wait loop that continuously yielded, burning significant CPU when tasks are long-lived or the system is oversubscribed.Changes
This preserves low latency for short waits while dramatically reducing CPU usage under sustained load.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.