-
Notifications
You must be signed in to change notification settings - Fork 6
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize zero reads #34
Merged
Merged
Conversation
This file contains 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
6 tasks
AkihiroSuda
reviewed
Oct 18, 2024
AkihiroSuda
reviewed
Oct 18, 2024
nirs
force-pushed
the
zero-reads
branch
2 times, most recently
from
October 18, 2024 06:05
d8933ae
to
82f0931
Compare
@AkihiroSuda current version is simpler, needs no temporary buffer, and much faster. |
Use optimized range loop[1], optimized by the compiler to single memclr call. This dramatically speeds up zero reads. | format | compression | utilization | speedup | |--------|-------------|-------------|---------| | qcow2 | - | 0% | 28.72 | | qcow2 | zlib | 0% | 28.04 | | qcow2 | - | 50% | 4.54 | | qcow2 | zlib | 50% | 1.03 | | qcow2 | - | 100% | 1.01 | | qcow2 | zlib | 100% | 1.00 | Before: % go test -bench Read BenchmarkRead0p/qcow2-12 14 77515735 ns/op 3462.98 MB/s 1050518 B/op 39 allocs/op BenchmarkRead0p/qcow2_zlib-12 14 77823402 ns/op 3449.29 MB/s 1050504 B/op 39 allocs/op BenchmarkRead50p/qcow2-12 24 48812158 ns/op 5499.36 MB/s 1181856 B/op 45 allocs/op BenchmarkRead50p/qcow2_zlib-12 2 899659187 ns/op 298.37 MB/s 184996316 B/op 43247 allocs/op BenchmarkRead100p/qcow2-12 61 19306020 ns/op 13904.24 MB/s 1181854 B/op 45 allocs/op BenchmarkRead100p/qcow2_zlib-12 1 1732168542 ns/op 154.97 MB/s 368850952 B/op 86460 allocs/op After: % go test -bench Read BenchmarkRead0p/qcow2-12 471 2698377 ns/op 99480.34 MB/s 1050514 B/op 39 allocs/op BenchmarkRead0p/qcow2_zlib-12 468 2774952 ns/op 96735.15 MB/s 1050511 B/op 39 allocs/op BenchmarkRead50p/qcow2-12 100 10735870 ns/op 25003.61 MB/s 1181854 B/op 45 allocs/op BenchmarkRead50p/qcow2_zlib-12 2 868310583 ns/op 309.15 MB/s 185038456 B/op 43263 allocs/op BenchmarkRead100p/qcow2-12 63 18977718 ns/op 14144.77 MB/s 1181851 B/op 45 allocs/op BenchmarkRead100p/qcow2_zlib-12 1 1727832917 ns/op 155.36 MB/s 368886656 B/op 86471 allocs/op Comparing with qemu-img show that we match qemu-img performance for uncompressed version of the lima default image: % time ./go-qcow2reader-example /tmp/test.qcow2 > /tmp/tmp.img ./go-qcow2reader-example /tmp/test.qcow2 > /tmp/tmp.img 0.06s user 0.73s system 93% cpu 0.854 total % time qemu-img convert -O raw /tmp/test.qcow2 /tmp/tmp.img qemu-img convert -O raw /tmp/test.qcow2 /tmp/tmp.img 0.04s user 0.70s system 98% cpu 0.756 total [1] https://go-review.googlesource.com/c/go/+/2520 Signed-off-by: Nir Soffer <[email protected]>
AkihiroSuda
approved these changes
Oct 20, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Sign up for free
to 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.
Use optimized range loop[1], optimized by the compiler to single memclr
call. This dramatically speeds up zero reads.
Before:
After:
Comparing with qemu-img show that we match qemu-img performance for
uncompressed version of the lima default image:
[1] https://go-review.googlesource.com/c/go/+/2520
Part-of #32
Based on #35 for more correct benchmarks.