Skip to content

Improve the CPU pinning logic for BatchExecutor. - #5390

Merged
dmkozh merged 1 commit into
stellar:masterfrom
dmkozh:thread_pool_followup
Jul 28, 2026
Merged

Improve the CPU pinning logic for BatchExecutor.#5390
dmkozh merged 1 commit into
stellar:masterfrom
dmkozh:thread_pool_followup

Conversation

@dmkozh

@dmkozh dmkozh commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

  • De-prioritize core 0 to decrease the probability of clashing with OS house-keeping
  • Pin hyper-threaded cores first if we run out of physical cores, and never wrap around the list (leave the over-subscribed rest workers unpinned)

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

- De-prioritize core 0 to decrease the probability of clashing with OS house-keeping
- Pin hyper-threaded cores first if we run out of physical cores, and never wrap around the list (leave the over-subscribed rest workers unpinned)
Copilot AI review requested due to automatic review settings July 28, 2026 00:34

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

Improves Linux CPU affinity ordering for BatchExecutor.

Changes:

  • De-prioritizes CPU 0’s physical core.
  • Uses hyper-thread siblings after distinct physical cores.
  • Leaves excess workers unpinned.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/util/BatchExecutor.h Updates pinning state and documentation.
src/util/BatchExecutor.cpp Implements topology-aware CPU ordering and oversubscription handling.
Comments suppressed due to low confidence (1)

src/util/BatchExecutor.cpp:94

  • This comment repeats the inaccurate absolute-last guarantee: on restricted or heterogeneous affinity sets, later sibling tiers can follow CPU 0. The rotation only guarantees that CPU 0 follows the other allowed CPUs from its own core.
        // Demote CPU 0 behind its own hyper-thread siblings so it becomes the
        // very last CPU we pin.

Comment thread src/util/BatchExecutor.cpp
Comment thread src/util/BatchExecutor.cpp
Comment thread src/util/BatchExecutor.cpp

@graydon graydon 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.

Nice! Thanks.

@dmkozh
dmkozh added this pull request to the merge queue Jul 28, 2026
Merged via the queue into stellar:master with commit b2e1ef6 Jul 28, 2026
69 checks passed
@dmkozh
dmkozh deleted the thread_pool_followup branch July 28, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants