Skip to content

Conversation

@roman-khimov
Copy link
Member

No functional changes.

…ject()

Usually we don't have many associated objects of the same type, but outer
cycle should still work correctly in all cases. Absent this fix we can have
a broken metaCursor that will certainly not find another associated object.

Signed-off-by: Roman Khimov <[email protected]>
@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

❌ Patch coverage is 87.62376% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.60%. Comparing base (2fbdf76) to head (0e9d8cb).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
pkg/local_object_storage/metabase/put.go 76.08% 6 Missing and 5 partials ⚠️
pkg/local_object_storage/metabase/metadata.go 60.00% 4 Missing ⚠️
pkg/local_object_storage/metabase/delete.go 71.42% 1 Missing and 1 partial ⚠️
pkg/local_object_storage/metabase/get.go 90.00% 1 Missing and 1 partial ⚠️
pkg/local_object_storage/metabase/iterators.go 81.81% 1 Missing and 1 partial ⚠️
pkg/local_object_storage/metabase/select.go 90.90% 2 Missing ⚠️
pkg/local_object_storage/metabase/inhume.go 50.00% 0 Missing and 1 partial ⚠️
pkg/local_object_storage/metabase/list.go 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3770      +/-   ##
==========================================
- Coverage   25.74%   25.60%   -0.14%     
==========================================
  Files         657      657              
  Lines       42223    42102     -121     
==========================================
- Hits        10870    10781      -89     
+ Misses      30366    30343      -23     
+ Partials      987      978       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

And use it where appropirate. The iterator itself is not exactly trivial, but
it simplifes code using values from it, in some cases allowing to avoid
additional allocations.

Signed-off-by: Roman Khimov <[email protected]>
Check association first, make switch be a proper switch. Minus two tabs for
the most part of the function.

Signed-off-by: Roman Khimov <[email protected]>
All of users have it anyway except for Get() which is rarely called and can
handle it internally.

Signed-off-by: Roman Khimov <[email protected]>
This allows to remove one intermediary tx function, otherwise it's all
the same.

Signed-off-by: Roman Khimov <[email protected]>
Drop some duplication and simplify flow. Caveat: this (inevitably) makes a bit
different choice wrt invalid key handling, but this was inconsistent among
users and returning an error is not very helpful in most cases.

Signed-off-by: Roman Khimov <[email protected]>
Simpler and allows to allocated a bit less in some cases.

goos: linux
goarch: amd64
pkg: github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase
cpu: AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics
                     │ expired.old │            expired.new             │
                     │   sec/op    │   sec/op     vs base               │
Exists/existing-16     2.647µ ± 1%   2.559µ ± 0%  -3.33% (p=0.001 n=10)
Exists/inexisting-16   548.1n ± 1%   539.0n ± 1%  -1.66% (p=0.002 n=10)
geomean                1.204µ        1.174µ       -2.50%

                     │ expired.old  │              expired.new              │
                     │     B/op     │     B/op      vs base                 │
Exists/existing-16     1.561Ki ± 0%   1.467Ki ± 0%  -6.01% (p=0.000 n=10)
Exists/inexisting-16     376.0 ± 0%     376.0 ± 0%       ~ (p=1.000 n=10) ¹
geomean                  775.1          751.5       -3.05%
¹ all samples are equal

                     │ expired.old │             expired.new             │
                     │  allocs/op  │ allocs/op   vs base                 │
Exists/existing-16      30.00 ± 0%   29.00 ± 0%  -3.33% (p=0.000 n=10)
Exists/inexisting-16    5.000 ± 0%   5.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                 12.25        12.04       -1.68%
¹ all samples are equal

Signed-off-by: Roman Khimov <[email protected]>
Less code, less allocations.

goos: linux
goarch: amd64
pkg: github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase
cpu: AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics
                     │ expired.old │            expired.new             │
                     │   sec/op    │   sec/op     vs base               │
Exists/existing-16     2.559µ ± 0%   2.518µ ± 1%  -1.60% (p=0.001 n=10)
Exists/inexisting-16   539.0n ± 1%   541.8n ± 2%       ~ (p=0.089 n=10)
geomean                1.174µ        1.168µ       -0.55%

                     │ expired.old  │              expired.new              │
                     │     B/op     │     B/op      vs base                 │
Exists/existing-16     1.467Ki ± 0%   1.389Ki ± 0%  -5.33% (p=0.000 n=10)
Exists/inexisting-16     376.0 ± 0%     376.0 ± 0%       ~ (p=1.000 n=10) ¹
geomean                  751.5          731.2       -2.70%
¹ all samples are equal

                     │ expired.old │             expired.new             │
                     │  allocs/op  │ allocs/op   vs base                 │
Exists/existing-16      29.00 ± 0%   28.00 ± 0%  -3.45% (p=0.000 n=10)
Exists/inexisting-16    5.000 ± 0%   5.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                 12.04        11.83       -1.74%
¹ all samples are equal

Signed-off-by: Roman Khimov <[email protected]>
A bit more common pattern.

Signed-off-by: Roman Khimov <[email protected]>
@roman-khimov roman-khimov merged commit d2624c8 into master Jan 12, 2026
25 of 30 checks passed
@roman-khimov roman-khimov deleted the metabase-polish branch January 12, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants