Skip to content
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 reading responses #3

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

jamesponddotco
Copy link
Collaborator

@jamesponddotco jamesponddotco commented Jan 15, 2024

What does this PR do?

Replaces io.ReadAll with io.Copy and a preallocated buffer, which decreases the number of allocations and usage happening in this portion of the code by up to 50%.

This is a big win for extremelly large diagrams, while causing no issues with small diagrams.

Review checklist

Please check relevant items below:

  • The title & description contain a short meaningful summary of work completed.
  • Tests have been updated/created and are passing locally.
  • I've reviewed the CONTRIBUTING.md file.

Using io.Copy instead of io.ReadAll we reduce memory usage by about 50%.

Signed-off-by: James Pond <[email protected]>
Signed-off-by: James Pond <[email protected]>
@jamesponddotco jamesponddotco added the enhancement New feature or request label Jan 15, 2024
@jamesponddotco jamesponddotco requested a review from a team January 15, 2024 15:38
@jamesponddotco jamesponddotco self-assigned this Jan 15, 2024
@jamesponddotco jamesponddotco merged commit 066a78f into trunk Jan 16, 2024
7 checks passed
@jamesponddotco jamesponddotco deleted the james.pond/optimize-read-response branch January 16, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants