Commit graph

12 commits

Author SHA1 Message Date
Calvin Kim
e009124748 treap, ffldb: change Put() to take in multiple key-value pairs
Previously, the Put() function took in a single key-value pair,
resulting in memory allocation overhead as the intermediary treapNodes
got allocated and immediately garbage collected, resulting in
performance loss due to the garbage collection overhead.

We're able to recycle the intermediary treapNodes allocated by taking in
multiple key-value pairs.  This results in better performance of the
node especially during UTXO cache flushes.
2025-11-14 14:58:35 +01:00
Calvin Kim
0e95ae381a treap: add recycle() method on treapNode
The recycle method resets and puts the treapNode into the treapNodePool
to be recycled at a future date.
2025-10-30 17:21:22 +09:00
Calvin Kim
65d39687bf treap: return newly created treapNodes in put()
The newly created treapNodes in put() are now returned so that the
caller has access to them.  This is done so that the caller can put back
some of the treapNodes to sync.Pool.

For multiple put operations, an immutable treap will allocate many
treapNodes that will immediately be garbage collected.  Let's say
there's 3 key-value pairs that are going to be inserted:

key 1: 50
key 2: 10
key 3: 4

Then the insertion is like so:

1: allocate 50.

        50

2: clone 50, allocate 10.

        50
       /  \
      10

3: clone 50, clone 10, allocate 4

        50
       /  \
      10
     /
    4

In this example, only the nodes allocated during insertion of (3) is
going to be used.  The rest is going to be garbage collected and they
can be safely be put in the sync.Pool if there's a guarantee that the
previous copies are not being accessed.  This is true if the put
operations are going to be called in batches.

By returning the pointers of these allocated treapNodes, we allow the
caller to make such optimizations.
2025-10-30 16:57:57 +09:00
Calvin Kim
e3d237d3ca treap: add treapNodePool and fetch from it for cloneTreapNode and
newTreapNode

The treapNodePool will allow for less memory allocations during
immutable treap operations.  We first change the cloneTreapNode and
newTreapNode to allocate a treapNode from the sync.Pool.

The allocated treapNodes will be put back into the sync.Pool in later
commits.
2025-09-20 17:54:14 +09:00
Calvin Kim
26ef499ae4 treap: refactor the Put() code into exported and unexported versions
We do this to later add batch put logic into the exported Put()
function.
2025-09-20 17:50:54 +09:00
cui fliter
e160bb6922 multi: remove repetitive the
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-26 15:40:51 +08:00
Calvin Kim
ba5407615d multi: Run gofmt on the entire repository
The doc formatting changes introduced in the recent go version is
increasing the diff for all of the new commits.  Formatting it all in
this commit will help the readability of future PRs by reducing the
diff.
2023-06-21 22:31:09 +09:00
Jake Sylvestre
d08785547a docs: update shields 2021-03-05 07:45:19 -05:00
tpkeeper
8512affc59 readme: remove duplicate word 2020-05-06 08:32:44 -04:00
Dave Collins
9918e2a561
multi: Update markdown files for GFM changes.
The github markdown interpreter has been changed such that it no longer
allows spaces in between the brackets and parenthesis of links and now
requires a newline in between anchors and other formatting.  This
updates all of the markdown files accordingly.

While here, it also corrects a couple of inconsistencies in some of the
README.md files.
2017-05-25 12:06:16 -05:00
Dave Collins
915fa6639b
multi: Simplify code per gosimple linter.
This simplifies the code based on the recommendations of the gosimple
lint tool.
2016-11-03 13:00:35 -05:00
Dave Collins
b580cdb7d3 database: Replace with new version.
This commit removes the old database package, moves the new package into
its place, and updates all imports accordingly.
2016-04-12 14:55:15 -05:00