Skip to content

Comments

Add comprehensive allocation tests for performance regression prevention#143

Open
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:perf-improvements-20260101-030211
Open

Add comprehensive allocation tests for performance regression prevention#143
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:perf-improvements-20260101-030211

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

  • Added comprehensive allocation tests using AllocCheck.jl to verify zero-allocation behavior for hot paths
  • The tests document and protect the already-optimized performance of the package

Performance Analysis Results

After thorough benchmarking and profiling, the package was found to already be well-optimized:

Operation Time Allocations
Scalar getp/getsym ~4ns 0
Tuple getp/getsym ~5ns 0
Observed function evaluation ~5ns 0 (after compilation)
Index lookups ~7-10ns 0
In-place array getp ~8ns 0
Scalar setp/setsym ~4ns 0

New Allocation Tests

The new test file (test/alloc_test.jl) covers:

  • Scalar getp/setp with arrays and ProblemState
  • Scalar getsym/setsym with arrays and ProblemState
  • Tuple getp/getsym
  • In-place array getp
  • Observed function (expression) evaluation
  • Index lookups (variable_index, parameter_index, is_variable, is_parameter)
  • Value provider interface functions

Test plan

  • All Core tests pass locally
  • New allocation tests pass (19 tests)

cc @ChrisRackauckas

🤖 Generated with Claude Code

This PR adds a new test file (test/alloc_test.jl) that uses AllocCheck.jl to
verify zero-allocation behavior for the hot paths in SymbolicIndexingInterface.

After thorough benchmarking and profiling, the package was found to already be
well-optimized:
- Scalar getters/setters: 0 allocations (~4ns per call)
- Tuple getters/setters: 0 allocations (~5ns per call)
- Observed function evaluation: 0 allocations after first compilation
- Index lookups: 0 allocations (~7-10ns per call)
- In-place array getters: 0 allocations

The new tests document and protect this performance:
- Scalar getp/setp with arrays and ProblemState
- Scalar getsym/setsym with arrays and ProblemState
- Tuple getp/getsym
- In-place array getp
- Observed function (expression) evaluation
- Index lookups (variable_index, parameter_index, is_variable, is_parameter)
- Value provider interface functions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@AayushSabharwal
Copy link
Member

Should this also disable fail_fast in CI so that the jobs that will pass with AllocCheck do? Until this testset is split out into its own group

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