-
Notifications
You must be signed in to change notification settings - Fork 273
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
Fix compression for deferred responses #2986
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
so this will be measured by CI benchmarks and serve as baseline for upcoming changes
This comment has been minimized.
This comment has been minimized.
This integrates the encoders from https://github.com/Nemo157/async-compression so we can use them other a stream that flushes data regularly
this makes an assumption that async-commpression cannot make: every chunk in the body stream has to be compressed and flushed directly, we should not wait for more data to come and get better compression. This is due to the multipart protocol for defer: we know each chunk represent eitehr the primary or a deferred response, and should be sent as soon as possible
bnjjj
reviewed
Apr 26, 2023
Co-authored-by: Jeremy Lempereur <jeremy.lempereur@iomentum.com>
bnjjj
approved these changes
Apr 27, 2023
This was referenced May 3, 2023
Merged
Merged
4 tasks
abernix
pushed a commit
that referenced
this pull request
May 5, 2023
1.17.0 sometimes panicked when doing gzip response encoding. The write head for the buffer was being extended by the total amount written so far (instead of the amount written by the current iteration). Rather than just remove the `+` in `written += ...` I thought it would be more ergonomic to add the required method to the `PartialBuffer`. Co-authored-by: Dylan Anthony <dbanty@users.noreply.github.com> Co-authored-by: Jesse Rosenberger <git@jro.cc> Co-authored-by: Geoffroy Couprie <apollo@geoffroycouprie.com> Ref: #2986
garypen
pushed a commit
that referenced
this pull request
May 10, 2023
1.17.0 sometimes panicked when doing gzip response encoding. The write head for the buffer was being extended by the total amount written so far (instead of the amount written by the current iteration). Rather than just remove the `+` in `written += ...` I thought it would be more ergonomic to add the required method to the `PartialBuffer`. Co-authored-by: Dylan Anthony <dbanty@users.noreply.github.com> Co-authored-by: Jesse Rosenberger <git@jro.cc> Co-authored-by: Geoffroy Couprie <apollo@geoffroycouprie.com> Ref: #2986
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.
Fix #1572
We replace tower-http's
CompressionLayer
with a custom stram transformation. This is necessary becauyse tower-http uses async-compression, which buffers data until the end of the stream to then write it, ensuring a better compression. This is incompatible with defer's multipart protocol, which requires chunks to be sent as soon as possible. So we need to compress them independently.This extracts parts of the codec module of async-compression, which so far is not public, and makes the streaming wrapper above it. Most of the PR is made from that code, the interesting parts are in
apollo-router/src/axum_factory/axum_http_server_factory.rs
andapollo-router/src/axum_factory/compression/mod.rs
Checklist
Complete the checklist (and note appropriate exceptions) before a final PR is raised.
Exceptions
Note any exceptions here
Notes
[^1]. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.
[^2]. Configuration is an important part of many changes. Where applicable please try to document configuration examples.
[^3]. Tick whichever testing boxes are applicable. If you are adding Manual Tests:
- please document the manual testing (extensively) in the Exceptions.
- please raise a separate issue to automate the test and label it (or ask for it to be labeled) as
manual test