Skip to content

perf: mark ReaderT context argument as borrow#12942

Merged
hargoniX merged 3 commits intomasterfrom
readert-update
Mar 23, 2026
Merged

perf: mark ReaderT context argument as borrow#12942
hargoniX merged 3 commits intomasterfrom
readert-update

Conversation

@hargoniX
Copy link
Copy Markdown
Contributor

@hargoniX hargoniX commented Mar 17, 2026

This PR marks the context argument of ReaderT as borrowed, causing a wide spread of useful borrow annotations throughout the entire meta stack which reduces RC pressure. This introduces a crucial new behavior: When modifying ReaderT context, e.g. through withReader this will almost always cause an allocation. Given that the ReaderT context is frequently used in a non-linear fashion anyways we think this is an acceptable behavior.

@hargoniX hargoniX added release-ci Enable all CI checks for a PR, like is done for releases fast-ci Forces the use of large runners so that e.g. PR releases are created faster labels Mar 17, 2026
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Mar 17, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

mathlib-lean-pr-testing bot commented Mar 17, 2026

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 133fd016b4ed1f0108945ce2f1a1b7ffbb3f6575 --onto 6714601ee4a123fef0f6ff3e44f01086ba78dfce. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-17 12:02:09)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 4ba85acc464e380c03034763e93506f695ae68d7 --onto 6714601ee4a123fef0f6ff3e44f01086ba78dfce. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-17 21:02:47)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 091726034110408555f0bca58cfebbf39b524147 --onto 61a3443a9569d548a235f785b9a33984bb7ff622. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-18 10:53:14)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 4d6accd55d4ec6997b2a247bce3ecf811beb4c8e --onto 87180a09c49c91577e54284703c73c5ca76be126. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-20 18:39:12)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 4a62d4a79be4298c8738c8bee94f9d325230ad79 --onto 87180a09c49c91577e54284703c73c5ca76be126. You can force Mathlib CI using the force-mathlib-ci label. (2026-03-21 06:02:49)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

leanprover-bot commented Mar 17, 2026

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 133fd016b4ed1f0108945ce2f1a1b7ffbb3f6575 --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using the force-manual-ci label. (2026-03-17 12:02:10)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 4ba85acc464e380c03034763e93506f695ae68d7 --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using the force-manual-ci label. (2026-03-17 21:02:48)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 091726034110408555f0bca58cfebbf39b524147 --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using the force-manual-ci label. (2026-03-18 10:53:15)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 4d6accd55d4ec6997b2a247bce3ecf811beb4c8e --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using the force-manual-ci label. (2026-03-20 18:39:14)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 4a62d4a79be4298c8738c8bee94f9d325230ad79 --onto cfa8c5a036d6990635c6ec50b02d0e806995cec3. You can force reference manual CI using the force-manual-ci label. (2026-03-21 06:02:50)

@github-actions github-actions bot added the changes-stage0 Contains stage0 changes, merge manually using rebase label Mar 17, 2026
@github-actions github-actions bot removed the changes-stage0 Contains stage0 changes, merge manually using rebase label Mar 18, 2026
@hargoniX
Copy link
Copy Markdown
Contributor Author

!bench

@hargoniX hargoniX marked this pull request as ready for review March 20, 2026 16:10
@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Mar 20, 2026

Benchmark results for 1fdf271 against 511be30 are in. Significant changes detected! @hargoniX

  • build//instructions: -165.4G (-1.35%)
  • 🟥 other exited with code -1

Large changes (4✅)

  • size/all/.c//lines: -189.9k (-1.70%)
  • size/all/.ir//bytes: -8MiB (-2.54%)
  • size/install//bytes: -26MiB (-1.05%)
  • size/libleanshared.so//bytes: -7MiB (-5.22%)

Medium changes (15✅)

  • build//instructions: -165.4G (-1.35%)
  • build/module/Init.Data.BitVec.Lemmas//instructions: -1.6G (-1.18%)
  • build/module/Init.Data.Nat.Linear//instructions: -4.5G (-7.28%)
  • build/module/Init.Data.Nat.SOM//instructions: -2.1G (-9.57%) (reduced significance based on absolute threshold)
  • build/module/Lake.CLI.Main//instructions: -1.2G (-3.25%) (reduced significance based on absolute threshold)
  • build/module/Lean.Elab.Do.Legacy//instructions: -1.1G (-2.05%) (reduced significance based on absolute threshold)
  • build/module/Lean.Elab.DocString.Builtin//instructions: -1.1G (-2.16%) (reduced significance based on absolute threshold)
  • build/module/Lean.Meta.Tactic.FunInd//instructions: -1.2G (-1.93%)
  • build/module/Lean.Meta.Tactic.Grind.Arith.CommRing.EqCnstr//instructions: -1.0G (-2.12%)
  • build/module/Lean.Meta.Tactic.Grind.EMatch//instructions: -1.3G (-1.84%) (reduced significance based on absolute threshold)
  • build/module/Std.Data.DHashMap.RawLemmas//instructions: -1.4G (-0.89%)
  • build/module/Std.Data.DTreeMap.Internal.Lemmas//instructions: -3.3G (-1.53%) (reduced significance based on absolute threshold)
  • build/module/Std.Data.Internal.List.Associative//instructions: -1.2G (-1.40%)
  • build/module/Std.Tactic.BVDecide.Bitblast.BVExpr.Circuit.Lemmas.Expr//instructions: -2.2G (-1.88%) (reduced significance based on absolute threshold)
  • build/module/Std.Tactic.BVDecide.LRAT.Internal.Formula.RupAddResult//instructions: -1.1G (-2.07%) (reduced significance based on absolute threshold)

and 1 hidden

Small changes (1201✅)

Too many entries to display here. View the full report on radar instead.

@hargoniX hargoniX added the changelog-compiler Compiler, runtime, and FFI label Mar 20, 2026
@github-actions github-actions bot added the changes-stage0 Contains stage0 changes, merge manually using rebase label Mar 20, 2026
@hargoniX
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Mar 21, 2026

Benchmark results for d34f8f2 against 4a62d4a are in. Significant changes detected! @hargoniX

  • build//instructions: -150.0G (-1.22%)

Large changes (9✅)

  • elab/big_do//instructions: -597.8M (-2.44%)
  • elab/grind_bitvec2//instructions: -3.3G (-1.66%)
  • elab/grind_list2//instructions: -1.0G (-1.87%)
  • elab/simp_local//instructions: -1.7G (-3.78%)
  • size/all/.c//lines: -238.0k (-2.12%)
  • size/all/.ir//bytes: -9MiB (-2.78%)
  • size/compile/.out//bytes: -183MiB (-9.52%)
  • size/install//bytes: -27MiB (-1.11%)
  • size/libleanshared.so//bytes: -8MiB (-5.46%)

Medium changes (29✅)

Too many entries to display here. View the full report on radar instead.

Small changes (1118✅, 6🟥)

Too many entries to display here. View the full report on radar instead.

fix it
fix more tests
@hargoniX
Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Mar 23, 2026

Benchmark results for dfe88e1 against 47427f8 are in. Significant changes detected! @hargoniX

  • build//instructions: -152.6G (-1.24%)

Large changes (9✅)

  • elab/big_do//instructions: -604.4M (-2.46%)
  • elab/grind_bitvec2//instructions: -3.3G (-1.65%)
  • elab/grind_list2//instructions: -1.0G (-1.86%)
  • elab/simp_local//instructions: -1.7G (-3.77%)
  • size/all/.c//lines: -239.3k (-2.12%)
  • size/all/.ir//bytes: -9MiB (-2.78%)
  • size/compile/.out//bytes: -184MiB (-9.53%)
  • size/install//bytes: -28MiB (-1.11%)
  • size/libleanshared.so//bytes: -8MiB (-5.45%)

Medium changes (29✅)

Too many entries to display here. View the full report on radar instead.

Small changes (1127✅, 4🟥)

Too many entries to display here. View the full report on radar instead.

@hargoniX hargoniX removed release-ci Enable all CI checks for a PR, like is done for releases fast-ci Forces the use of large runners so that e.g. PR releases are created faster labels Mar 23, 2026
@github-actions github-actions bot removed the changes-stage0 Contains stage0 changes, merge manually using rebase label Mar 23, 2026
@hargoniX hargoniX enabled auto-merge March 23, 2026 14:27
@hargoniX hargoniX added this pull request to the merge queue Mar 23, 2026
Merged via the queue into master with commit 33e63bb Mar 23, 2026
14 of 16 checks passed
@hargoniX hargoniX deleted the readert-update branch March 23, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-compiler Compiler, runtime, and FFI toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants