fix(io): make io worker cpu pinning opt-in via MORI_CORE_OFFSET#364
Merged
Conversation
Only pin workers when MORI_CORE_OFFSET is set; otherwise inherit the process cpuset and let the scheduler place them. Read the value via mori::env::GetInt to avoid std::stoi throwing on invalid input.
maning00
approved these changes
Jun 5, 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.
Follow-up to #358 (cpuset-aware worker pinning).
Changes
MORI_CORE_OFFSETis set. When it is unset, workers inherit the processcpuset and the scheduler places them (matches the default no-explicit-pin
behavior used elsewhere, e.g. SGLang's opt-in
SGLANG_SET_CPU_AFFINITY).MORI_CORE_OFFSETviamori::env::GetIntinstead ofstd::stoi,so an invalid value is ignored (treated as unset) instead of throwing and
terminating the worker thread. Added a small signed-int helper
(
ParseInt/GetInt) alongside the existingParsePositiveInt/GetPositiveIntOrinenv_utils.hpp.Why opt-in
Implicitly pinning every worker to
allowed[0..n]can collide with other hotthreads sharing the same cpuset (e.g. the SGLang scheduler/compute threads).
Pinning is a tuning decision, so the default is now neutral; operators opt in
when they have a deliberate core layout.
Test
On 086/087 under
taskset -c 8-15with--num-worker-threads 4 --disable-chunking:MORI_CORE_OFFSET=0: workers bound to cores 8-11 (within the allowed set).MORI_CORE_OFFSET=abc(invalid): no crash, treated as unset, workers run normally.Plus a unit check of
GetIntparsing (valid / 0 / negative / garbage / overflow).