Skip to content

Add allocation regression tests for zero-allocation code paths#36

Closed
ChrisRackauckas-Claude wants to merge 3 commits into
SciML:mainfrom
ChrisRackauckas-Claude:perf-improvements-20251229-090102
Closed

Add allocation regression tests for zero-allocation code paths#36
ChrisRackauckas-Claude wants to merge 3 commits into
SciML:mainfrom
ChrisRackauckas-Claude:perf-improvements-20251229-090102

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

Summary

This PR adds comprehensive allocation tests to prevent performance regressions in the critical IIP (in-place) code paths.

Changes

  • Add test/alloc_tests.jl with allocation tests for:

    • LiFukushimaLineSearch (IIP) - verified zero-allocation
    • RobustNonMonotoneLineSearch (IIP) - verified zero-allocation
    • NoLineSearch - verified zero-allocation
    • StaticLiFukushimaLineSearch (SVector) - verified zero-allocation
    • Scalar LiFukushimaLineSearch - verified zero-allocation
    • Larger problems (10D) - verified zero-allocation
  • Add StaticArrays as test dependency for SVector allocation tests

Performance Analysis Summary

The package is already well-optimized. Here are the benchmark results:

Algorithm Mode Allocations Notes
LiFukushimaLineSearch IIP 0 bytes Zero-allocation
RobustNonMonotoneLineSearch IIP 0 bytes Zero-allocation
NoLineSearch - 0 bytes Zero-allocation
LiFukushimaLineSearch Static (SVector) 0 bytes Zero-allocation
LiFukushimaLineSearch Scalar 0 bytes Zero-allocation
BackTracking IIP ~270-7000 bytes Expected - due to AD operations

BackTracking allocates due to SciMLJacobianOperators/ForwardDiff automatic differentiation operations, which is expected and cannot be avoided without pre-allocating AD buffers (which would require changes to external packages).

Test Plan

  • All new allocation tests pass
  • Existing tests continue to pass (except pre-existing Enzyme compatibility issues)
  • Tests are tagged with :alloc for easy filtering

CC: @ChrisRackauckas

Generated with Claude Code

ChrisRackauckas and others added 3 commits December 29, 2025 09:29
This PR adds comprehensive allocation tests to prevent performance
regressions in the critical IIP (in-place) code paths.

## Summary

- Add test/alloc_tests.jl with allocation tests for:
  - LiFukushimaLineSearch (IIP) - verified zero-allocation
  - RobustNonMonotoneLineSearch (IIP) - verified zero-allocation
  - NoLineSearch - verified zero-allocation
  - StaticLiFukushimaLineSearch (SVector) - verified zero-allocation
  - Scalar LiFukushimaLineSearch - verified zero-allocation
  - Larger problems (10D) - verified zero-allocation

- Add StaticArrays as test dependency for SVector allocation tests

## Performance Analysis Summary

The package is already well-optimized:

| Algorithm | Mode | Allocations |
|-----------|------|-------------|
| LiFukushimaLineSearch | IIP | 0 bytes |
| RobustNonMonotoneLineSearch | IIP | 0 bytes |
| NoLineSearch | - | 0 bytes |
| LiFukushimaLineSearch | Static | 0 bytes |
| BackTracking | IIP | ~270-7000 bytes (expected - due to AD) |

BackTracking allocates due to SciMLJacobianOperators/ForwardDiff
automatic differentiation operations, which is expected behavior.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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