feat: add `lake samply` command
This PR adds a lake samply command that records a CPU profile of a Lean
executable using samply, symbolicates
addresses, demangles Lean compiler names, and serves the result to
Firefox Profiler.
This replaces the Python scripts in script/profiler/ with a single Lake
command.
- [X] Depends on https://github.com/leanprover/lean4/pull/12539.
From the lean4 repo:
$ cd tests/bench/mergeSort
$ lake samply mergeSort -- -- 10
Building mergeSort
Recording profile...
Starting symbolication server...
Symbolicating and demangling...
Demangled 335 names, wrote profile-demangled.json.gz
Serving on http://127.0.0.1:3757/
Open in Firefox Profiler:
https://profiler.firefox.com/from-url/http%3A%2F%2F127.0.0.1%3A3757%2F...%2Fprofile.json
Press Ctrl+C to stop.
Open the Firefox Profiler URL in your browser. Function names like
List.MergeSort.Internal.mergeSortTR₂ appear instead of their mangled forms.
Lake-level options:
-o FILE— output path (default./profile-demangled.json.gz)--raw— skip symbolication and demangling--no-serve— write output file and exit without starting the HTTP server
Anything after -- is forwarded verbatim to samply record; an inner --
separates samply's own flags from the profiled executable's arguments:
lake samply mergeSort # no samply or exe args
lake samply mergeSort -- --rate 2000 # only samply args
lake samply mergeSort -- -- 10 # only exe args
lake samply mergeSort -- --rate 2000 -- 10 # both
There's an end-to-end test in tests/lake/tests/samply/ that builds a minimal
executable, runs lake samply --raw and lake samply --no-serve, and validates
the output is well-formed Firefox Profiler JSON. The test gracefully skips when
samply isn't installed or when perf_event_open isn't available.
🤖 Prepared with Claude Code
Mathlib CI status (docs):
- ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the
nightly-with-mathlibbranch. Trygit rebase e9cc84b7c99f64220c952dee026ac0f06a031fc4 --onto 91bd6e19a7b7aca769f9720e1127c768df0cd2a7. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-02-18 06:15:49) - ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the
nightly-with-mathlibbranch. Trygit rebase c948d24b6ddbb41c199c13edc9ebc04104a667bb --onto 333ab1c6f0ce11f33551d6a736054cb72812cad9. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-03-07 01:05:08) - ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the
nightly-with-mathlibbranch. Trygit rebase c948d24b6ddbb41c199c13edc9ebc04104a667bb --onto 4786e082dca22873d14d2a5b9b7c8843380c6e78. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-03-30 07:28:34) - ❗ Mathlib CI can not be attempted yet, as the
nightly-testing-2026-04-11tag does not exist there yet. We will retry when you push more commits. If you rebase your branch ontonightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-04-12 02:23:02) - ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the
nightly-with-mathlibbranch. Trygit rebase a416b90d22990f84607168ac6c520b52c843a25d --onto 5d5642107d0433519265f155ddbfbfb98007a80b. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-05-08 06:16:40) - ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the
nightly-with-mathlibbranch. Trygit rebase 819f4549d9bda7c34f1ae185a3353d7dfd1f19a6 --onto 5d5642107d0433519265f155ddbfbfb98007a80b. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-05-09 12:30:17) - ✅ Mathlib branch lean-pr-testing-12545 has successfully built against this PR. (2026-05-13 02:46:43) View Log
- ✅ Mathlib branch lean-pr-testing-12545 has successfully built against this PR. (2026-05-22 10:27:06) View Log
- ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the
nightly-with-mathlibbranch. Trygit rebase 5f9b66958dbcad3d3464e223e2c227d0a8e627b6 --onto d2f48db30713019241520218d0965227bbb64eed. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-06-10 13:58:03) - ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the
nightly-with-mathlibbranch. Trygit rebase 5f9b66958dbcad3d3464e223e2c227d0a8e627b6 --onto 58225845d6ead86550a9371cfdcb3d9f0be3fc55. You can force Mathlib CI using theforce-mathlib-cilabel. (2026-06-19 00:16:31)
Reference manual CI status:
- ❗ Reference manual CI will not be attempted unless your PR branches off the
nightly-with-manualbranch. Trygit rebase e9cc84b7c99f64220c952dee026ac0f06a031fc4 --onto 5c7a508e21c5ebc710b0dfe65648d5beba4e34e0. You can force reference manual CI using theforce-manual-cilabel. (2026-02-18 06:15:50) - ❗ Reference manual CI will not be attempted unless your PR branches off the
nightly-with-manualbranch. Trygit rebase c948d24b6ddbb41c199c13edc9ebc04104a667bb --onto a165292462a973c20d3cc8c8b23a3ac2334a2a4a. You can force reference manual CI using theforce-manual-cilabel. (2026-03-07 01:05:10) - ❗ Reference manual CI will not be attempted unless your PR branches off the
nightly-with-manualbranch. Trygit rebase c948d24b6ddbb41c199c13edc9ebc04104a667bb --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using theforce-manual-cilabel. (2026-03-30 07:28:36) - ❗ Reference manual CI can not be attempted yet, as the
nightly-testing-2026-03-25tag does not exist there yet. We will retry when you push more commits. If you rebase your branch ontonightly-with-manual, reference manual CI should run now. You can force reference manual CI using theforce-manual-cilabel. (2026-03-30 11:59:39) - ❗ Reference manual CI can not be attempted yet, as the
nightly-testing-2026-04-11tag does not exist there yet. We will retry when you push more commits. If you rebase your branch ontonightly-with-manual, reference manual CI should run now. You can force reference manual CI using theforce-manual-cilabel. (2026-04-12 02:23:04) - ❗ Reference manual CI will not be attempted unless your PR branches off the
nightly-with-manualbranch. Trygit rebase a416b90d22990f84607168ac6c520b52c843a25d --onto 5d5642107d0433519265f155ddbfbfb98007a80b. You can force reference manual CI using theforce-manual-cilabel. (2026-05-08 06:16:42) - ❗ Reference manual CI will not be attempted unless your PR branches off the
nightly-with-manualbranch. Trygit rebase 819f4549d9bda7c34f1ae185a3353d7dfd1f19a6 --onto 41ecccec6d1244c5f89be2fc76638f22ba37cbc6. You can force reference manual CI using theforce-manual-cilabel. (2026-05-09 12:30:18) - 🟡 Reference manual branch lean-pr-testing-12545 build against this PR didn't complete normally. (2026-05-13 01:54:56) View Log
- 💥 Reference manual branch lean-pr-testing-12545 build failed against this PR. (2026-05-13 01:55:20) View Log
- 💥 Reference manual branch lean-pr-testing-12545 build failed against this PR. (2026-05-22 09:36:32) View Log
- 🟡 Reference manual branch lean-pr-testing-12545 build against this PR didn't complete normally. (2026-05-22 09:36:47) View Log
- ❗ Reference manual CI will not be attempted unless your PR branches off the
nightly-with-manualbranch. Trygit rebase 5f9b66958dbcad3d3464e223e2c227d0a8e627b6 --onto 803553a556fd82fa1060efb0c43eda542130cb16. You can force reference manual CI using theforce-manual-cilabel. (2026-06-10 13:58:05)
Mathlib CI status (docs):
- ✅ Mathlib branch lean-pr-testing-12545 has successfully built against this PR. (2026-03-30 12:55:51) View Log
@kim-em That's a lot of code, what do you want me to review? I'm okay with the interface