Remove unnecessary locking in fs
osFs.acquire and osFs.release are surprisingly expensive, using a combined 345.7s of runtime in an AOSP aosp_cf_x86_64_phone-userdebug build. They are used to ensure we don't use too many simultaneous open files, but many of the functions they are called from don't actually open a file. Remove them from all the stat-based functions (Exists, IsDir, IsSymlink, Lstat, Stat), and from ReadLink. After this change the time spent in acquire and release is effectively zero. Test: SOONG_PROFILE_CPU=/tmp/cpu.pprof m nothing Change-Id: Ie5e22e33c61794354821f05ab79ceb4efc3b276c
This commit is contained in:
parent
0065131f50
commit
098c09334f
1 changed files with 0 additions and 12 deletions
|
@ -204,8 +204,6 @@ func (fs *osFs) Open(name string) (ReaderAtSeekerCloser, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *osFs) Exists(name string) (bool, bool, error) {
|
func (fs *osFs) Exists(name string) (bool, bool, error) {
|
||||||
fs.acquire()
|
|
||||||
defer fs.release()
|
|
||||||
stat, err := os.Stat(fs.toAbs(name))
|
stat, err := os.Stat(fs.toAbs(name))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return true, stat.IsDir(), nil
|
return true, stat.IsDir(), nil
|
||||||
|
@ -217,8 +215,6 @@ func (fs *osFs) Exists(name string) (bool, bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *osFs) IsDir(name string) (bool, error) {
|
func (fs *osFs) IsDir(name string) (bool, error) {
|
||||||
fs.acquire()
|
|
||||||
defer fs.release()
|
|
||||||
info, err := os.Stat(fs.toAbs(name))
|
info, err := os.Stat(fs.toAbs(name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -227,8 +223,6 @@ func (fs *osFs) IsDir(name string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *osFs) IsSymlink(name string) (bool, error) {
|
func (fs *osFs) IsSymlink(name string) (bool, error) {
|
||||||
fs.acquire()
|
|
||||||
defer fs.release()
|
|
||||||
if info, err := os.Lstat(fs.toAbs(name)); err != nil {
|
if info, err := os.Lstat(fs.toAbs(name)); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else {
|
} else {
|
||||||
|
@ -249,14 +243,10 @@ func (fs *osFs) glob(pattern string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *osFs) Lstat(path string) (stats os.FileInfo, err error) {
|
func (fs *osFs) Lstat(path string) (stats os.FileInfo, err error) {
|
||||||
fs.acquire()
|
|
||||||
defer fs.release()
|
|
||||||
return os.Lstat(fs.toAbs(path))
|
return os.Lstat(fs.toAbs(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *osFs) Stat(path string) (stats os.FileInfo, err error) {
|
func (fs *osFs) Stat(path string) (stats os.FileInfo, err error) {
|
||||||
fs.acquire()
|
|
||||||
defer fs.release()
|
|
||||||
return os.Stat(fs.toAbs(path))
|
return os.Stat(fs.toAbs(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,8 +274,6 @@ func (fs *osFs) ReadDirNames(name string) ([]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *osFs) Readlink(name string) (string, error) {
|
func (fs *osFs) Readlink(name string) (string, error) {
|
||||||
fs.acquire()
|
|
||||||
defer fs.release()
|
|
||||||
return os.Readlink(fs.toAbs(name))
|
return os.Readlink(fs.toAbs(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue