Skip to content

Enable dynamic increase/decrease of compare threads#3304

Merged
sdottaka merged 5 commits into
masterfrom
feature/dynamic-compare-thread-scaling
Apr 5, 2026
Merged

Enable dynamic increase/decrease of compare threads#3304
sdottaka merged 5 commits into
masterfrom
feature/dynamic-compare-thread-scaling

Conversation

@sdottaka

@sdottaka sdottaka commented Apr 5, 2026

Copy link
Copy Markdown
Member

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

  • Pre-create worker threads up to processorCount() for content comparisons, enabling true dynamic scaling across all available CPU cores.
  • Control active concurrency via IdleCompareThreadCount: idle workers check their status before dequeuing work items, ensuring they never process items while designated as idle.
  • Worker threads use a short-timeout dequeue (waitDequeueNotification(10ms)) so they can promptly detect being made idle while waiting for work.
  • Clamp requested cores and guard against uninitialized thread state in the CPU-cores UI handler.
  • Initialize the CPU-cores selector to the currently active (non-idle) thread count.

@sdottaka sdottaka requested a review from Copilot April 5, 2026 06:21
@sdottaka sdottaka marked this pull request as ready for review April 5, 2026 06:21
@sdottaka sdottaka added this to the v2.16.55 milestone Apr 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Src/DirScan.cpp Outdated
Comment thread Src/DirScan.cpp
Comment thread Src/DirScan.cpp Outdated
Comment thread Src/DirDoc.cpp
Comment thread Src/DirDoc.cpp
Comment thread Src/DirCompProgressBar.cpp Outdated
sdottaka and others added 2 commits April 5, 2026 15:38
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>
@sdottaka sdottaka merged commit 6514e76 into master Apr 5, 2026
2 of 3 checks passed
@sdottaka sdottaka deleted the feature/dynamic-compare-thread-scaling branch April 5, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants