ssbc / ssb-db2

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

Add decrypted api for for box2 decrypted messages #410

Closed arj03 closed 1 year ago

arj03 commented 1 year ago

This should fix #406

I went through a bit different solutions (see https://github.com/ssbc/jitdb/pull/236), but ended up with a new pull source api.

I considered doing this so the operators could be reused, but decided against that because the filtering is often pretty simple and this also shows people that doing a filter on the result is not that scary. Where this could also be useful is if you have something like do a rough filter on post but then filter the result only for specific stuff without creating an index in jitdb.

github-actions[bot] commented 1 year ago

Benchmark results

Part Duration
Create 5000 new messages 375.36ms
Validate 5000 messages 453.85ms
Native to db format 5000 messages 121.59ms
Db to native format 5000 messages 84.52ms
Add 1000 elements 487.80ms
Add 1000 box1 msgs 929.53ms
Unbox 1000 box1 msgs first run 214.18ms
Unbox 1000 box1 msgs second run 98.99ms
Add 1000 box1 msgs 893.36ms
Query 1000 msgs first run 37.49ms
Query 1000 msgs second run 21.09ms
Add 1000 box2 msgs 1291.75ms
Unbox 1000 box2 msgs first run 320.31ms
Unbox 1000 box2 msgs second run 149.18ms
Migrate (+db1) 11299.17ms
Migrate (alone) 3895.10ms
Migrate (+db1 +db2) 8275.14ms
Migrate (+db2) 6070.83ms
Migrate continuation (+db2) 918.66ms
Memory usage without indexes 753.86 MB = 42.46 MB + etc
Initial indexing 1628.30ms
Initial indexing maxcpu=86 5318.48ms
Initial indexing compat 771.83ms
Two indexes updating concurrently 2810.19ms
Key one initial 52.00ms
Key two 1.87ms
Key one again 2.04ms
Reboot and key one again 38.28ms
Latest root posts 1771.49ms
Latest posts 9.23ms
Votes one initial 1488.35ms
Votes again 0.56ms
HasRoot 1280.07ms
HasRoot again 0.37ms
Author one posts 1379.34ms
Author two posts 18.55ms
Dedicated author one posts 1435.46ms
Dedicated author one posts again 0.48ms
DeleteFeed 5721.17ms
Maximum memory usage 1018.56 MB = 56.37 MB + etc
Indexes folder size 10.01mb
arj03 commented 1 year ago

Should be ready to go now. Thanks for the review. I'll probably squash this as there is a bit too many commits. Happy with the result :)

github-actions[bot] commented 1 year ago

Benchmark results

Part Duration
Create 5000 new messages 406.05ms
Validate 5000 messages 506.73ms
Native to db format 5000 messages 133.03ms
Db to native format 5000 messages 103.88ms
Add 1000 elements 552.10ms
Add 1000 box1 msgs 1040.07ms
Unbox 1000 box1 msgs first run 235.58ms
Unbox 1000 box1 msgs second run 111.83ms
Add 1000 box1 msgs 997.24ms
Query 1000 msgs first run 50.29ms
Query 1000 msgs second run 24.91ms
Add 1000 box2 msgs 1410.89ms
Unbox 1000 box2 msgs first run 376.88ms
Unbox 1000 box2 msgs second run 188.03ms
Migrate (+db1) 12872.16ms
Migrate (alone) 4553.32ms
Migrate (+db1 +db2) 9465.19ms
Migrate (+db2) 6907.56ms
Migrate continuation (+db2) 952.76ms
Memory usage without indexes 762.47 MB = 39.74 MB + etc
Initial indexing 1853.47ms
Initial indexing maxcpu=86 6008.02ms
Initial indexing compat 901.42ms
Two indexes updating concurrently 3182.26ms
Key one initial 55.15ms
Key two 0.53ms
Key one again 1.05ms
Reboot and key one again 47.52ms
Latest root posts 1960.77ms
Latest posts 10.63ms
Votes one initial 1604.99ms
Votes again 0.56ms
HasRoot 1428.01ms
HasRoot again 0.33ms
Author one posts 1543.71ms
Author two posts 16.75ms
Dedicated author one posts 1622.88ms
Dedicated author one posts again 0.61ms
DeleteFeed 6159.03ms
Maximum memory usage 1014.53 MB = 63.13 MB + etc
Indexes folder size 10.01mb
github-actions[bot] commented 1 year ago

Benchmark results

Part Duration
Create 5000 new messages 575.98ms
Validate 5000 messages 583.60ms
Native to db format 5000 messages 169.19ms
Db to native format 5000 messages 120.32ms
Add 1000 elements 517.84ms
Add 1000 box1 msgs 1407.59ms
Unbox 1000 box1 msgs first run 326.96ms
Unbox 1000 box1 msgs second run 146.65ms
Add 1000 box1 msgs 1327.58ms
Query 1000 msgs first run 52.54ms
Query 1000 msgs second run 26.25ms
Add 1000 box2 msgs 2004.25ms
Unbox 1000 box2 msgs first run 557.11ms
Unbox 1000 box2 msgs second run 233.08ms
Migrate (+db1) 16563.72ms
Migrate (alone) 6035.07ms
Migrate (+db1 +db2) 12619.70ms
Migrate (+db2) 8808.96ms
Migrate continuation (+db2) 1493.48ms
Memory usage without indexes 749.56 MB = 42.68 MB + etc
Initial indexing 2142.62ms
Initial indexing maxcpu=86 6613.27ms
Initial indexing compat 1269.63ms
Two indexes updating concurrently 3986.64ms
Key one initial 65.65ms
Key two 1.06ms
Key one again 0.80ms
Reboot and key one again 69.51ms
Latest root posts 2449.03ms
Latest posts 11.62ms
Votes one initial 2025.21ms
Votes again 0.77ms
HasRoot 1849.02ms
HasRoot again 0.59ms
Author one posts 1948.42ms
Author two posts 22.35ms
Dedicated author one posts 2028.48ms
Dedicated author one posts again 0.68ms
DeleteFeed 7338.67ms
Maximum memory usage 1013.62 MB = 62.58 MB + etc
Indexes folder size 10.01mb