Skip to content

Commit

Permalink
object/search: Do not access the node repeatedly within the same request
Browse files Browse the repository at this point in the history
Previously, `ObjectService.Search` RPC server could send a request to a
remote container node more than once in the context of processing a
single client request. On the one hand, this makes no sense, since the
state of the remote node is assumed to be unchanged in the context of a
single request. On the other hand, the resource costs for a repeated
request are prohibitively high - signatures, network, local storage.

In practice, repetitions occurred in two cases:
 - storage policy specifics, e.g. with several replica (`REP`) rules
 - when switching processing to previous epochs: some nodes could
   "remain" in the container

This is solved by storing the processed nodes in memory. Incurs much
lower costs than repeated requests.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Jan 17, 2024
1 parent 04d99d4 commit a862cb4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/services/object/search/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ func (exec *execCtx) executeOnContainer() {
return
}

mProcessedNodes := make(map[string]struct{})

for {
if exec.processCurrentEpoch() {
if exec.processCurrentEpoch(mProcessedNodes) {
break
}

Expand All @@ -47,7 +49,7 @@ func (exec *execCtx) executeOnContainer() {
exec.err = nil
}

func (exec *execCtx) processCurrentEpoch() bool {
func (exec *execCtx) processCurrentEpoch(mProcessedNodes map[string]struct{}) bool {
exec.log.Debug("process epoch",
zap.Uint64("number", exec.curProcEpoch),
)
Expand All @@ -71,6 +73,13 @@ func (exec *execCtx) processCurrentEpoch() bool {
var mtx sync.Mutex

for i := range addrs {
strKey := string(addrs[i].PublicKey())
if _, ok = mProcessedNodes[strKey]; ok {
continue
}

mProcessedNodes[strKey] = struct{}{}

wg.Add(1)
go func(i int) {
defer wg.Done()
Expand Down

0 comments on commit a862cb4

Please sign in to comment.