Skip to content

fix: mark irrelevant params as erased in mono type signatures - #9226

Closed
zwarich wants to merge 2 commits into
leanprover:masterfrom
zwarich:reduce-arity-erasure
Closed

zwarich wants to merge 2 commits into
leanprover:masterfrom
zwarich:reduce-arity-erasure

Conversation

@zwarich

@zwarich zwarich commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

This PR changes the reduceArity pass to rewrite the type signatures of the original decls to mark any irrelevant params as erased. In concert with #9224, this enables more functions to be considered computable.

@zwarich zwarich added the changelog-compiler Compiler, runtime, and FFI label Jul 7, 2025
@zwarich
zwarich requested a review from leodemoura as a code owner July 7, 2025 01:23
@zwarich

zwarich commented Jul 7, 2025

Copy link
Copy Markdown
Contributor Author

!bench

@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 Jul 7, 2025
@ghost

ghost commented Jul 7, 2025 •

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 9b7a14b156c6ddd0f6fcf827be4a5f4ad04789e7 --onto 5f818826d14a58b64d42fa8576003cd199adb50a. You can force Mathlib CI using the force-mathlib-ci label. (2025-07-07 01:45:43)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 6cf8828ce77026165212194b5d56cf3e44544452 --onto 5f818826d14a58b64d42fa8576003cd199adb50a. You can force Mathlib CI using the force-mathlib-ci label. (2025-07-07 05:20:14)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e2e36087e1ff1c29043ded4949862d5da7a8cf4a --onto 18a82c04fc59d3dba392308e09d65ee431240d89. You can force Mathlib CI using the force-mathlib-ci label. (2025-07-11 22:34:49)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 65abbd90bf076447c83c50e7873f01d083216ad4 --onto 18a82c04fc59d3dba392308e09d65ee431240d89. You can force Mathlib CI using the force-mathlib-ci label. (2025-07-17 06:10:05)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 5cd5885da4a46ba6f55da77e98c8f95c2af51470 --onto cdab726e3d289b80860ae9f5a7de21d990c8b95f. You can force Mathlib CI using the force-mathlib-ci label. (2025-07-18 22:00:04)

@leanprover-bot

leanprover-bot commented Jul 7, 2025 •

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 9b7a14b156c6ddd0f6fcf827be4a5f4ad04789e7 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-07-07 01:45:44)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 6cf8828ce77026165212194b5d56cf3e44544452 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-07-07 05:20:16)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase e2e36087e1ff1c29043ded4949862d5da7a8cf4a --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-07-11 22:34:50)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 65abbd90bf076447c83c50e7873f01d083216ad4 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-07-17 06:10:07)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 5cd5885da4a46ba6f55da77e98c8f95c2af51470 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-07-18 22:00:06)

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 6294a3c.
There were significant changes against commit 9b7a14b:

  Benchmark                              Metric                Change
  ==============================================================================
- Init.Data.BitVec.Lemmas                maxrss                 83.4%   (64.0 σ)
- Init.Data.BitVec.Lemmas re-elab        maxrss                 61.5%  (224.6 σ)
+ Init.Data.List.Sublist re-elab -j4     branches               -1.4%  (-74.5 σ)
+ Init.Data.List.Sublist re-elab -j4     instructions           -1.2%  (-65.5 σ)
- Init.Data.List.Sublist re-elab -j4     maxrss                190.4%  (338.0 σ)
- Std.Data.DHashMap.Internal.RawLemmas   maxrss                 98.6%   (95.0 σ)
- Std.Data.Internal.List.Associative     maxrss                 62.9%   (84.2 σ)
- big_omega.lean                         maxrss                 25.5%   (62.1 σ)
- big_omega.lean MT                      maxrss                 25.9%  (140.1 σ)
+ bv_decide_inequality.lean              branches               -1.1%  (-40.5 σ)
+ bv_decide_mul                          branches               -1.1%  (-64.2 σ)
+ bv_decide_mul                          instructions           -1.2%  (-51.8 σ)
+ bv_decide_realworld                    branches               -1.6% (-121.0 σ)
+ bv_decide_realworld                    instructions           -1.6% (-120.3 σ)
- channel.lean                           bounded0_spsc           6.2%   (30.2 σ)
+ libleanshared.so                       binary size            -1.0%
+ stdlib size                            max dynamic symbols    -1.3%

