Skip to content

Analyse each file on a shared base compilation - #281

Draft
machadoit wants to merge 1 commit into
masterfrom
tar-269-shared-base-compilation
Draft

machadoit wants to merge 1 commit into
masterfrom
tar-269-shared-base-compilation

Conversation

@machadoit

Copy link
Copy Markdown
Contributor

SonarC# builds a new compilation, with all ~160 framework assemblies, for every file, and analyses all files of a chunk at once. Run time and memory grow with the chunk, which is why SonarC# gets only ~100 KB per pod. TAR-269, findings: SonarC# rebuilds the whole .NET framework for every file it analyses.

  • One base compilation per run holds the framework references. Each file is analysed on a compilation derived from it (AddSyntaxTrees), so the references are bound once.
  • Files are analysed one at a time, so only one file's compilation is in memory. Since DOTNET_PROCESSOR_COUNT=1 (Set DOTNET_PROCESSOR_COUNT=1 in the runtime image #279) the pod already ran on one core, so no parallelism is lost.
  • Each file is still compiled on its own: results don't change.

Local runs, AutoMapper source, default patterns, 1 CPU:

Chunk master this PR Output
110 KB, 31 files 12.5s / 271 MiB 9.9s / 212 MiB identical
1.6 MB, 413 files 117s / 720 MiB 85s / 287 MiB identical (925 issues)

Once this is out, SonarC#'s splitChunkSize can go up (10 → 40 first) without approaching the pod's 1300 Mi limit.

  • CI plugins_test (multiple tests) passes unchanged
  • Test on dev: analyse troubleshoot-codacy/csharp-sonar-sample; same issues as before, lower SonarC# task times

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

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.

@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 changed compilation workflow has no reported logic or quality defects, but its reuse, per-file isolation, sequential processing, diagnostic equivalence, and failure handling are not covered by automated tests.

Test suggestions

  • Verify framework references and compilation setup are reused across multiple analyzed files.
  • Verify each file is analyzed independently and diagnostics are attributed to the correct filename.
  • Verify multiple files are processed sequentially without concurrent analysis tasks.
  • Verify analysis results remain equivalent to the previous per-file compilation behavior.
  • Verify parsing and diagnostic failures still produce the expected error result for the affected file.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify framework references and compilation setup are reused across multiple analyzed files.
2. Verify each file is analyzed independently and diagnostics are attributed to the correct filename.
3. Verify multiple files are processed sequentially without concurrent analysis tasks.
4. Verify analysis results remain equivalent to the previous per-file compilation behavior.
5. Verify parsing and diagnostic failures still produce the expected error result for the affected file.

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

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.

1 participant