perf: give currRecDepth its own ReaderT layer in CoreM - #14970
Conversation
|
!bench |
|
Benchmark results for f409edb against 696e847 are in. There are significant results. @Kha
Large changes (6🟥)
Medium changes (11✅, 1🟥)
Small changes (490✅, 175🟥)
|
|
Mathlib CI status (docs):
|
|
Reference manual CI status:
|
f409edb to
f51ba22
Compare
|
!bench |
|
Benchmark results for f51ba22 against e991a05 are in. There are significant results. @Kha
Large changes (2✅, 5🟥)
Medium changes (30✅, 2🟥)
Small changes (754✅, 65🟥)
|
|
!bench mathlib |
|
Benchmark results for leanprover-community/mathlib4-nightly-testing@3495667 against leanprover-community/mathlib4-nightly-testing@78f2465 are in. There are significant results. @Kha
No significant changes detected. |
08499f9 to
4772a04
Compare
4772a04 to
6382ea1
Compare
|
!bench |
6382ea1 to
69ef47f
Compare
|
!bench |
|
Benchmark results for 69ef47f against 19c7959 are in. There are significant results. @Kha
Large changes (6🟥)
Medium changes (9✅, 1🟥)
Small changes (468✅, 197🟥)
|
This PR stops the recursion-depth guard from rebuilding `Core.Context` on every recursive step. Roughly 96% of `Core.Context` reconstructions exist only to bump the depth counter, and each one paid a reference count increment per pointer field. `withReader` can never reuse the `Context` record, so keeping `currRecDepth` there made every `withIncRecDepth` rebuild it. As its own reader layer the depth is just an extra argument, so a recursion step neither allocates nor touches a reference count. The layer sits inside the `Context` reader so that a bare `read` still resolves to `Context`, and `CoreM.run` gains an initial-depth parameter so nested command elaboration keeps inheriting its caller's depth. Note this changes `CoreM`'s arity, which is externally observable in LCNF output.
69ef47f to
dd005b0
Compare
|
The adaptation PR for this PR is leanprover/downstream-lean4#31. |
This PR stops the recursion-depth guard from rebuilding
Core.Contexton every recursive step. Roughly 96% ofCore.Contextreconstructions exist only to bump the depth counter, and each one paid a reference count increment per pointer field. -0.77%/-1.10% Mathlib/core instrs, -0.55%/-2.88% wall-clock.withReadercan never reuse theContextrecord, so keepingcurrRecDepththere made everywithIncRecDepthrebuild it. As its own reader layer the depth is just an extra argument, so a recursion step neither allocates nor touches a reference count. The layer sits inside theContextreader so that a barereadstill resolves toContext, andCoreM.rungains an initial-depth parameter so nested command elaboration keeps inheriting its caller's depth.