mirror of
https://github.com/minio/minio.git
synced 2025-11-20 18:06:10 -05:00
fix: [fs] CompleteMultipart use trie structure for partMatch (#10522)
performance improves by around 100x or more ``` go test -v -run NONE -bench BenchmarkGetPartFile goos: linux goarch: amd64 pkg: github.com/minio/minio/cmd BenchmarkGetPartFileWithTrie BenchmarkGetPartFileWithTrie-4 1000000000 0.140 ns/op 0 B/op 0 allocs/op PASS ok github.com/minio/minio/cmd 1.737s ``` fixes #10520
This commit is contained in:
@@ -45,6 +45,7 @@ import (
|
||||
"github.com/minio/minio/cmd/logger"
|
||||
"github.com/minio/minio/pkg/hash"
|
||||
"github.com/minio/minio/pkg/ioutil"
|
||||
"github.com/minio/minio/pkg/trie"
|
||||
"github.com/minio/minio/pkg/wildcard"
|
||||
)
|
||||
|
||||
@@ -487,13 +488,12 @@ func hasPattern(patterns []string, matchStr string) bool {
|
||||
}
|
||||
|
||||
// Returns the part file name which matches the partNumber and etag.
|
||||
func getPartFile(entries []string, partNumber int, etag string) string {
|
||||
for _, entry := range entries {
|
||||
if strings.HasPrefix(entry, fmt.Sprintf("%.5d.%s.", partNumber, etag)) {
|
||||
return entry
|
||||
}
|
||||
func getPartFile(entriesTrie *trie.Trie, partNumber int, etag string) (partFile string) {
|
||||
for _, match := range entriesTrie.PrefixMatch(fmt.Sprintf("%.5d.%s.", partNumber, etag)) {
|
||||
partFile = match
|
||||
break
|
||||
}
|
||||
return ""
|
||||
return partFile
|
||||
}
|
||||
|
||||
// Returns the compressed offset which should be skipped.
|
||||
|
||||
Reference in New Issue
Block a user