google / btree

BTree provides a simple, ordered, in-memory data structure for Go programs.
Apache License 2.0
3.9k stars 414 forks source link

Persistent12 #14

Closed keep94 closed 4 years ago

keep94 commented 7 years ago

This is ImmutableBTree without the Builder class. The API changes here involve the following:

As I had expected, the ImmutableInsert1 benchmark slowed down 2X from my previous PR but ImmutableInsert100 was only ~50% slower. ImmutableDelete gave similar results.

I suspect that ImmutableInsert100 was only 50% slower because with more changes, the changes themselves take up a larger percentage of time than the copying because the later changes require copying fewer nodes since the BTree owns the nodes from the previous changes.

Although this PR does not have the performance that the previous PR had when changing Immutable trees, I prefer this PR to the previous one because the API is simpler. I believe that the 50% to 2X slow down in performance is a fair trade off for simpler API.