Skip to content

[Merged by Bors] - perf: fast_instance% in Mathlib.Order.Basic#39795

Closed
kbuzzard wants to merge 1 commit into
leanprover-community:masterfrom
kbuzzard:kbuzzard-order-basic
Closed

[Merged by Bors] - perf: fast_instance% in Mathlib.Order.Basic#39795
kbuzzard wants to merge 1 commit into
leanprover-community:masterfrom
kbuzzard:kbuzzard-order-basic

Conversation

@kbuzzard

@kbuzzard kbuzzard commented May 24, 2026

Copy link
Copy Markdown
Member

This PR adds some fast_instance% to tidy up some instance terms. We get a speedup in Mathlib.Topology.Algebra.Valued.WithVal.


Open in Gitpod

The genesis of this PR is #39780 (scattergun fast_instance%) which when benchmarked here #39780 (comment) didn't do much in general, but did save over 10% off
Mathlib.Topology.Algebra.Valued.WithVal. This PR reverse-engineers which change caused that speedup, and makes only that change. The change looks sensible to me.

@kbuzzard

Copy link
Copy Markdown
Member Author

!radar

@leanprover-radar

leanprover-radar commented May 24, 2026

Copy link
Copy Markdown

Benchmark results for 48f2583 against 383a355 are in. No significant results found. @kbuzzard

  • build//instructions: -19.5G (-0.01%)

Medium changes (1✅)

  • build/module/Mathlib.Topology.Algebra.Valued.WithVal//instructions: -11.6G (-12.48%)

@github-actions github-actions Bot added the t-order Order theory label May 24, 2026
@github-actions

Copy link
Copy Markdown

PR summary 48f25832fa

Import changes for modified files

Dependency changes

File Base Count Head Count Change
Mathlib.Order.Basic 114 115 +1 (+0.88%)
Import changes for all files
Files Import difference
254 files Mathlib.Algebra.BigOperators.Group.List.Basic Mathlib.Algebra.BigOperators.Group.List.Lemmas Mathlib.Algebra.EuclideanDomain.Defs Mathlib.Algebra.EuclideanDomain.Field Mathlib.Algebra.EuclideanDomain.Int Mathlib.Algebra.FreeMonoid.FreeSemigroup Mathlib.Algebra.Group.Action.End Mathlib.Algebra.Group.Center Mathlib.Algebra.Group.Conj Mathlib.Algebra.Group.End Mathlib.Algebra.GroupWithZero.Action.Basic Mathlib.Algebra.GroupWithZero.Associated Mathlib.Algebra.GroupWithZero.Center Mathlib.Algebra.GroupWithZero.Conj Mathlib.Algebra.Order.AddGroupWithTop Mathlib.Algebra.Order.AddTorsor Mathlib.Algebra.Order.BigOperators.Group.List Mathlib.Algebra.Order.Group.Abs Mathlib.Algebra.Order.Group.Action.End Mathlib.Algebra.Order.Group.Action.Synonym Mathlib.Algebra.Order.Group.Basic Mathlib.Algebra.Order.Group.Defs Mathlib.Algebra.Order.Group.DenselyOrdered Mathlib.Algebra.Order.Group.End Mathlib.Algebra.Order.Group.Equiv Mathlib.Algebra.Order.Group.Int Mathlib.Algebra.Order.Group.Lattice Mathlib.Algebra.Order.Group.MinMax Mathlib.Algebra.Order.Group.Nat Mathlib.Algebra.Order.Group.Opposite Mathlib.Algebra.Order.Group.OrderIso Mathlib.Algebra.Order.Group.PosPart Mathlib.Algebra.Order.Group.Synonym Mathlib.Algebra.Order.Group.Unbundled.Abs Mathlib.Algebra.Order.Group.Unbundled.Basic Mathlib.Algebra.Order.Group.Unbundled.Int Mathlib.Algebra.Order.Group.Units Mathlib.Algebra.Order.GroupWithZero.Action.Synonym Mathlib.Algebra.Order.GroupWithZero.Synonym Mathlib.Algebra.Order.GroupWithZero.Unbundled.Defs Mathlib.Algebra.Order.Hom.Basic Mathlib.Algebra.Order.Hom.Monoid Mathlib.Algebra.Order.Hom.TypeTags Mathlib.Algebra.Order.Hom.Units Mathlib.Algebra.Order.IsBotOne Mathlib.Algebra.Order.Module.Synonym Mathlib.Algebra.Order.Monoid.Associated Mathlib.Algebra.Order.Monoid.Basic Mathlib.Algebra.Order.Monoid.Canonical.Defs Mathlib.Algebra.Order.Monoid.Defs Mathlib.Algebra.Order.Monoid.NatCast Mathlib.Algebra.Order.Monoid.OrderDual Mathlib.Algebra.Order.Monoid.TypeTags Mathlib.Algebra.Order.Monoid.Unbundled.Basic Mathlib.Algebra.Order.Monoid.Unbundled.Defs Mathlib.Algebra.Order.Monoid.Unbundled.ExistsOfLE Mathlib.Algebra.Order.Monoid.Unbundled.MinMax Mathlib.Algebra.Order.Monoid.Unbundled.OrderDual Mathlib.Algebra.Order.Monoid.Unbundled.Pow Mathlib.Algebra.Order.Monoid.Unbundled.TypeTags Mathlib.Algebra.Order.Monoid.Unbundled.Units Mathlib.Algebra.Order.Monoid.Unbundled.WithTop Mathlib.Algebra.Order.Monoid.Units Mathlib.Algebra.Order.Monoid.WithTop Mathlib.Algebra.Order.PUnit Mathlib.Algebra.Order.Ring.Idempotent Mathlib.Algebra.Order.Ring.Synonym Mathlib.Algebra.Order.Ring.Unbundled.Rat Mathlib.Algebra.Order.Sub.Basic Mathlib.Algebra.Order.Sub.Defs Mathlib.Algebra.Order.Sub.Prod Mathlib.Algebra.Order.Sub.Unbundled.Basic Mathlib.Algebra.Order.Sub.WithTop Mathlib.Algebra.Order.Sum Mathlib.Algebra.Order.ZeroLEOne Mathlib.Algebra.Prime.Lemmas Mathlib.Algebra.Ring.Centralizer Mathlib.Algebra.Tropical.Basic Mathlib.AlgebraicTopology.DoldKan.Compatibility Mathlib.CategoryTheory.Bicategory.End Mathlib.CategoryTheory.Bicategory.EqToHom Mathlib.CategoryTheory.Bicategory.Functor.Prelax Mathlib.CategoryTheory.Bicategory.LocallyDiscrete Mathlib.CategoryTheory.Bicategory.Opposites Mathlib.CategoryTheory.Bicategory.Strict.Basic Mathlib.CategoryTheory.CatCommSq Mathlib.CategoryTheory.Category.Preorder Mathlib.CategoryTheory.Category.ULift Mathlib.CategoryTheory.CommSq Mathlib.CategoryTheory.Comma.Arrow Mathlib.CategoryTheory.Comma.Basic Mathlib.CategoryTheory.Comma.CatCommSq Mathlib.CategoryTheory.ConcreteCategory.Basic Mathlib.CategoryTheory.DinatTrans Mathlib.CategoryTheory.Discrete.Basic Mathlib.CategoryTheory.Discrete.SumsProducts Mathlib.CategoryTheory.Elementwise Mathlib.CategoryTheory.EqToHom Mathlib.CategoryTheory.Equivalence Mathlib.CategoryTheory.EssentialImage Mathlib.CategoryTheory.FiberedCategory.BasedCategory Mathlib.CategoryTheory.FiberedCategory.Cartesian Mathlib.CategoryTheory.FiberedCategory.Cocartesian Mathlib.CategoryTheory.FiberedCategory.Fiber Mathlib.CategoryTheory.FiberedCategory.Fibered Mathlib.CategoryTheory.FiberedCategory.HasFibers Mathlib.CategoryTheory.FiberedCategory.HomLift Mathlib.CategoryTheory.Functor.Const Mathlib.CategoryTheory.Functor.CurryingThree Mathlib.CategoryTheory.Functor.Currying Mathlib.CategoryTheory.Functor.OfSequence Mathlib.CategoryTheory.Functor.TwoSquare Mathlib.CategoryTheory.Join.Basic Mathlib.CategoryTheory.Join.Opposites Mathlib.CategoryTheory.Join.Sum Mathlib.CategoryTheory.Limits.Shapes.Pullback.Categorical.Basic Mathlib.CategoryTheory.Limits.Shapes.Pullback.Categorical.CatCospanTransform Mathlib.CategoryTheory.Monoidal.Action.Basic Mathlib.CategoryTheory.Monoidal.Action.LinearFunctor Mathlib.CategoryTheory.Monoidal.Category Mathlib.CategoryTheory.Monoidal.CoherenceLemmas Mathlib.CategoryTheory.ObjectProperty.Basic Mathlib.CategoryTheory.ObjectProperty.ClosedUnderIsomorphisms Mathlib.CategoryTheory.ObjectProperty.Equivalence Mathlib.CategoryTheory.ObjectProperty.FullSubcategory Mathlib.CategoryTheory.Opposites Mathlib.CategoryTheory.PEmpty Mathlib.CategoryTheory.PUnit Mathlib.CategoryTheory.Pi.Basic Mathlib.CategoryTheory.Products.Associator Mathlib.CategoryTheory.Products.Basic Mathlib.CategoryTheory.Products.Bifunctor Mathlib.CategoryTheory.Products.Unitor Mathlib.CategoryTheory.Square Mathlib.CategoryTheory.Sums.Associator Mathlib.CategoryTheory.Sums.Basic Mathlib.CategoryTheory.Sums.Products Mathlib.Combinatorics.Quiver.Path.Decomposition Mathlib.Combinatorics.Quiver.Path.Vertices Mathlib.Computability.Tape Mathlib.Computability.TuringMachine.Tape Mathlib.Control.Fix Mathlib.Data.Bool.Set Mathlib.Data.Bundle Mathlib.Data.Fin.Basic Mathlib.Data.FunLike.Graded Mathlib.Data.Int.GCD Mathlib.Data.Int.LeastGreatest Mathlib.Data.Int.Range Mathlib.Data.List.Chain Mathlib.Data.List.Destutter Mathlib.Data.List.DropRight Mathlib.Data.List.Infix Mathlib.Data.List.Intervals Mathlib.Data.List.Iterate Mathlib.Data.List.Lex Mathlib.Data.List.MinMax Mathlib.Data.List.Permutation Mathlib.Data.List.Prime Mathlib.Data.List.Range Mathlib.Data.List.Rotate Mathlib.Data.List.SplitBy Mathlib.Data.List.SplitLengths Mathlib.Data.List.Sublists Mathlib.Data.List.TakeWhile Mathlib.Data.Multiset.AddSub Mathlib.Data.Multiset.Basic Mathlib.Data.Multiset.Count Mathlib.Data.Multiset.Defs Mathlib.Data.Multiset.Pairwise Mathlib.Data.Multiset.Replicate Mathlib.Data.Multiset.ZeroCons Mathlib.Data.Nat.Cast.Synonym Mathlib.Data.Nat.Cast.WithTop Mathlib.Data.Nat.Choose.Basic Mathlib.Data.Nat.GCD.Prime Mathlib.Data.Nat.Log Mathlib.Data.Nat.Order.Lemmas Mathlib.Data.Nat.Prime.Defs Mathlib.Data.Nat.Upto Mathlib.Data.Nat.WithBot Mathlib.Data.Ordmap.Ordnode Mathlib.Data.PEquiv Mathlib.Data.PNat.Defs Mathlib.Data.PNat.Equiv Mathlib.Data.PSigma.Order Mathlib.Data.Part Mathlib.Data.Rat.Defs Mathlib.Data.Set.Basic Mathlib.Data.Set.Disjoint Mathlib.Data.Set.Enumerate Mathlib.Data.Set.Inclusion Mathlib.Data.Set.Insert Mathlib.Data.Set.Order Mathlib.Data.Set.Subsingleton Mathlib.Data.SetLike.Basic Mathlib.Data.Sigma.Order Mathlib.Data.String.Basic Mathlib.Data.Sum.Lattice Mathlib.Data.Sum.Order Mathlib.InformationTheory.Coding.UniquelyDecodable Mathlib.Logic.Function.FiberPartition Mathlib.Order.Antisymmetrization Mathlib.Order.Basic Mathlib.Order.BooleanAlgebra.Basic Mathlib.Order.BooleanAlgebra.Defs Mathlib.Order.Booleanisation Mathlib.Order.BoundedOrder.Basic Mathlib.Order.BoundedOrder.Lattice Mathlib.Order.BoundedOrder.Monotone Mathlib.Order.Circular Mathlib.Order.Comparable Mathlib.Order.Compare Mathlib.Order.Disjoint Mathlib.Order.GaloisConnection.Defs Mathlib.Order.Heyting.Basic Mathlib.Order.Heyting.Boundary Mathlib.Order.Heyting.Hom Mathlib.Order.Hom.Basic Mathlib.Order.Hom.BoundedLattice Mathlib.Order.Hom.Bounded Mathlib.Order.Hom.Lattice Mathlib.Order.Hom.WithTopBot Mathlib.Order.Iterate Mathlib.Order.Lattice Mathlib.Order.Lex Mathlib.Order.Max Mathlib.Order.MinMax Mathlib.Order.Monotone.Basic Mathlib.Order.Monotone.Defs Mathlib.Order.Monotone.Monovary Mathlib.Order.Nat Mathlib.Order.OrderDual Mathlib.Order.Part Mathlib.Order.PropInstances Mathlib.Order.RelClasses Mathlib.Order.RelIso.Basic Mathlib.Order.SetIsMax Mathlib.Order.SymmDiff Mathlib.Order.Synonym Mathlib.Order.Types.Defs Mathlib.Order.ULift Mathlib.Order.WithBotTop Mathlib.Order.WithBot Mathlib.SetTheory.Lists Mathlib.Tactic.ApplyFun Mathlib.Tactic.CategoryTheory.Elementwise Mathlib.Tactic.CategoryTheory.Monoidal.Basic Mathlib.Tactic.CategoryTheory.Monoidal.Datatypes Mathlib.Tactic.CategoryTheory.Monoidal.Normalize Mathlib.Tactic.CategoryTheory.Monoidal.PureCoherence Mathlib.Tactic.CategoryTheory.MonoidalComp Mathlib.Tactic.Widget.StringDiagram Mathlib.Tactic.Zify
1

Declarations diff

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.


No changes to strong technical debt.
No changes to weak technical debt.

@riccardobrasca

Copy link
Copy Markdown
Member

Thanks!

bors merge

@mathlib-triage mathlib-triage Bot added the ready-to-merge This PR has been sent to bors. label May 25, 2026
mathlib-bors Bot pushed a commit that referenced this pull request May 25, 2026
This PR adds some `fast_instance%` to tidy up some instance terms. We get a speedup in `Mathlib.Topology.Algebra.Valued.WithVal`.
@mathlib-bors

mathlib-bors Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title perf: fast_instance% in Mathlib.Order.Basic [Merged by Bors] - perf: fast_instance% in Mathlib.Order.Basic May 25, 2026
@mathlib-bors mathlib-bors Bot closed this May 25, 2026
riccardobrasca added a commit to riccardobrasca/mathlib4 that referenced this pull request May 27, 2026
This PR adds some `fast_instance%` to tidy up some instance terms. We get a speedup in `Mathlib.Topology.Algebra.Valued.WithVal`.

---
<!-- Your PR title will become the first line of the commit message.

In this box, the text above the `---` (if not empty) will be appended
to the commit message, and can be used to give additional context or
details. Please leave a blank newline before the `---`, otherwise GitHub
will format the text above it as a title.

For details on the "pull request lifecycle" in mathlib, please see:
https://leanprover-community.github.io/contribute/index.html

In particular, note that most reviewers will only notice your PR
if it passes the continuous integration checks.
Please ask for help on https://leanprover.zulipchat.com if needed.

When merging, all the commits will be squashed into a single commit
listing all co-authors.

Co-authors in the squash commit are gathered from two sources:

First, all authors of commits to this PR branch are included. Thus,
one way to add co-authors is to include at least one commit authored by
each co-author among the commits in the pull request. If necessary, you
may create empty commits to indicate co-authorship, using commands like so:

git commit --author="Author Name <author@email.com>" --allow-empty -m "add Author Name as coauthor"

Second, co-authors can also be listed in lines at the very bottom of
the commit message (that is, directly before the `---`) using the following format:

Co-authored-by: Author Name <author@email.com>

If you are moving or deleting declarations, please include these lines
at the bottom of the commit message (before the `---`, and also before
any "Co-authored-by" lines) using the following format:

Moves:
- Vector.* -> List.Vector.*
- ...

Deletions:
- Nat.bit1_add_bit1
- ...

Any other comments you want to keep out of the PR commit should go
below the `---`, and placed outside this HTML comment, or else they
will be invisible to reviewers.

If this PR depends on other PRs, please list them below this comment,
using the following format:
- [ ] depends on: #abc [optional extra text]
- [ ] depends on: #xyz [optional extra text]

-->

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/from-referrer/)
b-mehta pushed a commit to b-mehta/mathlib4 that referenced this pull request Jun 2, 2026
This PR adds some `fast_instance%` to tidy up some instance terms. We get a speedup in `Mathlib.Topology.Algebra.Valued.WithVal`.
Bergschaf pushed a commit to Bergschaf/mathlib4 that referenced this pull request Jun 3, 2026
This PR adds some `fast_instance%` to tidy up some instance terms. We get a speedup in `Mathlib.Topology.Algebra.Valued.WithVal`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-order Order theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants