tonsky / datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
Eclipse Public License 1.0
5.49k stars 309 forks source link

Performance1 #436

Closed bsless closed 2 years ago

bsless commented 2 years ago

There are lots of commits in this MR which break the changes apart, but comparing the benchmarks before and after:

Java 8

add-1                 373.2 -> 235.6 ms/op   
add-5                 596.3 -> 470.9 ms/op   
add-all               589.3 -> 477.9 ms/op   
freeze                552.6 -> 548.4 ms/op   
init                   19.8 ->  18.1 ms/op   
pull-many               1.2 ->   1.1 ms/op   
pull-many-entities      3.2 ->   2.9 ms/op   
pull-one              0.644 -> 0.568 ms/op   
pull-one-entities       1.1 -> 0.977 ms/op   
pull-wildcard           1.5 ->   1.4 ms/op   
q1                      1.4 -> 0.692 ms/op   
q2                      3.4 ->   2.2 ms/op   
q3                      4.9 ->   3.2 ms/op   
q4                      7.7 ->   4.6 ms/op   
qpred1                  4.7 ->   4.4 ms/op   
qpred2                 14.8 ->  10.0 ms/op   
retract-5             474.3 -> 394.6 ms/op   

Java 17

add-1                 363.1 -> 232.0 ms/op   
add-5                 577.9 -> 450.0 ms/op   
add-all               561.0 -> 454.9 ms/op   
freeze                577.5 -> 562.9 ms/op   
init                   21.1 ->  20.1 ms/op   
pull-many               1.2 ->   1.2 ms/op   
pull-many-entities      2.9 ->   2.7 ms/op   
pull-one              0.628 -> 0.615 ms/op   
pull-one-entities       1.0 -> 0.892 ms/op   
pull-wildcard           1.4 ->   1.4 ms/op   
q1                      1.3 -> 0.753 ms/op   
q2                      3.2 ->   2.4 ms/op   
q3                      4.6 ->   3.3 ms/op   
q4                      7.4 ->   4.8 ms/op   
qpred1                  5.3 ->   4.6 ms/op   
qpred2                 15.4 ->   9.6 ms/op   
retract-5             459.2 -> 384.1 ms/op   
tonsky commented 2 years ago

Thanks! Merged and released as 1.3.15.

My results (Apple M1 Pro, Azul JVM 18):

Screenshot 2022-08-24 at 21 14 52

JVM only, CLJS is more or less the same