8000 perf: budgets for import, first-call and solver work (#347) by rafatahmed · Pull Request #351 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content

perf: budgets for import, first-call and solver work (#347) - #351

Merged
rafatahmed merged 1 commit into
mainfrom
perf/benchmark-budgets
Nov 27, 2026
Merged

rafatahmed merged 1 commit into
mainfrom
perf/benchmark-budgets

Conversation

@rafatahmed
Copy link
Copy Markdown
Owner

Closes #347

The 0.7.1 speedups (#335, #337, #339, #342) had no guard against regressing. benchmarks/performance.py (asv) already measures, but only on demand and with no thresholds.

Added

  • python -m tools.performance_budgets check|measure|write-budgets (standard library only).
  • benchmarks/budgets.json with the agreed budgets and the machine it was recorded on.
  • Hard gates, machine-independent, also run by tests/test_performance_budgets.py in the normal suite: modules loaded by import flahax (exactly 0), by the first recommend (17), equilibrium solves and Newton iterations for the four reference fixtures (iterations: measured +10 percent, at least 2), and the pH-grid warm start must need at most 0.6 of the cold-start iterations (measured 0.47).
  • Timings (import, first call, second call; median and p90 over 7 fresh processes) divided by a fixed pure-Python calibration loop in the same run, budgeted at 3 times the measured value. They are reported and fail only with --strict-timing, since machine noise is large (first-call relative median ranged 1.8 to 9.7 over 12 runs).
  • Bytecode is compiled first and PYTHONDONTWRITEBYTECODE is removed in the children, so imports are not recompiled.
  • The manual benchmark workflow runs check and uploads the JSON. CHANGELOG entry; roadmap H6 marked done.

Measured (Windows, Python 3.13, compiled): import 0.6 ms, first recommend 46 to 54 ms, second 3.8 ms. Counts were identical on Python 3.11, 3.12, 3.13 and 3.14.

Verified locally

  • Negative controls: disabling the warm start fails the iteration and warm-ratio budgets; adding an eager import to __init__ fails the module budget.
  • tools/performance_budgets.py has 100 percent line and branch coverage (the coverage gate requires it for tools).
  • ruff 0.8.4 check and format; files are LF; changelog, manifest, release-hygiene, documentation, benchmark and lazy-import tests pass.

Not run: the full pre-push suite (hours); CI runs the full gate. Linux and macOS counts are not measured yet; if a platform shifts an iteration count by more than the headroom, CI will show it.

@rafatahmed rafatahmed added the enhancement New feature or request label Nov 27, 2026
@rafatahmed rafatahmed self-assigned this Nov 27, 2026
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 Flahax | 🛠️ Build #36218688 | 📁 Comparing 51005f6 against latest (0acf7e4)

  🔍 Preview build  

1 file changed
± changelog.html

@codecov
codecov Bot commented Nov 27, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0acf7e4) to head (51005f6).

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #351    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          150       151     +1     
  Lines        17596     17754   +158     
  Branches      3561      3581    +20     
==========================================
+ Hits         17596     17754   +158     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rafatahmed
rafatahmed marked this pull request as ready for review November 27, 2026 20:18
@rafatahmed
rafatahmed merged commit 27785a0 into main Nov 27, 2026
29 checks passed
@rafatahmed
rafatahmed deleted the perf/benchmark-budgets branch November 27, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0.7.1: performance regression benchmark with budgets

1 participant

0