Skip to content

Commit

Permalink
*: Remove multipart object re-slicing
Browse files Browse the repository at this point in the history
Closes #843.

Before, multipartComplete read all parts of Big object to the memory, combine them and generate final Big object.
These step consume time and memory, eventually any system will fail to load all parts in mem or timeout during
the process.
After, object slicing process works from the first uploaded part. Calculating each part hash and whole object
hash during whole process. Storing object hash state to each part metadata in tree service.

Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
  • Loading branch information
smallhive committed Mar 15, 2024
1 parent ef9a5ba commit a21a781
Show file tree
Hide file tree
Showing 11 changed files with 540 additions and 51 deletions.
7 changes: 7 additions & 0 deletions api/data/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ type PartInfo struct {
Created time.Time
// Server creation time.
ServerCreated time.Time

// MultipartHash contains internal state of the [hash.Hash] to calculate whole object payload hash.
MultipartHash []byte
// HomoHash contains internal state of the [hash.Hash] to calculate whole object homomorphic payload hash.
HomoHash []byte
// Elements contain [oid.ID] object list for the current part.
Elements []oid.ID
}

// ToHeaderString form short part representation to use in S3-Completed-Parts header.
Expand Down
9 changes: 9 additions & 0 deletions api/layer/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/url"
"strconv"
"strings"
"sync"
"time"

"github.com/nats-io/nats.go"
Expand Down Expand Up @@ -50,6 +51,7 @@ type (
ncontroller EventListener
cache *Cache
treeService TreeService
buffers *sync.Pool
}

Config struct {
Expand Down Expand Up @@ -266,13 +268,20 @@ func (f MsgHandlerFunc) HandleMessage(ctx context.Context, msg *nats.Msg) error
// NewLayer creates an instance of a layer. It checks credentials
// and establishes gRPC connection with the node.
func NewLayer(log *zap.Logger, neoFS NeoFS, config *Config) Client {
buffers := sync.Pool{}
buffers.New = func() any {
b := make([]byte, neoFS.MaxObjectSize())
return &b
}

return &layer{
neoFS: neoFS,
log: log,
anonymous: config.Anonymous,
resolver: config.Resolver,
cache: NewCache(config.Caches),
treeService: config.TreeService,
buffers: &buffers,
}
}

Expand Down
Loading

0 comments on commit a21a781

Please sign in to comment.