Skip to content

perf: add syntactic prefilters before semantic-model calls in all affected analyzers#463

Draft
dnyw4l3n13 wants to merge 1 commit into
mainfrom
perf/457-syntactic-prefilters-before-semantic-model-calls
Draft

perf: add syntactic prefilters before semantic-model calls in all affected analyzers#463
dnyw4l3n13 wants to merge 1 commit into
mainfrom
perf/457-syntactic-prefilters-before-semantic-model-calls

Conversation

@dnyw4l3n13

Copy link
Copy Markdown
Collaborator

Summary

Add cheap syntactic prefilters immediately before semantic-model calls (GetTypeInfo, GetSymbolInfo, FindInvokedMemberSymbol) in ten affected analyzers. Each prefilter uses Identifier.Text on the syntax node's name token and compares against a static HashSet<string>/FrozenSet<string>, avoiding expensive Roslyn semantic lookups for nodes that cannot possibly match.

Affected analyzers:

  • ProhibitedMethodsDiagnosticsAnalyzer — prefilter on banned member names before GetTypeInfo
  • ForceMethodParametersInvocationsDiagnosticsAnalyzer — prefilter on {Serialize, SerializeAsync, Deserialize, DeserializeAsync, Received}
  • ProhibitedMethodInvocationsDiagnosticsAnalyzer — prefilter on {True, False, AddOrUpdate, GetOrAdd, Equals}
  • ProhibitedMethodWithStrictParametersInvocationDiagnosticsAnalyzer — prefilter on {Received, AddJsonFile}
  • ProhibitedClassesInTestAssembliesDiagnosticsAnalyzer — syntactic receiver-name prefilter (Console)
  • ProhibitedSubstituteForUsageInTestBaseDiagnosticsAnalyzer — check name is For before GetSymbolInfo
  • ArgumentExceptionAnalysisDiagnosticsAnalyzer — prefilter on {ArgumentException, ArgumentNullException, ArgumentOutOfRangeException}
  • TestClassFieldsAnalysisDiagnosticsAnalyzer — reorder: readonly/const check BEFORE IsDerivedFromTestBase
  • TestClassPropertyAnalysisDiagnosticsAnalyzer — reorder: accessor-mutability check BEFORE IsDerivedFromTestBase
  • TestDetection.IsTestMethod — attribute-name prefilter {Fact, Theory, FactAttribute, TheoryAttribute} before GetTypeInfo

Test plan

  • All existing tests in FunFair.CodeAnalysis.Tests pass unchanged (no new or removed diagnostics)
  • Benchmarks in FunFair.CodeAnalysis.Benchmark.Tests show reduced mean time and/or allocations vs baseline
  • dotnet build succeeds with no warnings
  • dotnet buildcheck passes

Closes #457

🤖 Generated with Claude Code

Prompt: Perf Phase 1: syntactic prefilters before semantic-model calls in all affected analyzers
@dnyw4l3n13 dnyw4l3n13 self-assigned this Jul 2, 2026
@dnyw4l3n13 dnyw4l3n13 added AI-Work Work for an AI Agent Urgent Urgent Priority labels Jul 2, 2026
@dnyw4l3n13

Copy link
Copy Markdown
Collaborator Author

Pre-commit Hook Failure — Environmental Issue

The pre-commit hook is blocking the commit of the syntactic prefilter implementation due to a missing system utility in the build container.

What the hook ran

The hook detected .cs file changes and ran buildtest, which runs dotnet test on the entire solution (including FunFair.CodeAnalysis.Benchmark.Tests). The benchmark tests use BenchmarkDotNet to run micro-benchmarks, and BenchmarkDotNet internally tries to use pgrep to manage child processes. Since pgrep (from procps) is not installed in this container, BenchmarkDotNet fails to build its auto-generated boilerplate and the benchmark test assertions fail:

Build Error: Exception!
Message: ErrorStartingProcess, pgrep, .../FunFair.CodeAnalysis.Benchmark.Tests/bin/Release/net10.0, No such file or directory

Status of the actual code

The syntactic prefilter implementation is complete and correct:

  • ✅ Build: dotnet build succeeds with 0 warnings
  • ✅ Unit tests: 448/448 pass on both net9.0 and net10.0
  • ✅ Buildcheck: dotnet buildcheck reports "No errors found"
  • ✅ Formatter: dotnet cscleanup makes no changes (already formatted)
  • ✅ CI: All required checks are green (from the last committed state)

Root cause

The build container is missing the procps package (which provides pgrep). This would block any commit of .cs files in this container, not just this PR.

To unblock

Install pgrep in the build container:

apt-get install -y procps

Or, if the CI environment has pgrep available, the code can be committed from a machine with procps installed.

The uncommitted implementation is on the local working tree of branch perf/457-syntactic-prefilters-before-semantic-model-calls.

@dnyw4l3n13 dnyw4l3n13 added the Blocked Blocked by a dependency or external factor label Jul 2, 2026
credfeto added a commit to credfeto/credfeto-orchestrator that referenced this pull request Jul 3, 2026
Adds ps/pkill/free, needed by .NET benchmark tooling (BenchmarkDotNet
process-priority/affinity handling) used in downstream repos. Confirmed
locally with `podman build --format docker` of development-tools plus a
direct check that ps/pkill/free are present and functional in the built
image.

Closes #1061

Prompt: apt-get install -y procps

can you do that in the appropriate base container

needed for funfair-tech/funfair-server-code-analysis#463
credfeto added a commit to credfeto/credfeto-orchestrator that referenced this pull request Jul 3, 2026
## Summary

- Installs `procps` (`ps`, `pkill`, `free`, etc.) in
`containers/base/development-tools/Dockerfile`, the base apt-packages
layer shared by every downstream image (node/python/full/agent).
- Needed by .NET benchmark tooling (BenchmarkDotNet
process-priority/affinity handling) used in downstream repos — see
funfair-tech/funfair-server-code-analysis#463.

Closes #1061

## Test plan

- [x] Local `podman build --format docker -t development-tools:local
containers/base/development-tools` completes successfully end-to-end
(53/53 steps), including the build-time sanity check.
- [x] Verified `ps`, `pkill`, `free` are present and functional in the
built image (`ps from procps-ng 4.0.4`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Work Work for an AI Agent Blocked Blocked by a dependency or external factor Urgent Urgent Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perf Phase 1: syntactic prefilters before semantic-model calls

1 participant