Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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:master
base:master
Choose a base branch
Loading
fromcharlievieth:cev/xl-storage-openfile-perf

Conversation

@charlievieth
Copy link

@charlieviethcharlievieth commentedNov 20, 2025
edited
Loading

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:

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)
goos: linuxgoarch: amd64pkg: github.com/minio/minio/cmdcpu: AMD EPYC-Milan Processor                      │ base.10.txt │             new.10.txt              │                      │   sec/op    │   sec/op     vs base                │XLStorageAppendFile-4   23.07µ ± 3%   16.10µ ± 3%  -30.21% (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)

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Fixes a regression (If yes, please addcommit-id orPR # here)
  • Unit tests added/updated
  • Internal documentation updated
  • Create a documentation update requesthere

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>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@klauspostklauspostklauspost approved these changes

At least 2 approving reviews are required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@charlievieth@klauspost

[8]ページ先頭

©2009-2025 Movatter.jp