ssbc / ssb-db2

A new database for secure-scuttlebutt
47 stars 8 forks source link

update our usage of Obz to be safer #337

Closed staltz closed 2 years ago

staltz commented 2 years ago

This PR does 3 refactors.

I started by updating Obz to 1.1.0 to use the new return false style, but I noticed that actually our util onceWhen is safer (because if we were to use return false we have to run that as the last command, but in fact we need to unsubscribe from the Obz as soon as possible). So there are more things that use onceWhen now.

The other refactors are simple:

github-actions[bot] commented 2 years ago

Benchmark results

Part Duration
add 1000 elements 485ms
add 1000 private box1 elements 1340ms
unbox 1000 private box1 elements first run 139ms
unbox 1000 private box1 elements second run 101ms
add 1000 private box1 elements 1233ms
query 1000 elements first run 32ms
query 1000 elements second run 14ms
add 1000 private box2 elements 710ms
unbox 1000 private box2 elements first run 388ms
unbox 1000 private box2 elements second run 392ms
Migrate (+db1) 13925ms
Migrate (alone) 4985ms
Migrate (+db1 +db2) 10520ms
Migrate (+db2) 7464ms
Migrate continuation (+db2) 1085ms
Memory usage without indexes 721.15 MB = 30.27 MB + etc
Initial indexing 764ms
Initial indexing maxCpu=86 4271ms
Initial indexing compat 867ms
Two indexes updating concurrently 871ms
key one initial 52ms
key two 1ms
key one again 2ms
reboot and key one again 45ms
latest root posts 689ms
latest posts 10ms
votes one initial 527ms
votes again 0ms
hasRoot 403ms
hasRoot again 0ms
author one posts 355ms
author two posts 19ms
dedicated author one posts 404ms
dedicated author one posts again 0ms
Maximum memory usage 821.25 MB = 45.66 MB + etc
Indexes folder size 9.97mb
github-actions[bot] commented 2 years ago

Benchmark results

Part Duration
add 1000 elements 561ms
add 1000 private box1 elements 1106ms
unbox 1000 private box1 elements first run 102ms
unbox 1000 private box1 elements second run 79ms
add 1000 private box1 elements 1010ms
query 1000 elements first run 29ms
query 1000 elements second run 18ms
add 1000 private box2 elements 626ms
unbox 1000 private box2 elements first run 316ms
unbox 1000 private box2 elements second run 292ms
Migrate (+db1) 10801ms
Migrate (alone) 3614ms
Migrate (+db1 +db2) 7888ms
Migrate (+db2) 5840ms
Migrate continuation (+db2) 898ms
Memory usage without indexes 727.38 MB = 26.44 MB + etc
Initial indexing 542ms
Initial indexing maxCpu=86 3805ms
Initial indexing compat 738ms
Two indexes updating concurrently 756ms
key one initial 48ms
key two 2ms
key one again 1ms
reboot and key one again 38ms
latest root posts 558ms
latest posts 21ms
votes one initial 438ms
votes again 0ms
hasRoot 331ms
hasRoot again 0ms
author one posts 283ms
author two posts 17ms
dedicated author one posts 270ms
dedicated author one posts again 0ms
Maximum memory usage 811.59 MB = 52.29 MB + etc
Indexes folder size 9.97mb