Repository navigation
Add CodSpeed continuous benchmarking for the build pipeline - #87
shenxianpeng wants to merge 3 commits into
Conversation
Establish a measured performance baseline before starting optimization work on the build pipeline (upstream issue mkdocs/mkdocs#3695). The new benchmarks/ suite (pytest + pytest-codspeed, hatch env 'bench') covers the real hot paths: * clean full builds of synthetic sites at 10/50/200 pages, config loading included to match the 'mkdocs serve' rebuild loop * a dirty rebuild ('mkdocs serve --dirty' inner-loop proxy) * a single Page.render() call (exposes the per-page markdown.Markdown construction overhead) * a single page's Jinja template render with a large nav (exposes the O(N^2) sitewide rendering term) * search index population and serialization * file discovery and navigation construction Synthetic sites are generated on the fly with realistic Markdown (headings, prose, fenced code, cross-page and anchor links). Site sizes are overridable via MKDOCS_BENCH_SIZES for local scaling studies. The suite intentionally avoids importing mkdocs.tests (whose package init installs a logging handler that raises on warnings) and runs on a single Python version for comparability. benchmarks/ is not shipped in the wheel or sdist. CI: new codspeed.yml workflow runs the suite under CodSpeed instrumentation on pushes to main and pull requests, giving every PR an automatic performance comparison against main once the CodSpeed GitHub App is installed and the CODSPEED_TOKEN secret is set. Local wall-time baseline (this machine, Python 3.11): full build 212ms/384ms/1.44s at 10/50/200 pages; scaling study 100/400/1600 pages: 0.78s/3.7s/35.3s, i.e. 7.8/9.3/22.1 ms per page - the superlinear growth reported in mkdocs/mkdocs#3695.
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
|
Superseded by #88 (the CodSpeed wizard PR), which was merged as the base benchmark setup — its OIDC authentication needs no token secret and its 23 micro-benchmarks give finer-grained regression attribution. The pieces unique to this PR (size-parametrized full builds for scaling studies, the dirty-rebuild serve-loop proxy, and a large-nav template render that actually exposes the O(N²) term from mkdocs/mkdocs#3695) will follow as an incremental PR on top of the merged structure. The baseline scaling numbers measured here (100/400/1600 pages → 7.8/9.3/22.1 ms per page) remain valid reference data. Generated by Claude Code |
Establishes a measured performance baseline before starting optimization work on the build pipeline (upstream issue mkdocs/mkdocs#3695).
What's included
benchmarks/suite (pytest + pytest-codspeed, new hatch envbench) covering the real hot paths:mkdocs serverebuild loop)mkdocs serve --dirtyinner-loop proxy)Page.render()call — exposes the per-pagemarkdown.Markdownconstruction overhead.github/workflows/codspeed.yml— runs the suite under CodSpeed instrumentation on pushes tomainand PRs (SHA-pinnedCodSpeedHQ/actionv5.0.3, following repo convention)hatch run bench:test(smoke) /hatch run bench:codspeed(measure); sizes overridable viaMKDOCS_BENCH_SIZES; docs inbenchmarks/README.mdandCONTRIBUTING.mdBaseline numbers (wall-time fallback, Linux container, CPython 3.11)
Scaling study (
MKDOCS_BENCH_SIZES=100,400,1600, full build only):4× the pages costs 9.5× the time — the superlinear growth from mkdocs/mkdocs#3695, driven by the O(N²) nav rendering term. This is the baseline the upcoming optimization PRs will be measured against.
One-time manual setup required (@shenxianpeng)
mkdocs-ng/mkdocs.CODSPEED_TOKEN(this is the repository's first secret).mainestablishes the instrumented baseline; subsequent PRs get automatic performance-comparison comments.Until the app/token is set up, the workflow's benchmark run still executes; only the report upload is affected.
Verification
hatch run bench:testequivalent passes (8 benchmarks), ruff/isort/markdownlint cleanpython -m buildconfirmsbenchmarks/is not shipped in the wheelRelated Issue
Groundwork for upstream mkdocs/mkdocs#3695 (build/serve performance).
Checklist
docs/about/release-notes.mdupdated (if applicable)🤖 Generated with Claude Code
https://claude.ai/code/session_018Hw7x9BxxpuKiLkzjLczp9
Generated by Claude Code