Skip to content

Conversation

ChrisRackauckas-Claude
Copy link
Contributor

Summary

Fixes #744 - resolves const assignment error when setting BenchmarkTools.DEFAULT_PARAMETERS in Julia 1.12+.

In Julia 1.12+, BenchmarkTools.DEFAULT_PARAMETERS became a const and cannot be reassigned. The previous code attempted to:

  1. Save original parameters: old_params = BenchmarkTools.DEFAULT_PARAMETERS
  2. Modify global parameters: BenchmarkTools.DEFAULT_PARAMETERS.seconds = seconds
  3. Restore in finally block: BenchmarkTools.DEFAULT_PARAMETERS = old_params ← This fails

Changes

  • Removed global modification of BenchmarkTools.DEFAULT_PARAMETERS
  • Replaced with local BenchmarkTools.Parameters creation and direct usage via @benchmarkable + BenchmarkTools.run
  • Removed try/finally block that was only needed for parameter restoration
  • Maintains exact same functionality while fixing Julia 1.12+ compatibility

Files Changed

  • lib/LinearSolveAutotune/src/benchmarking.jl:90-93: Removed global parameter setting
  • lib/LinearSolveAutotune/src/benchmarking.jl:235-241: Updated benchmark execution to use local parameters
  • lib/LinearSolveAutotune/src/benchmarking.jl:272-277: Removed try/finally block

Testing

  • ✅ All LinearSolveAutotune tests pass
  • ✅ Benchmarking functionality works correctly with custom parameters
  • ✅ No behavior changes - same results as before

Benefits

  • Fixes Julia 1.12+ compatibility issue
  • Cleaner code without global state modification
  • Thread-safe approach using local parameters
  • Future-proof against further BenchmarkTools.jl const restrictions

🤖 Generated with Claude Code

ChrisRackauckas and others added 2 commits September 1, 2025 14:58
… 1.12

- Remove global modification of BenchmarkTools.DEFAULT_PARAMETERS which
  fails in Julia 1.12+ due to const restriction
- Pass seconds and samples parameters directly to @benchmark macro
- Remove try/finally block that was only needed for parameter restoration
- Fixes issue SciML#744

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

Co-Authored-By: Claude <[email protected]>
… 1.12

- Remove global modification of BenchmarkTools.DEFAULT_PARAMETERS which
  fails in Julia 1.12+ due to const restriction
- Use @benchmarkable and BenchmarkTools.run with custom parameters
- Remove try/finally block that was only needed for parameter restoration
- Fixes issue SciML#744

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

Co-Authored-By: Claude <[email protected]>
@ChrisRackauckas ChrisRackauckas merged commit f1bdc47 into SciML:main Sep 1, 2025
132 of 136 checks passed
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.

[LinearSolveAutotune] Setting BenchmarkTools.DEFAULT_PARAMETERS on Julia 1.12 fails since it is const
2 participants