-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
copy: avoid recopying buffer #106088
Merged
Merged
copy: avoid recopying buffer #106088
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
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
4 tasks
Release note: None
Use a []byte instead of a bytes.Buffer, so that we only move the cursor into the buffer if we know we want to advance. This provides a 25% reduction in allocations in BenchmarkCopyCSVEndToEnd. ``` goos: darwin goarch: arm64 │ /var/folders/p3/c61_z_vd3r7dr1_hnztm3ryr0000gq/T/tmp.Dm00yAlG6O/bench.a51e8a7806c │ /var/folders/p3/c61_z_vd3r7dr1_hnztm3ryr0000gq/T/tmp.Dm00yAlG6O/bench.0c9d3d5efb0 │ │ sec/op │ sec/op vs base │ CopyCSVEndToEnd-10 3.991 ± 3% 3.883 ± 2% -2.71% (p=0.019 n=10) │ /var/folders/p3/c61_z_vd3r7dr1_hnztm3ryr0000gq/T/tmp.Dm00yAlG6O/bench.a51e8a7806c │ /var/folders/p3/c61_z_vd3r7dr1_hnztm3ryr0000gq/T/tmp.Dm00yAlG6O/bench.0c9d3d5efb0 │ │ B/op │ B/op vs base │ CopyCSVEndToEnd-10 8.322Gi ± 2% 8.304Gi ± 1% ~ (p=0.971 n=10) │ /var/folders/p3/c61_z_vd3r7dr1_hnztm3ryr0000gq/T/tmp.Dm00yAlG6O/bench.a51e8a7806c │ /var/folders/p3/c61_z_vd3r7dr1_hnztm3ryr0000gq/T/tmp.Dm00yAlG6O/bench.0c9d3d5efb0 │ │ allocs/op │ allocs/op vs base │ CopyCSVEndToEnd-10 18.30M ± 0% 13.79M ± 0% -24.62% (p=0.000 n=10) ``` Release note: None
otan
approved these changes
Jul 7, 2023
tftr! bors r+ |
Build succeeded: |
Thanks! Really nice improvement. |
craig bot
pushed a commit
that referenced
this pull request
Jul 18, 2023
106056: cli,sql: improve userfile upload performance r=adityamaru a=stevendanna This PR is a serious of changes to improve the performance of userfile uploads. See the individual commits for details. The performance of uploading a 64 MB file improves substantially with these changes: ``` Before: BenchmarkUserfileUpload-16 1 13537820708 ns/op 4.96 MB/s 37239761608 B/op 1311062 allocs/op After: BenchmarkUserfileUpload-16 1 2135076152 ns/op 31.43 MB/s 2460613480 B/op 551130 allocs/op ``` - [x] Avoid buffering entire file during upload on the CLI-side - [x] Avoid quadratic behaviour when searching for line endings (`@rafiss` fixed in #106088, thanks!) - [x] Tests for escapingReader - [x] Benchmark Co-authored-by: Steven Danna <[email protected]>
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 a []byte instead of a bytes.Buffer, so that we only move the cursor into the buffer if we know we want to advance.
This provides a 25% reduction in allocations in BenchmarkCopyCSVEndToEnd.
Epic: None
Release note: None