frostfs-node/pkg
Evgenii Stratonikov c0135f8a65 tree: Use pairing heap for listing
When we have N items, sorting then iterating provides `O(n log n)` latency
in the worst case scenario (flat bucket), because we must return items
from a level in the sorted order. Some heap implementations allow O(1)
insertion and O(log n) dequeue, this means that we can decrease the
latency for the first received operation to O(log n), albeit with a
slight increase in the total time.
Pairing heap was chosen as one of the most simplest implementations.

```
goos: linux
goarch: amd64
pkg: git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/tree
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
                        │     old      │                 new                  │
                        │    sec/op    │    sec/op     vs base                │
GetSubTree/latency-8      5.034m ± 23%   1.110m ± 22%  -77.95% (p=0.000 n=10)
GetSubTree/total_time-8   81.03m ±  1%   95.02m ± 14%  +17.26% (p=0.000 n=10)
geomean                   20.20m         10.27m        -49.15%

                        │     old      │                 new                  │
                        │     B/op     │     B/op      vs base                │
GetSubTree/latency-8      32.14Mi ± 0%   37.49Mi ± 0%  +16.63% (p=0.000 n=10)
GetSubTree/total_time-8   32.14Mi ± 0%   37.49Mi ± 0%  +16.63% (p=0.000 n=10)
geomean                   32.14Mi        37.49Mi       +16.63%

                        │     old     │                new                 │
                        │  allocs/op  │  allocs/op   vs base               │
GetSubTree/latency-8      400.0k ± 0%   400.0k ± 0%  +0.00% (p=0.000 n=10)
GetSubTree/total_time-8   400.0k ± 0%   400.0k ± 0%  +0.00% (p=0.000 n=10)
geomean                   400.0k        400.0k       +0.00%
```

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-01-30 12:36:26 +03:00
..
core [#529] objectcore: Use common sender classifier 2023-08-29 10:33:06 +03:00
innerring [#733] frostfs-cli: Add control ir remove-container 2023-11-03 15:42:58 +03:00
local_object_storage [#863] blobovnicza: Fix counters 2023-12-13 13:57:42 +03:00
metrics [#661] metrcis: Add rebuild percent metric 2023-12-07 15:36:05 +03:00
morph [#858] morph: Disable kludge by default 2023-12-12 12:01:10 +03:00
network [#674] network: Close connections on address updates 2023-09-04 15:34:24 +03:00
services tree: Use pairing heap for listing 2024-01-30 12:36:26 +03:00
util [#638] logger: Remove sampling from test loggers 2023-08-23 11:21:05 +00:00