@zwarich
zwarich force-pushed the reduce-arity-erasure branch from 6294a3c to 2af9c01 Compare July 7, 2025 04:59
@zwarich

zwarich commented Jul 7, 2025

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 2af9c01.
There were significant changes against commit 6cf8828:

  Benchmark                              Metric                Change
  ================================================================================
- Init.Data.BitVec.Lemmas                maxrss                 85.0%     (71.7 σ)
- Init.Data.BitVec.Lemmas re-elab        maxrss                 61.9%   (1071.6 σ)
+ Init.Data.List.Sublist re-elab -j4     branches               -1.3%   (-138.8 σ)
+ Init.Data.List.Sublist re-elab -j4     instructions           -1.1%   (-109.8 σ)
- Init.Data.List.Sublist re-elab -j4     maxrss                190.4%    (561.3 σ)
+ Init.Data.List.Sublist re-elab -j4     task-clock             -5.5%    (-38.6 σ)
- Std.Data.DHashMap.Internal.RawLemmas   maxrss                 99.4%     (44.3 σ)
- Std.Data.Internal.List.Associative     maxrss                 60.3%    (138.1 σ)
- big_omega.lean                         maxrss                 25.9%    (541.1 σ)
- big_omega.lean MT                      maxrss                 25.1%    (121.1 σ)
+ bv_decide_inequality.lean              branches               -1.1%    (-35.5 σ)
+ bv_decide_mul                          branches               -1.1%    (-51.0 σ)
+ bv_decide_mul                          instructions           -1.2%    (-52.3 σ)
+ libleanshared.so                       binary size            -1.0%
+ riscv-ast.lean                         task-clock             -5.2% (-18363.6 σ)
+ riscv-ast.lean                         wall-clock             -5.0%    (-31.7 σ)
+ stdlib size                            max dynamic symbols    -1.3%

@zwarich

zwarich commented Jul 11, 2025

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 5093723.
There were significant changes against commit e2e3608:

  Benchmark                              Metric                Change
  ==============================================================================
+ Init.Data.BitVec.Lemmas                branch-misses          -2.4%  (-26.6 σ)
- Init.Data.BitVec.Lemmas                maxrss                 82.7%  (110.7 σ)
- Init.Data.BitVec.Lemmas re-elab        maxrss                 61.1% (1735.0 σ)
+ Init.Data.List.Sublist re-elab -j4     branch-misses          -2.9%  (-55.8 σ)
+ Init.Data.List.Sublist re-elab -j4     branches               -1.4%  (-46.5 σ)
+ Init.Data.List.Sublist re-elab -j4     instructions           -1.2%  (-38.5 σ)
- Init.Data.List.Sublist re-elab -j4     maxrss                189.3%  (721.0 σ)
- Std.Data.DHashMap.Internal.RawLemmas   maxrss                 99.0%   (31.6 σ)
- Std.Data.Internal.List.Associative     maxrss                 61.0%   (48.0 σ)
- big_omega.lean                         maxrss                 25.6%   (86.6 σ)
- big_omega.lean MT                      maxrss                 25.9%  (140.8 σ)
+ bv_decide_inequality.lean              branches               -1.1% (-283.4 σ)
+ bv_decide_inequality.lean              instructions           -1.0% (-290.8 σ)
+ bv_decide_mul                          branches               -1.0%  (-99.6 σ)
+ bv_decide_mul                          instructions           -1.1% (-111.3 σ)
- bv_decide_rewriter.lean                maxrss                 14.7%  (250.4 σ)
- hashmap.lean                           branch-misses           3.6%   (26.4 σ)
+ libleanshared.so                       binary size            -1.1%
+ stdlib size                            max dynamic symbols    -1.2%
+ tests/compiler                         sum binary sizes       -1.0%

