Suggested change for TreeOp::Put
davebryson opened this issue Β· comments
Not a big deal, but one suggestion I have is to changeTreeOp::Put(&'a[u8])
to TreeOp::Put(Vec<u8>)
. Why?
- The consumer
Node.value
is already aVec<u8>
- It simplifies TreeOp a bit (lifetime is not needed)
- It's easier to use
Put(Vec<u8>)
from external calls - (again simplifies lifetime stuff)
That was chosen for performance - I hate unneccessary clones. Would switching to AsRef([u8])
solve this?
Ah but you're right that it's getting cloned into the node - maybe you're right and we can just change this π
Made the change to try it out and see the perf difference. It's in my treeop branch
Bench results (just showing Put related ones):
test bench_put_insert_random: 186,201,818 (&[u8]) --- 168,084,786 (Vec<u8>) ns/iter
test bench_put_insert_sequential: 23,737,681 (&[u8]) --- 24,472,033 (Vec<u8>) ns/iter
test bench_put_update_random: 206,077,496 (&[u8]) --- 194,155,280 (Vec<u8>) ns/iter
test bench_put_update_sequential 25,539,183 (&[u8]) --- 24,806,745 (Vec<u8>) ns/iter
Performance wise they're pretty close. I'll settle for 23,809 random inserts per/sec π
Minimal touchpoints to make the change - π to the designer of this thing!