Enable dynamic increase/decrease of compare threads#3304
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables dynamic scaling of directory-compare worker threads while a compare is running by pre-creating a larger worker pool and using an “idle thread count” to control how many workers are active.
Changes:
- Pre-create a larger set of compare workers and represent “inactive” workers via
IdleCompareThreadCount. - Update the CPU-cores UI handler to compute idle threads from the requested core count, with clamping.
- Initialize the CPU-cores selector to the currently active (non-idle) thread count.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
Src/DirScan.cpp |
Pre-creates a larger worker pool, sets compare thread count to max, and uses idle thread count to represent initial effective thread usage. |
Src/DirDoc.cpp |
Updates CPU core selection handler to clamp requested cores and set idle thread count accordingly. |
Src/DirCompProgressBar.cpp |
Initializes the UI’s selected core count to “active threads” (total minus idle). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Count() as maxWorkers Agent-Logs-Url: https://github.com/WinMerge/winmerge/sessions/f8940a61-41de-41e7-a976-d29110548220 Co-authored-by: sdottaka <98126+sdottaka@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.
Allow dynamic scaling of compare threads during execution.
Previously, threads could only be reduced, not increased. This change pre-creates a full pool of worker threads (up to
processorCount()) and controls active usage via idle thread count.Summary
processorCount()for content comparisons, enabling true dynamic scaling across all available CPU cores.IdleCompareThreadCount: idle workers check their status before dequeuing work items, ensuring they never process items while designated as idle.waitDequeueNotification(10ms)) so they can promptly detect being made idle while waiting for work.