perf: pick cache size coprime to pointer alignment

This commit is contained in:
Gabriel Ebner 2022-11-16 10:24:46 -08:00 committed by Leonardo de Moura
parent c8859a31d9
commit bbe5cf63b2
4 changed files with 5 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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 :=

View file

@ -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