Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

  • Added allocation regression tests to ensure the core computational hotpath remains allocation-free
  • Verified that the package is already well-optimized with excellent performance

Benchmarking Results

The benchmarking analysis showed that:

  • serial_fvm_eqs! is completely allocation-free for both FVMProblem and FVMSystem
  • get_triangle_contributions!, get_boundary_edge_contributions!, and get_source_contributions! are all allocation-free
  • The parallel path has minimal allocations (~8KB for FVMProblem, ~27KB for FVMSystem) which are from Julia's threading infrastructure (expected and unavoidable behavior from Threads.@threads)

Benchmark Numbers (611 triangles, 342 vertices)

Function Time Allocations
serial_fvm_eqs! ~136 μs 0 bytes
get_triangle_contributions! ~106 μs 0 bytes
get_boundary_edge_contributions! ~16 μs 0 bytes
get_source_contributions! ~12 μs 0 bytes

Individual Function Performance

Function Time Allocations
get_shape_function_coefficients ~9 ns 0 bytes
get_fluxes ~5 ns 0 bytes
fvm_eqs_single_triangle! ~28 ns 0 bytes

Changes

  1. test/alloc_tests.jl (new file): Allocation regression tests for:

    • FVMProblem serial path functions
    • FVMSystem serial path functions
  2. test/runtests.jl: Updated to include allocation tests in the test suite (conditionally based on GROUP env variable for CI flexibility)

Test Plan

  • Allocation tests pass locally (7/7 tests)
  • Full test suite runs (allocation tests integrated)
  • Verified no regressions in existing functionality

Notes

The package is already well-optimized with:

  • Type-stable core functions with @inline annotations
  • Pre-computed and cached triangle properties
  • No heap allocations in the main computation loop

These tests will help prevent future performance regressions.

cc @ChrisRackauckas

🤖 Generated with Claude Code

This commit adds allocation regression tests to ensure the core
computational hotpath remains allocation-free. The benchmarking
analysis showed that:

- serial_fvm_eqs! is completely allocation-free for both FVMProblem
  and FVMSystem
- get_triangle_contributions!, get_boundary_edge_contributions!, and
  get_source_contributions! are all allocation-free
- The parallel path has minimal allocations (~8KB) which are from
  Julia's threading infrastructure (expected behavior)

Key changes:
- Add test/alloc_tests.jl with allocation regression tests
- Update test/runtests.jl to include allocation tests in the test suite
  (conditionally based on GROUP env variable for CI flexibility)

The package is already well-optimized with excellent performance:
- Core functions are type-stable and fully inlined
- Triangle properties are pre-computed and cached
- No heap allocations in the main computation loop

🤖 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