- Notifications
You must be signed in to change notification settings - Fork6.5k
xl-storage: improve xlStorage.openFile performance#21702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
charlievieth wants to merge1 commit intominio:masterChoose a base branch fromcharlievieth:cev/xl-storage-openfile-perf
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+40 −5
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This commit improves the performance of xlStorage.openFile and thusAppendFile by ~33% when the file's parent directory already exists.The performance improvement comes from changing openFile tooptimistically attempt to open the file and only create the parentdirectories if os.OpenFile fails with ErrNotExist.The performance impact of a failed call to os.OpenFile when the parentdirectory does not exist and must be created is about ~300ns on Linux,which is far less than the benefit this change provides for the likelymore common case of the parent directory existing.Benchmark results:goos: linuxgoarch: arm64pkg: github.com/minio/minio/cmd │ base.10.txt │ new.10.txt │ │ sec/op │ sec/op vs base │XLStorageAppendFile-4 9.023µ ± 1% 5.961µ ± 0% -33.94% (p=0.000 n=10) │ base.10.txt │ new.10.txt │ │ B/op │ B/op vs base │XLStorageAppendFile-4 2.281Ki ± 1% 1.672Ki ± 0% -26.71% (p=0.000 n=10) │ base.10.txt │ new.10.txt │ │ allocs/op │ allocs/op vs base │XLStorageAppendFile-4 50.00 ± 0% 35.00 ± 0% -30.00% (p=0.000 n=10)Signed-off-by: Charlie Vieth <charlie.vieth@gmail.com>
klauspost approved these changesNov 21, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
Community Contribution License
All community contributions in this pull request are licensed to the project maintainers
under the terms of theApache 2 license.
By creating this pull request I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 license.
Description
This commit improves the performance of xlStorage.openFile and thus AppendFile by ~33% when the file's parent directory already exists. The performance improvement comes from changing openFile to optimistically attempt to open the file and only create the parent directories if os.OpenFile fails with ErrNotExist.
The performance impact of a failed call to os.OpenFile when the parent directory does not exist and must be created is about ~300ns on Linux, which is far less than the benefit this change provides for the likely more common case of the parent directory existing.
Benchmark results:
Motivation and Context
Motivation is simply performance. As for context, I noticed this while reviewing the minio code.
How to test this PR?
The existing tests cover this logic.
Types of changes
Checklist:
commit-idorPR #here)