Skip to content

[Merged by Bors] - perf(Translate): use cache in guessReorder#41516

Closed
JovanGerb wants to merge 1 commit into
leanprover-community:masterfrom
JovanGerb:Jovan-translate-guessReorder-perf
Closed

[Merged by Bors] - perf(Translate): use cache in guessReorder#41516
JovanGerb wants to merge 1 commit into
leanprover-community:masterfrom
JovanGerb:Jovan-translate-guessReorder-perf

Conversation

@JovanGerb

Copy link
Copy Markdown
Contributor

This PR fixes a performance issue in to_additive/to_dual. The guessReorder function did not use a cache, meaning that it would visit the same expressions multiple times unnecessarily.


Open in Gitpod

@github-actions github-actions Bot added the t-meta Tactics, attributes or user commands label Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

PR summary 97dd87c9f5

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

Lean-aware diff — post-build, computed from the Lean environment (commit 97dd87c).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit 97dd87c9f5
Reference commit 463839dbb4

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@JovanGerb

Copy link
Copy Markdown
Contributor Author

!radar

@leanprover-radar

leanprover-radar commented Jul 8, 2026

Copy link
Copy Markdown

Benchmark results for 97dd87c against 463839d are in. There are significant results. @JovanGerb

  • build//instructions: -109.4G (-0.07%)

Large changes (1✅)

  • build/module/Mathlib.GroupTheory.GroupAction.SubMulAction.OfFixingSubgroup//instructions: -31.6G (-35.55%)

Small changes (1✅, 3🟥)

  • 🟥 build/module/Mathlib.Algebra.Group.InjSurj//instructions: +376.4M (+2.50%)
  • build/module/Mathlib.GroupTheory.QuotientGroup.Basic//instructions: -746.0M (-2.29%)
  • 🟥 build/module/Mathlib.Tactic.Translate.Core//instructions: +2.2G (+5.94%)
  • 🟥 build/module/Mathlib.Tactic.Translate.Reorder//instructions: +603.0M (+5.01%)

@bryangingechen

Copy link
Copy Markdown
Contributor

Thanks!
bors r+

@mathlib-bors mathlib-bors Bot added the ready-to-merge This PR has been sent to bors. label Jul 8, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Jul 8, 2026
This PR fixes a performance issue in `to_additive`/`to_dual`. The `guessReorder` function did not use a cache, meaning that it would visit the same expressions multiple times unnecessarily.
@mathlib-bors mathlib-bors Bot added the bors-staging This PR is currently being built by bors on the staging branch. label Jul 8, 2026
@mathlib-bors

mathlib-bors Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@mathlib-bors mathlib-bors Bot changed the title perf(Translate): use cache in guessReorder [Merged by Bors] - perf(Translate): use cache in guessReorder Jul 9, 2026
@mathlib-bors mathlib-bors Bot closed this Jul 9, 2026

@plp127 plp127 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, looks like I forgot to hit "submit comments" on github! Well I guess it's a little late now since the PR's merged already, I'll still post this here.

Comment thread Mathlib/Tactic/Translate/Core.lean
michaellee94 pushed a commit to michaellee94/mathlib4 that referenced this pull request Jul 11, 2026
)

This PR fixes a performance issue in `to_additive`/`to_dual`. The `guessReorder` function did not use a cache, meaning that it would visit the same expressions multiple times unnecessarily.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bors-staging This PR is currently being built by bors on the staging branch. ready-to-merge This PR has been sent to bors. t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants