Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: add ShareCommon.shareCommon' #4767

Merged
merged 2 commits into from
Jul 17, 2024
Merged

perf: add ShareCommon.shareCommon' #4767

merged 2 commits into from
Jul 17, 2024

Conversation

leodemoura
Copy link
Member

A more restrictive but efficient max sharing primitive.

Motivation: Some software verification proofs may contain significant redundancy that can be eliminated using hash-consing (also known as shareCommon). For example, theorem sha512_block_armv8_test_4_sym took a few seconds at addPreDefinitions and one second at fixLevelParams on a MacBook Pro (with M1 Pro). The proof term initially had over 16 million subterms, but the redundancy was indirectly and inefficiently eliminated using Core.transform at addPreDefinitions. I tried to use shareCommon method to fix the performance issue, but it was too inefficient. This PR introduces a new shareCommon' method that, although less flexible (e.g., it uses only a local cache and hash-consing table), is much more efficient. The new procedure minimizes the number of RC operations and optimizes the caching strategy. It is 20 times faster than the old shareCommon procedure for theorem sha512_block_armv8_test_4_sym.

A more efficient (but less flexible) `shareCommon` API.
@leodemoura
Copy link
Member Author

!bench

@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc July 17, 2024 00:11 Inactive
@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 17, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase b73fe04710437daf1140cc8d06bef3e0f503fd33 --onto 7aec6c9ae7a54935ada0df0b4cc1efafc2291007. (2024-07-17 00:17:50)

@leanprover-bot
Copy link
Collaborator

Here are the benchmark results for commit 8558fd6.
There were significant changes against commit b73fe04:

  Benchmark                  Metric                Change
  ==================================================================
+ stdlib                     add pre-definitions    -4.4%  (-38.6 σ)
+ stdlib                     dsimp                 -11.1% (-665.6 σ)
+ stdlib                     fix level params      -14.4% (-127.0 σ)
- tests/bench/ interpreted   instructions            1.1% (1268.3 σ)

@leodemoura leodemoura added this pull request to the merge queue Jul 17, 2024
Merged via the queue into master with commit c580684 Jul 17, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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