mirror of
https://github.com/minio/minio.git
synced 2025-01-24 13:13:16 -05:00
use optimized pathJoin instead of path.Join (#18042)
this avoids allocations in scanner routine, they are tiny but they allocate a lot over many cycles of the scanner.
This commit is contained in:
parent
fa6d082bfd
commit
36385010f5
@ -28,7 +28,6 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -114,7 +113,7 @@ func (r *BatchJobReplicateV1) ReplicateFromSource(ctx context.Context, api Objec
|
|||||||
srcObject := srcObjInfo.Name
|
srcObject := srcObjInfo.Name
|
||||||
tgtObject := srcObjInfo.Name
|
tgtObject := srcObjInfo.Name
|
||||||
if r.Target.Prefix != "" {
|
if r.Target.Prefix != "" {
|
||||||
tgtObject = path.Join(r.Target.Prefix, srcObjInfo.Name)
|
tgtObject = pathJoin(r.Target.Prefix, srcObjInfo.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
versionID := srcObjInfo.VersionID
|
versionID := srcObjInfo.VersionID
|
||||||
@ -182,7 +181,7 @@ func (r *BatchJobReplicateV1) copyWithMultipartfromSource(ctx context.Context, a
|
|||||||
srcObject := srcObjInfo.Name
|
srcObject := srcObjInfo.Name
|
||||||
tgtObject := srcObjInfo.Name
|
tgtObject := srcObjInfo.Name
|
||||||
if r.Target.Prefix != "" {
|
if r.Target.Prefix != "" {
|
||||||
tgtObject = path.Join(r.Target.Prefix, srcObjInfo.Name)
|
tgtObject = pathJoin(r.Target.Prefix, srcObjInfo.Name)
|
||||||
}
|
}
|
||||||
if r.Target.Type == BatchJobReplicateResourceS3 || r.Source.Type == BatchJobReplicateResourceS3 {
|
if r.Target.Type == BatchJobReplicateResourceS3 || r.Source.Type == BatchJobReplicateResourceS3 {
|
||||||
opts.VersionID = ""
|
opts.VersionID = ""
|
||||||
|
@ -409,9 +409,9 @@ func (f *folderScanner) scanFolder(ctx context.Context, folder cachedFolder, int
|
|||||||
|
|
||||||
var existingFolders, newFolders []cachedFolder
|
var existingFolders, newFolders []cachedFolder
|
||||||
var foundObjects bool
|
var foundObjects bool
|
||||||
err := readDirFn(path.Join(f.root, folder.name), func(entName string, typ os.FileMode) error {
|
err := readDirFn(pathJoin(f.root, folder.name), func(entName string, typ os.FileMode) error {
|
||||||
// Parse
|
// Parse
|
||||||
entName = pathClean(path.Join(folder.name, entName))
|
entName = pathClean(pathJoin(folder.name, entName))
|
||||||
if entName == "" || entName == folder.name {
|
if entName == "" || entName == folder.name {
|
||||||
if f.dataUsageScannerDebug {
|
if f.dataUsageScannerDebug {
|
||||||
console.Debugf(scannerLogPrefix+" no entity (%s,%s)\n", f.root, entName)
|
console.Debugf(scannerLogPrefix+" no entity (%s,%s)\n", f.root, entName)
|
||||||
@ -461,7 +461,7 @@ func (f *folderScanner) scanFolder(ctx context.Context, folder cachedFolder, int
|
|||||||
|
|
||||||
// Get file size, ignore errors.
|
// Get file size, ignore errors.
|
||||||
item := scannerItem{
|
item := scannerItem{
|
||||||
Path: path.Join(f.root, entName),
|
Path: pathJoin(f.root, entName),
|
||||||
Typ: typ,
|
Typ: typ,
|
||||||
bucket: bucket,
|
bucket: bucket,
|
||||||
prefix: path.Dir(prefix),
|
prefix: path.Dir(prefix),
|
||||||
@ -496,7 +496,7 @@ func (f *folderScanner) scanFolder(ctx context.Context, folder cachedFolder, int
|
|||||||
// Object already accounted for, remove from heal map,
|
// Object already accounted for, remove from heal map,
|
||||||
// simply because getSize() function already heals the
|
// simply because getSize() function already heals the
|
||||||
// object.
|
// object.
|
||||||
delete(abandonedChildren, path.Join(item.bucket, item.objectPath()))
|
delete(abandonedChildren, pathJoin(item.bucket, item.objectPath()))
|
||||||
|
|
||||||
into.addSizes(sz)
|
into.addSizes(sz)
|
||||||
into.Objects++
|
into.Objects++
|
||||||
@ -873,7 +873,7 @@ type getSizeFn func(item scannerItem) (sizeSummary, error)
|
|||||||
func (i *scannerItem) transformMetaDir() {
|
func (i *scannerItem) transformMetaDir() {
|
||||||
split := strings.Split(i.prefix, SlashSeparator)
|
split := strings.Split(i.prefix, SlashSeparator)
|
||||||
if len(split) > 1 {
|
if len(split) > 1 {
|
||||||
i.prefix = path.Join(split[:len(split)-1]...)
|
i.prefix = pathJoin(split[:len(split)-1]...)
|
||||||
} else {
|
} else {
|
||||||
i.prefix = ""
|
i.prefix = ""
|
||||||
}
|
}
|
||||||
@ -1247,7 +1247,7 @@ func applyLifecycleAction(event lifecycle.Event, src lcEventSrc, obj ObjectInfo)
|
|||||||
|
|
||||||
// objectPath returns the prefix and object name.
|
// objectPath returns the prefix and object name.
|
||||||
func (i *scannerItem) objectPath() string {
|
func (i *scannerItem) objectPath() string {
|
||||||
return path.Join(i.prefix, i.objectName)
|
return pathJoin(i.prefix, i.objectName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// healReplication will heal a scanned item that has failed replication.
|
// healReplication will heal a scanned item that has failed replication.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user