Skip to content

Use AllocCheck static analysis for allocation tests - #59

Merged
ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:alloccheck-tests
Jan 26, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:alloccheck-tests

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

Replaces flaky runtime @allocated tests with AllocCheck's check_allocs() for robust static allocation analysis.

Changes

  • AllocCheck static analysis: Uses check_allocs(func, types) which analyzes LLVM IR for allocation sites at compile-time, rather than @allocated which measures runtime allocations
  • No warmup needed: Static analysis is deterministic and doesn't depend on JIT state or GC artifacts
  • Type-based testing: Verifies function type signatures don't allocate, covering both Int64 and Float64 vector types
  • Fixes Julia 1.12 test failures: The previous @allocated tests spuriously reported non-zero allocations (16 bytes for findfirstequal, 576 bytes for findfirstsortedequal) on large vectors due to GC measurement noise

Why static analysis is better

Aspect @allocated (runtime) check_allocs() (static)
Measurement Runtime heap allocation LLVM IR analysis
Warmup needed Yes (JIT artifacts) No
GC noise Can report spurious allocations Deterministic
Julia version Behavior varies (1.12 issues) Consistent

Depends on

Test plan

  • Local QA tests pass
  • CI tests pass

🤖 Generated with Claude Code

Replace runtime @allocated tests with AllocCheck's check_allocs() for
more robust allocation checking:

- check_allocs() does compile-time LLVM IR analysis to find allocation
  sites, rather than measuring runtime allocations which can be noisy
  due to GC bookkeeping artifacts on Julia 1.12+
- No warmup needed since it's static analysis, not runtime measurement
- Tests verify type combinations don't allocate, not specific data values
- Added coverage for both Int64 and Float64 vector types

This resolves the flaky @allocated tests that were spuriously reporting
non-zero allocations on Julia 1.12 for large vectors.

Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas
ChrisRackauckas merged commit 4344b3b into SciML:main Jan 26, 2026
17 of 20 checks passed
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.

3 participants