@zwarich
zwarich force-pushed the reduce-arity-erasure branch from 5093723 to 3911d92 Compare July 17, 2025 05:19
@zwarich

zwarich commented Jul 17, 2025

Copy link
Copy Markdown
Contributor Author

!bench

@zwarich

zwarich commented Jul 17, 2025

Copy link
Copy Markdown
Contributor Author

The big memory usage regressions went away locally, so I’m curious what the bot says.

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 3911d92.
There were significant changes against commit 65abbd9:

  Benchmark                              Metric                    Change
  ==================================================================================
- Init.Data.BitVec.Lemmas                maxrss                     82.4%   (73.1 σ)
- Init.Data.BitVec.Lemmas re-elab        maxrss                     60.1%  (230.3 σ)
+ Init.Data.List.Sublist re-elab -j4     branches                   -1.3%  (-61.9 σ)
+ Init.Data.List.Sublist re-elab -j4     instructions               -1.1%  (-56.1 σ)
- Init.Data.List.Sublist re-elab -j4     maxrss                    189.9%  (724.8 σ)
- Init.Prelude async                     maxrss                     16.3%   (22.0 σ)
- Std.Data.DHashMap.Internal.RawLemmas   maxrss                     98.7%   (24.9 σ)
- Std.Data.Internal.List.Associative     maxrss                     59.5%  (120.5 σ)
- big_omega.lean                         maxrss                     25.8%  (110.3 σ)
- big_omega.lean MT                      maxrss                     25.6%  (104.5 σ)
+ bv_decide_inequality.lean              branches                   -1.1% (-185.2 σ)
- bv_decide_inequality.lean              maxrss                      4.0%   (23.4 σ)
+ bv_decide_inequality.lean              wall-clock                 -4.8%  (-83.0 σ)
+ bv_decide_mul                          branches                   -1.0%  (-60.6 σ)
+ bv_decide_mul                          instructions               -1.1%  (-65.0 σ)
+ bv_decide_realworld                    branches                   -1.6%  (-39.7 σ)
+ bv_decide_realworld                    instructions               -1.6%  (-39.2 σ)
- bv_decide_rewriter.lean                maxrss                     14.6%   (57.5 σ)
- hashmap.lean                           branch-misses               4.1%   (42.0 σ)
+ lake build clean                       maxrss                     -1.2%  (-21.0 σ)
+ libleanshared.so                       binary size                -1.0%
- simp_local                             maxrss                     11.3%   (41.1 σ)
+ stdlib                                 grind dsimp               -21.8%  (-78.9 σ)
- stdlib                                 grind mark subsingleton     2.1%   (22.9 σ)
+ stdlib size                            max dynamic symbols        -1.2%
- tests/bench/ interpreted               task-clock                  2.5%  (646.6 σ)
+ treemap.lean                           iterate                    -4.3%

@zwarich
zwarich force-pushed the reduce-arity-erasure branch from 3911d92 to 5b76f1e Compare July 18, 2025 21:19
@zwarich

zwarich commented Jul 18, 2025

Copy link
Copy Markdown
Contributor Author

!bench

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Here are the benchmark results for commit 5b76f1e.
There were significant changes against commit 5cd5885:

  Benchmark          Metric                Change
  =========================================================
- hashmap.lean       branch-misses           3.6%  (57.6 σ)
- iterators          branches                1.2% (450.0 σ)
- iterators          instructions            1.2% (485.8 σ)
- libleanshared.so   binary size             1.8%
- stdlib size        bytes .ir               2.2%
- stdlib size        max dynamic symbols     3.2%
- tests/compiler     sum binary sizes        3.3%

@zwarich

zwarich commented Jul 18, 2025

Copy link
Copy Markdown
Contributor Author

Well, at least the maxrss regression goes away after #9433.

@zwarich zwarich closed this Aug 6, 2025
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.

2 participants