Skip to content

CPU topology v2 phase 3: make CPU Sets mapping group-aware#9

Merged
PrimeBuild-pc merged 2 commits into
mainfrom
codex-cpu-topology-v2-phase-3
May 19, 2026
Merged

CPU topology v2 phase 3: make CPU Sets mapping group-aware#9
PrimeBuild-pc merged 2 commits into
mainfrom
codex-cpu-topology-v2-phase-3

Conversation

@PrimeBuild-pc
Copy link
Copy Markdown
Owner

Summary

  • Replaces the fragile LogicalProcessorIndex -> CpuSetId CPU Sets mapping with ProcessorRef -> CpuSetId, preserving group and group-relative logical processor number.
  • Adds reverse CpuSetId -> ProcessorRef mapping for verification/logging-ready lookup.
  • Adds ApplyCpuSelection(CpuSelection, bool) on IProcessCpuSetHandler/ProcessCpuSetHandler without wiring it into ProcessService yet.
  • Keeps legacy ApplyCpuSetMask(long, bool) available and documents it as single-group <=64 logical processor compatibility path.
  • Adds a fakeable native API seam so CPU Sets behavior is testable without admin rights or protected processes.

Tests

  • Group 0 CPU0 and Group 1 CPU0 remain distinct in the CPU Set map.
  • CPU64 resolves to its own CPU Set and does not alias CPU0.
  • CpuSelection with explicit CPU Set IDs applies those IDs.
  • CpuSelection without CPU Set IDs resolves via ProcessorRef -> CpuSetId.
  • Missing CPU Set mapping fails without native apply.
  • Clear selection calls SetProcessDefaultCpuSets(handle, null, 0).
  • Legacy ApplyCpuSetMask(long) remains characterized for single-group <=64 and does not represent Group 1 CPU0.

Validation

  • dotnet test "ThreadPilot_1.sln" --configuration Release --no-restore passes: 189 passed, 0 failed.

Scope intentionally left unchanged

  • No ProcessService runtime wiring to CpuSelection.
  • No UI changes.
  • No preset generator changes.
  • No profile/core-mask migration changes.
  • No anti-cheat or protected-process bypass behavior.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 61.53846% with 55 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Platforms/Windows/ProcessCpuSetHandler.cs 41.25% 34 Missing and 13 partials ⚠️
Platforms/Windows/IProcessCpuSetNativeApi.cs 0.00% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 256088546f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +107 to +110
staticCpuSetMapping = CpuSetMapping.Empty;
}

staticInitialized = true;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry CPU-set mapping after initialization failures

Marking static initialization as complete even in the exception path makes a transient GetSystemCpuSetInformation failure permanent for the process lifetime. After one failed probe, staticCpuSetMapping is frozen as Empty, so later handlers never retry and both legacy mask application and processor-resolved ApplyCpuSelection will keep failing until restart. This regresses resiliency versus the prior behavior that retried on subsequent handler creation.

Useful? React with 👍 / 👎.

@PrimeBuild-pc PrimeBuild-pc merged commit 290826b into main May 19, 2026
3 checks passed
@PrimeBuild-pc PrimeBuild-pc deleted the codex-cpu-topology-v2-phase-3 branch May 19, 2026 15:18
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.

2 participants