rocicorp / repc

The canonical Replicache client, implemented in Rust.
Other
30 stars 7 forks source link

Prevent one copy when doing get from IDB #283

Closed arv closed 3 years ago

arv commented 3 years ago

We store Uint8Arrays in IDB. So when we do a get we get an Uint8Array out. No need to call new Uint8Array(value) again which does memcopy.

arv commented 3 years ago

And here are the numbers:

master:

populate 1024x1000 (clean, indexes: 0) x 3.56 MB/s ±0.0% (6 runs sampled)
populate 1024x1000 (dirty, indexes: 0) x 4.36 MB/s ±0.0% (9 runs sampled)
populate 1024x1000 (clean, indexes: 1) x 2.85 MB/s ±0.0% (6 runs sampled)
populate 1024x1000 (clean, indexes: 2) x 2.33 MB/s ±0.0% (5 runs sampled)
read tx 1024x1000 x 6.93 MB/s ±0.0% (15 runs sampled)
read tx 1024x5000 x 7.58 MB/s ±0.0% (5 runs sampled)
scan 1024x1000 x 19.15 MB/s ±0.0% (39 runs sampled)
scan 1024x5000 x 23.59 MB/s ±0.0% (10 runs sampled)
write single byte x 11.36 tx/s ±0.0% (23 runs sampled)
create index 1024x1000 x 23.26 op/s ±0.0% (46 runs sampled)
create index 1024x5000 x 5.62 op/s ±0.0% (11 runs sampled)

no-iterate-copy-on-read:

populate 1024x1000 (clean, indexes: 0) x 3.86 MB/s ±0.0% (7 runs sampled)
populate 1024x1000 (dirty, indexes: 0) x 4.40 MB/s ±0.0% (10 runs sampled)
populate 1024x1000 (clean, indexes: 1) x 2.94 MB/s ±0.0% (7 runs sampled)
populate 1024x1000 (clean, indexes: 2) x 2.38 MB/s ±0.0% (5 runs sampled)
read tx 1024x1000 x 6.98 MB/s ±0.0% (15 runs sampled)
read tx 1024x5000 x 7.50 MB/s ±0.0% (5 runs sampled)
scan 1024x1000 x 18.43 MB/s ±0.0% (38 runs sampled)
scan 1024x5000 x 24.54 MB/s ±0.0% (11 runs sampled)
write single byte x 11.49 tx/s ±0.0% (21 runs sampled)
create index 1024x1000 x 23.26 op/s ±0.0% (47 runs sampled)
create index 1024x5000 x 5.62 op/s ±0.0% (12 runs sampled)

Not clear if it made any significant difference.