Skip to content

Commit 8b7ed67

Browse files
authored
3863 llvm term cache (#3882)
This PR introduces a cache for the terms returned from calls to `Booster.LLVM.Internal.API.simplify`. Unpacking now uses a term store for the unpacked terms, and recognises shared terms by a shallow index into this store, using `TermF Int` as the map key (where the `Int` are indexes of symbol application/injection arguments in the term store). In small targeted tests using requests from MX-backend proofs , memory consumption was noticeably reduced, also resulting in better performance. Currently, the cache only lives for the duration of one LLVM call (not across different calls), no global variables or unsafe IO is required. Fixes #3863
1 parent 0f31483 commit 8b7ed67

File tree

3 files changed

+216
-94
lines changed

3 files changed

+216
-94
lines changed

booster/library/Booster/LLVM/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import System.Posix.DynamicLinker qualified as Linker
5151

5252
import Booster.LLVM.TH (dynamicBindings)
5353
import Booster.Pattern.Base
54-
import Booster.Pattern.Binary hiding (Block)
54+
import Booster.Pattern.Binary
5555
import Booster.Pattern.Util (sortOfTerm)
5656
import Booster.Trace
5757
import Booster.Trace qualified as Trace

booster/library/Booster/Pattern/ApplyEquations.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,9 @@ llvmSimplify term = do
501501
withTermContext result $
502502
emitEquationTrace t Nothing (Just "LLVM") Nothing $
503503
Success result
504-
toCache LLVM t result
505504
pure result
506-
| otherwise = do
507-
result <- cb t
508-
toCache LLVM t result
509-
pure result
505+
| otherwise =
506+
cb t
510507

511508
----------------------------------------
512509
-- Interface functions

0 commit comments

Comments
 (0)