Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

  • Add PrecompileTools as a dependency to OptimizationBase
  • Add precompilation workload for common operations (OptimizationFunction and OptimizationProblem creation)

Performance Improvements

Metric Before After Improvement
Loading time 1.33s 1.33s Same
TTFX (problem creation) 0.081s 0.024s 70%
Total startup+TTFX 1.41s 1.35s ~4%

Analysis Performed

  1. Baseline measurements: Measured startup time (~1.33s) and TTFX for OptimizationProblem creation (~0.081s)

  2. Invalidation analysis: Used SnoopCompile to check for invalidations. Found 32 minor invalidation trees (1 child each), all from external dependencies (FillArrays, SparseConnectivityTracer, RecursiveArrayTools, SciMLBase) - none actionable for this package.

  3. TTFX profiling: Used @snoop_inference to profile inference during first use. Most time spent in Base, Core, and SparseMatrixColorings rather than OptimizationBase/SciMLBase code.

  4. Precompilation workload: Added minimal workload that covers the most common use case - creating OptimizationFunction and OptimizationProblem with and without bounds.

Test Results

All OptimizationBase tests pass (703 tests in ~8.5 minutes).

Changes

  • lib/OptimizationBase/Project.toml: Added PrecompileTools dependency
  • lib/OptimizationBase/src/OptimizationBase.jl: Include precompilation file
  • lib/OptimizationBase/src/precompilation.jl: New precompilation workload

cc @ChrisRackauckas

🤖 Generated with Claude Code

This adds a precompilation workload to OptimizationBase that precompiles
the most common operations: OptimizationFunction and OptimizationProblem
creation with and without bounds.

## Performance improvements

- TTFX for OptimizationProblem creation: 0.081s -> 0.024s (~70% improvement)
- Loading time remains essentially unchanged (~1.33s)

## Analysis performed

- Measured baseline startup and TTFX times
- Checked for invalidations using SnoopCompile (32 minor trees, all from
  dependencies, none actionable)
- Profiled inference during TTFX to identify precompilation targets
- Added minimal precompile workload for common use cases

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@ChrisRackauckas
Copy link
Member

Baseline measurements: Measured startup time (~1.33s) and TTFX for OptimizationProblem creation (~0.081s)

Those types are in SciMLBase, so the precompilation here is in the wrong repo.

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