This repository was archived by the owner on May 12, 2026. It is now read-only.
Performance improvements: calc𝒪estimates zero-alloc + cleaner ConvergenceSimulation#174
Closed
ChrisRackauckas-Claude wants to merge 1 commit into
Closed
Conversation
…enceSimulation ## Summary - **calc𝒪estimates**: Optimized to be zero-allocation by computing mean directly without allocating intermediate vector. Also uses Float64 accumulator to handle Rational inputs correctly. - Before: 768 bytes, 10 allocations, ~700 ns - After: 0 bytes, 0 allocations, ~50 ns - Speedup: ~14x faster - **ConvergenceSimulation constructor**: Simplified by removing redundant loop that extracted scalar values from 1-element arrays (no longer needed since calc𝒪estimates now returns scalars directly) - **analyticless_test_convergence (SDE)**: Refactored Brownian motion generation with a helper function `_generate_brownian_values!` that pre-allocates arrays and computes cumulative sums in-place, avoiding comprehension-based allocations. - **Added AllocCheck tests**: New test file `test/alloc_tests.jl` that verifies calc𝒪estimates remains allocation-free, preventing future regressions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves performance of key functions in DiffEqDevTools.jl and adds allocation regression tests.
Benchmark Results
calc𝒪estimates- Computes convergence order estimates from error ratiosChanges
calc𝒪estimates(convergence.jl:287-302): Optimized to be zero-allocation by computing the mean of log2 ratios directly in a loop rather than allocating an intermediateVector. Also usesFloat64accumulator to correctly handleRationalinputs.ConvergenceSimulationconstructor (convergence.jl:32): Simplified by removing redundant loop that was extracting scalar values from 1-element arrays. Sincecalc𝒪estimatesnow returns scalars directly, this code is no longer needed.analyticless_test_convergence(convergence.jl:123-180): Refactored Brownian motion generation with a new helper function_generate_brownian_values!that:Added AllocCheck tests (test/alloc_tests.jl): New test file that verifies
calc𝒪estimatesremains allocation-free, preventing future performance regressions.Test plan
calc𝒪estimatescc @ChrisRackauckas
🤖 Generated with Claude Code