perf: pick cache size coprime to pointer alignment
This commit is contained in:
parent
c8859a31d9
commit
bbe5cf63b2
4 changed files with 5 additions and 5 deletions
|
|
@ -10,7 +10,7 @@ namespace Expr
|
|||
|
||||
namespace FindImpl
|
||||
|
||||
abbrev cacheSize : USize := 8192
|
||||
abbrev cacheSize : USize := 8192 - 1
|
||||
|
||||
structure State where
|
||||
keys : Array Expr -- Remark: our "unsafe" implementation relies on the fact that `()` is not a valid Expr
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Lean
|
|||
namespace Expr
|
||||
namespace FoldConstsImpl
|
||||
|
||||
abbrev cacheSize : USize := 8192
|
||||
abbrev cacheSize : USize := 8192 - 1
|
||||
|
||||
structure State where
|
||||
visitedTerms : Array Expr -- Remark: cache based on pointer address. Our "unsafe" implementation relies on the fact that `()` is not a valid Expr
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace Expr
|
|||
|
||||
namespace ReplaceImpl
|
||||
|
||||
@[inline] def cacheSize : USize := 8192
|
||||
@[inline] def cacheSize : USize := 8192 - 1
|
||||
|
||||
structure Cache where
|
||||
-- First cacheSize elements are the keys.
|
||||
|
|
@ -23,7 +23,7 @@ unsafe def Cache.new : Cache :=
|
|||
|
||||
@[inline]
|
||||
unsafe def Cache.keyIdx (key : Expr) : USize :=
|
||||
(ptrAddrUnsafe key >>> 4) % cacheSize
|
||||
ptrAddrUnsafe key % cacheSize
|
||||
|
||||
@[inline]
|
||||
unsafe def Cache.resultIdx (key : Expr) : USize :=
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Expr
|
|||
|
||||
namespace ReplaceLevelImpl
|
||||
|
||||
abbrev cacheSize : USize := 8192
|
||||
abbrev cacheSize : USize := 8192 - 1
|
||||
|
||||
structure State where
|
||||
keys : Array Expr -- Remark: our "unsafe" implementation relies on the fact that `()` is not a valid Expr
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue