ssbc / ssb-db2

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

fix initial value of compacting Obz #381

Closed staltz closed 2 years ago

staltz commented 2 years ago

Fixes (hopefully) issue #380.

I had difficulty reproducing this bug in tests. We would need AAOL compactionProgress to emit more often than 1sec (currently it's hard coded) and we would need to have a way to immediately kill the sbot (to simulate a crash) but we can't because sbot.close will call log.close which actually waits for compaction to complete.

github-actions[bot] commented 2 years ago

Benchmark results

Part Duration
Create 5000 new messages 385.02ms
Validate 5000 messages 476.66ms
Native to db format 5000 messages 109.92ms
Db to native format 5000 messages 81.47ms
Add 1000 elements 495.01ms
Add 1000 box1 msgs 1002.72ms
Unbox 1000 box1 msgs first run 164.14ms
Unbox 1000 box1 msgs second run 106.55ms
Add 1000 box1 msgs 967.17ms
Query 1000 msgs first run 38.19ms
Query 1000 msgs second run 21.54ms
Add 1000 box2 msgs 1288.51ms
Unbox 1000 box2 msgs first run 184.99ms
Unbox 1000 box2 msgs second run 153.66ms
Migrate (+db1) 10838.25ms
Migrate (alone) 3717.58ms
Migrate (+db1 +db2) 8095.41ms
Migrate (+db2) 5646.02ms
Migrate continuation (+db2) 871.86ms
Memory usage without indexes 741.70 MB = 35.31 MB + etc
Initial indexing 606.77ms
Initial indexing maxcpu=86 3831.82ms
Initial indexing compat 630.93ms
Two indexes updating concurrently 936.58ms
Key one initial 46.98ms
Key two 0.49ms
Key one again 0.90ms
Reboot and key one again 51.07ms
Latest root posts 739.77ms
Latest posts 8.81ms
Votes one initial 512.04ms
Votes again 0.48ms
HasRoot 355.56ms
HasRoot again 0.32ms
Author one posts 462.54ms
Author two posts 20.45ms
Dedicated author one posts 493.06ms
Dedicated author one posts again 0.48ms
DeleteFeed 2575.35ms
Maximum memory usage 1017.72 MB = 64.14 MB + etc
Indexes folder size 10.01mb
github-actions[bot] commented 2 years ago

Benchmark results

Part Duration
Create 5000 new messages 367.98ms
Validate 5000 messages 481.33ms
Native to db format 5000 messages 113.88ms
Db to native format 5000 messages 83.58ms
Add 1000 elements 493.07ms
Add 1000 box1 msgs 999.76ms
Unbox 1000 box1 msgs first run 170.64ms
Unbox 1000 box1 msgs second run 115.57ms
Add 1000 box1 msgs 972.24ms
Query 1000 msgs first run 37.99ms
Query 1000 msgs second run 22.75ms
Add 1000 box2 msgs 1270.46ms
Unbox 1000 box2 msgs first run 191.39ms
Unbox 1000 box2 msgs second run 136.09ms
Migrate (+db1) 11158.88ms
Migrate (alone) 3761.60ms
Migrate (+db1 +db2) 8080.02ms
Migrate (+db2) 5785.72ms
Migrate continuation (+db2) 859.26ms
Memory usage without indexes 743.24 MB = 39.48 MB + etc
Initial indexing 630.85ms
Initial indexing maxcpu=86 3935.47ms
Initial indexing compat 746.69ms
Two indexes updating concurrently 919.83ms
Key one initial 54.66ms
Key two 0.61ms
Key one again 0.58ms
Reboot and key one again 43.92ms
Latest root posts 712.96ms
Latest posts 9.58ms
Votes one initial 516.46ms
Votes again 0.65ms
HasRoot 359.19ms
HasRoot again 0.30ms
Author one posts 444.51ms
Author two posts 21.74ms
Dedicated author one posts 479.99ms
Dedicated author one posts again 0.58ms
DeleteFeed 2740.12ms
Maximum memory usage 1006.48 MB = 64.50 MB + etc
Indexes folder size 10.01mb