perf: add ShareCommon.shareCommon'
#4767
Merged
+211
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, theoremsha512_block_armv8_test_4_sym
took a few seconds ataddPreDefinitions
and one second atfixLevelParams
on a MacBook Pro (with M1 Pro). The proof term initially had over 16 million subterms, but the redundancy was indirectly and inefficiently eliminated usingCore.transform
ataddPreDefinitions
. I tried to useshareCommon
method to fix the performance issue, but it was too inefficient. This PR introduces a newshareCommon'
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 oldshareCommon
procedure for theoremsha512_block_armv8_test_4_sym
.