Skip to content

Commit

Permalink
Fix neofs_node_engine_list_objects_time_bucket metric (#3120)
Browse files Browse the repository at this point in the history
  • Loading branch information
cthulhu-rider authored Feb 12, 2025
2 parents 64dac4c + 87441c3 commit eb90734
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Changelog for NeoFS Node
- The parent of the split object is not removed from the metabase (#3089)
- A split expired object is not deleted after the lock is removed or expired (#3089)
- `neofs_node_engine_list_containers_time_bucket` and `neofs_node_engine_exists_time_bucket` metrics (#3014)
- `neofs_node_engine_list_objects_time_bucket` metric (#3120)

### Changed
- Number of cuncurrenly handled notifications from the chain was increased from 10 to 300 for IR (#3068)
Expand Down
4 changes: 4 additions & 0 deletions pkg/local_object_storage/engine/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type Cursor struct {
// Returns ErrEndOfListing if there are no more objects to return or count
// parameter set to zero.
func (e *StorageEngine) ListWithCursor(count uint32, cursor *Cursor) ([]objectcore.AddressWithType, *Cursor, error) {
if e.metrics != nil {
defer elapsed(e.metrics.AddListObjectsDuration)()
}

result := make([]objectcore.AddressWithType, 0, count)

// 1. Get available shards and sort them.
Expand Down
43 changes: 0 additions & 43 deletions pkg/local_object_storage/engine/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,46 +49,3 @@ func (e *StorageEngine) Select(cnr cid.ID, filters object.SearchFilters) ([]oid.

return addrList, nil
}

// List returns `limit` available physically storage object addresses in engine.
// If limit is zero, then returns all available object addresses.
//
// Returns an error if executions are blocked (see BlockExecution).
func (e *StorageEngine) List(limit uint64) ([]oid.Address, error) {
if e.metrics != nil {
defer elapsed(e.metrics.AddListObjectsDuration)()
}

e.blockMtx.RLock()
defer e.blockMtx.RUnlock()

if e.blockErr != nil {
return nil, e.blockErr
}

addrList := make([]oid.Address, 0, limit)
uniqueMap := make(map[string]struct{})
ln := uint64(0)

// consider iterating over shuffled shards
for _, sh := range e.unsortedShards() {
res, err := sh.List() // consider limit result of shard iterator
if err != nil {
e.reportShardError(sh, "could not select objects from shard", err)
continue
}
for _, addr := range res { // save only unique values
if _, ok := uniqueMap[addr.EncodeToString()]; !ok {
uniqueMap[addr.EncodeToString()] = struct{}{}
addrList = append(addrList, addr)

ln++
if limit > 0 && ln >= limit {
return addrList, nil
}
}
}
}

return addrList, nil
}

0 comments on commit eb90734

Please sign in to comment.