Skip to content

Commit

Permalink
cmd/sync: increase memory pool for sync oversize files(part > 1G) (#4344
Browse files Browse the repository at this point in the history
)
  • Loading branch information
zhijian-pro authored Jan 16, 2024
1 parent b1b6d29 commit 9bab947
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ func doCopyMultiple(src, dst object.ObjectStorage, key string, size int64, uploa
if partSize == 0 {
partSize = defaultPartSize
}
limits := dst.Limits()
if size > int64(limits.MaxPartSize)*int64(limits.MaxPartCount) {
return fmt.Errorf("object size %d is too large to copy", size)
}
if size > partSize*int64(upload.MaxCount) {
partSize = size / int64(upload.MaxCount)
partSize = ((partSize-1)>>20 + 1) << 20 // align to MB
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func powerOf2(s int) int {
}

func init() {
pools = make([]*sync.Pool, 30) // 1 - 1G
for i := 0; i < 30; i++ {
pools = make([]*sync.Pool, 33) // 1 - 8G
for i := 0; i < 33; i++ {
func(bits int) {
pools[i] = &sync.Pool{
New: func() interface{} {
Expand Down

0 comments on commit 9bab947

Please sign in to comment.