Gödel Hashing matt.might.net @mattmight
Disclaimer
“simple, fun idea”
“simple, fun idea” “works well in practice,”
“simple, fun idea” “works well in practice,” “but theory says it will not.”
An old problem An older solution A big impact
An old problem
“CFA is slow!”
An older solution
Gödel hashing functional monotonic compact dynamic incremental perfect Inspired by a true theorem.
Word-level parallelism!
Great cache behavior!
A big impact
Minutes of work
2x
2x 5x
2x 5x 8x
2x 5x 8x 100x
Motivation
(f x)
f(x)
What is ? f
Wh y not run the program?
e
e
e
e What is f , here ?
e What is f , here ?
e ...
e AAM ...
e ...
e
e
Problem
� � � � � � � � � � � � � � � � � � � � � � � � � � � � ˆ � � ς 1 � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
v
v
ˆ ˆ ς 2 ς 1 v
ς 1 = ( e, ˆ ρ , ˆ σ , ˆ κ ) ˆ ˆ σ
expression store = ( e, ˆ ρ , ˆ σ , ˆ κ ) ˆ ˆ σ ς 1 environment stack
expression store = ( e, ˆ ρ , ˆ σ , ˆ κ ) ˆ ˆ σ ς 1 environment stack
σ : [ Addr → P ( \ [ ( \ ˆ Value ) Addr Value )
( \ Value ) Addr [
[ ( \ Addr Value )
First: Hash sets
Prime decomposition
Primes p 1 p 3 p 2 p 4
Primes p 1 p 3 p 2 p 4
p 3 p 4
p 3 p 4
p 3 p 4 ×
} { ,
} { ,
⊆ A B
[ [ ] ] [ [ ] ] = 0 mod A B
A B ∩
( [ [ ] ] [ [ ] ] ) gcd A B ,
lcm ( [ [ ] ] [ [ ] ] ) A B ,
A B ∪
A A B ∪
A A B −
[ [ A / ] ] ( [ [ ] ] [ [ ] ] ) gcd A B ,
⊆
> ⊥
> prime basis ⊥
m 1 m 2 m 3 . . . n = p 1 p 2 p 3
G } { n = , ,
⊥
⊥
⊥
⊥
⊥
⊥
⊥
p 1 p 3 p 4
p 1 p 3 p 4
t y x
lcm ( [ [ ] ] [ [ ] ] ) y x ,
v y x
[ [ ] ] [ [ ] ] = 0 mod x y
u x y
Recommend
More recommend