Jacek Sieka db8f81cd63
perf: flatten merkle tree
A classic encoding of a merkle tree is to store the layers consecutively
in memory breadth-first. This encoding has several advantages:

* Good performance for accessing successive nodes, such as when
constructing the tree or serializing it
* Significantly lower memory usage - avoids the per-node allocation
overhead which otherwise more than doubles the memory usage for
"regular" 32-byte hashes
* Less memory management - a single memory allocation can reserve memory
for the whole tree meaning that there are fewer allocations to keep
track of
* Simplified buffer lifetimes - with all memory allocated up-front,
there's no need for cross-thread memory management or transfers

While we're here, we can clean up a few other things in the
implementation:

* Move async implementation to `merkletree` so that it doesn't have to
be repeated
* Factor tree construction into preparation and computation - the latter
is the part offloaded onto a different thread
* Simplify task posting - `threadpools` already creates a "task" from
the worker function call
* Deprecate several high-overhead accessors that presumably are only
needed in tests
2025-12-17 13:52:44 +01:00
..
2025-12-17 13:52:44 +01:00
2025-07-10 18:56:42 +05:30
2023-12-21 06:41:43 +00:00
2025-12-11 21:03:36 +00:00
2024-03-12 06:41:03 +00:00
2024-09-23 14:37:17 +00:00
2024-06-10 22:47:29 +00:00