Repository navigation
test(perf): time the API endpoints against a synthetic database - #145
Conversation
Fetching one diagnostic raised a 500 when the provider registry did not know it, while the list endpoints already fell back to an empty description. The three lookups now share one helper.
Adds tests/perf, which requests common endpoints against a production-shaped synthetic database from climate_ref.testing.synthetic. Each endpoint fails when a query reads a whole large table it is not allowed to. `make perf-compare` runs the same tests on a base ref and fails if a median is over 30% slower, and CI runs it on every pull request. The tests skip until the pinned climate-ref ships the generator.
📝 Walkthrough
Priority: ➖ Normal Change: Other · Severity of issue fixed: Low Merge Risk: 🟡 Moderate · up to
|
Adds scripts/perf-database.py, which builds the synthetic database and a copy migrated down to a given Alembic revision. perf-compare.sh runs the base against the copy matching its climate-ref, so a release such as v0.8.2 can be the baseline. REF_PERF_DATABASE points the tests at a prebuilt database, and the scan check is skipped when the generator is missing. CI caches the databases, keyed on both lock files.
Removes scripts/perf-database.py and REF_PERF_DATABASE, now that the v0.8.2 baseline is recorded. A base without the synthetic database generator skips again. The CI cache for the databases stays.
* origin/main: fix: stop Sentry collecting HTTP bodies, matching v10 behaviour docs: add changelog for #146 chore(deps): frontend lock file maintenance and sentry-javascript v11 chore(deps): backend lock file maintenance
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
-
⚙️ Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6a4a2500-8e49-41c8-8b6c-532dfcd16093
⛔ Files ignored due to path filters: 1
-
backend/uv.lockis excluded by!**/*.lock
📒 Files selected for processing: 12
-
.github/workflows/ci.ymlbackend/Makefilebackend/README.mdbackend/pyproject.tomlbackend/scripts/perf-compare.shbackend/src/ref_backend/models/diagnostics.pybackend/tests/perf/README.mdbackend/tests/perf/conftest.pybackend/tests/perf/test_endpoints.pybackend/tests/test_api/test_routes/test_diagnostics.pychangelog/145.fix.mdchangelog/145.trivial.md
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
-
Adds a performance suite for the API in
backend/tests/perf. It requests 20 common endpoints against the production-shaped synthetic database from climate-ref (Climate-REF/climate-ref#1009). Each endpoint is anEndpoint(id, path, params)entry inENDPOINTS, so adding one is a single line.allowed_scans.make perf-comparechecks out the base ref in a temporary worktree and runs this branch's tests against both. It fails when an endpoint's median is over 30% slower. Running the same code twice drifts up to about 22%. A 10 ms sleep added todatasets.getfailed it at +679%.backend-perfruns the compare on every PR.GET /diagnostics/{provider}/{slug}when the provider registry doesn't know the diagnostic. The list endpoints already fell back to an empty description, and all three lookups now share one helper.7 endpoints already read a whole large table, so their
allowed_scansrecord today's behaviour rather than what they should read. Worth a look:diagnostics/?mip_era=CMIP6scansexecution_groupwhile the unfiltered list doesn't, andexecutions/statisticsis the slowest at about 240 ms at a tenth of production size.Blocked on a climate-ref release with #1009. Until then the perf tests skip, so the CI job passes without checking anything. Locally against that branch, all 20 endpoints pass and
make test-perftakes about 15 s including the 9 s database build.Summary by CodeRabbit