mirror of
https://github.com/pgsty/minio.git
synced 2026-07-23 22:16:15 +03:00
use Access() instead of Lstat() for frequent use (#11911)
using Lstat() is causing tiny memory allocations, that are usually wasted and never used, instead we can simply uses Access() call that does 0 memory allocations.
This commit is contained in:
@@ -39,6 +39,7 @@ const (
|
||||
osMetricLstat
|
||||
osMetricRemove
|
||||
osMetricStat
|
||||
osMetricAccess
|
||||
// .... add more
|
||||
|
||||
osMetricLast
|
||||
@@ -94,6 +95,14 @@ func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error) {
|
||||
return os.OpenFile(name, flag, perm)
|
||||
}
|
||||
|
||||
// Access captures time taken to call syscall.Access()
|
||||
// on windows, plan9 and solaris syscall.Access uses
|
||||
// os.Lstat()
|
||||
func Access(name string) error {
|
||||
defer updateOSMetrics(osMetricAccess, name)()
|
||||
return access(name)
|
||||
}
|
||||
|
||||
// Open captures time taken to call os.Open
|
||||
func Open(name string) (*os.File, error) {
|
||||
defer updateOSMetrics(osMetricOpen, name)()
|
||||
|
||||
Reference in New Issue
Block a user