This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Fix severe compression bug introduced by #97 #99
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
weihanglo
reviewed
Sep 17, 2022
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.
Nice rework! I am fine with lowering brotli compression level.
Just some nits, nothing prominent so far. Thank you!
Co-authored-by: Weihang Lo <[email protected]>
weihanglo
reviewed
Sep 17, 2022
Co-authored-by: Weihang Lo <[email protected]>
weihanglo
approved these changes
Sep 17, 2022
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.
Thank you for getting this job done!
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
closes #98
How to reproduce
x.txt
.cargo run
curl --compressed http://localhost:5000/x.txt
A error like
curl: (23) Failed reading the chunked-encoded stream
will occur and only first 4KB content of file will be returned.Root cause
sfz/src/server/serve.rs
Lines 416 to 419 in 70b431a
Maybe the body stream isn't split like how I expected, so only the first item of stream get compressed and returned then the rest are dropped. Since the buffer of file stream is 4KB, it might explain why only the first 4KB will be returned:
sfz/src/server/send.rs
Line 160 in 70b431a
Solution
compress
withasync-compression
.2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 5.45ms 2.20ms 23.10ms 72.66%
Req/Sec 0.93k 79.59 1.06k 70.00%
18434 requests in 10.01s, 18.09MB read
Requests/sec: 1841.70
Transfer/sec: 1.81MB
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 2.97ms 1.09ms 19.27ms 69.77%
Req/Sec 1.70k 110.24 3.07k 96.52%
33932 requests in 10.10s, 38.96MB read
Requests/sec: 3359.58
Transfer/sec: 3.86MB
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.30s 432.24ms 1.79s 76.92%
Req/Sec 4.71 3.89 20.00 78.57%
68 requests in 10.01s, 16.04MB read
Socket errors: connect 0, read 0, write 0, timeout 3
Requests/sec: 6.79
Transfer/sec: 1.60MB
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 880.53ms 337.25ms 1.51s 68.52%
Req/Sec 6.25 4.69 30.00 89.47%
108 requests in 10.01s, 42.28MB read
Requests/sec: 10.78
Transfer/sec: 4.22MB