Skip to content

Set DOTNET_PROCESSOR_COUNT=1 in the runtime image - #279

Merged
lolgab merged 1 commit into
masterfrom
sonar-csharp-processor-count
Dec 3, 2026
Merged

lolgab merged 1 commit into
masterfrom
sonar-csharp-processor-count

Conversation

@lolgab

@lolgab lolgab commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Tool pods have a memory limit but no CPU limit, so cgroup cpu.max is max and .NET's Environment.ProcessorCount is every core of the node (16–64), not the pod's 1000m CPU request. The thread pool's minimum worker count is Environment.ProcessorCount, and the analyzer starts one task per file (CodeAnalyzer.Analyze + Task.WhenAll) while Roslyn runs analyzers with concurrentAnalysis: true on the same pool. On a large node that keeps many per-file compilations (each referencing the whole framework) alive at once, pushing the pod towards its 1300Mi limit, where the kernel kills it.

Not done on purpose: changing the per-file concurrency in CodeAnalyzer. This PR only stops the runtime from sizing itself to the node.

Same class of fix as codacy/codacy-opengrep#50.

  • Build the image and run the multiple-tests suite (CircleCI plugins_test)
  • After deploy, 7 days: sonar-csharp ToolOutOfMemory count vs before
  • After deploy, 7 days: p99 run time and timeouts vs before (1 core of parallelism can be slower on idle nodes)

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@lolgab
lolgab marked this pull request as ready for review December 3, 2026 10:52
@lolgab
lolgab enabled auto-merge (squash) December 3, 2026 10:52

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

✅ No blocking issues noticed

No blocking findings were identified. The requested runtime configuration change has no conflicting code-review or quality findings.

Test suggestions

  • Build the runtime image and verify the analyzer observes Environment.ProcessorCount as 1.
  • Run the existing multiple-tests suite against the updated image.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Build the runtime image and verify the analyzer observes Environment.ProcessorCount as 1.
2. Run the existing multiple-tests suite against the updated image.

TIP Add review instructions in .codacy/instructions/review.md, or an AGENTS.md, so the reviewer knows your conventions.
TIP How was this review? Give us feedback

@lolgab
lolgab merged commit bf226f3 into master Dec 3, 2026
4 checks passed
@lolgab
lolgab deleted the sonar-csharp-processor-count branch December 3, 2026 10:57
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