Open lunixbochs opened 1 month ago
In trying to reduce this I noticed os.Stat(bucket)
is actually responsible for a lot of code across the posix endpoints - is there some way you'd feel comfortable removing almost all of the redundant calls to os.Stat(bucket)
for bucket exists and finding another way to make sure it's hit in GetBucketAcl
or via the middleware at an appropriate time for each backend? Almost 6% of the code in posix.go
is redundant os.Stat(bucket)
calls (because it was already called in the acl middleware)
Wow! Thanks for diving into this and opening some PRs too. I have no problem removing the redundant calls. We will need to double check that there are functional tests coving all the cases of these redundant calls just in case something gets refactored in the future.
Ignore the azurite failures in the tests, there is another PR outstanding to fix this.
Recorded with
perf trace -p $(pgrep versitygw)
and then fetching one file withGetObject
4 of the 8 syscalls can be removed here with no downsides:
os.Stat(bucket)
inGetBucketAcl
can be moved afterp.meta.RetrieveAttribute
on error, thoughRetrieveAttribute
may itself even return afs.ErrNotExist
already.os.Stat(bucket)
inGetObject
will currently never be reached for a nonexistent bucket, because the middleware is already raising this error, so this syscall is maybe just redundant. Even if you want defensive coding, we can still avoid the syscall here by only statting the bucket if the file itself is not found, to possibly upgrade a "file not found" error to a "bucket not found" error.p.meta.RetrieveAttribute
calls above seem redundant, I think the metadata should already be retrieved inuserMetaData
from thePosix.loadUserMetaData
method? so we can grab it from there iff it exists instead of making extra syscalls when it doesn't existImpact:
This is a vaguely 44% ~(151us -> 84us) syscall overhead reduction per
GetObject
. Could be worth shaving that further to ~53us (65% reduction) by caching the bucket ACLgetxattr
with like a 1s ttl, which will amortize it out completely under heavy load.