-
Notifications
You must be signed in to change notification settings - Fork 22
feat: implement optional compression based on threshold #54
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
base: master
Are you sure you want to change the base?
Conversation
eb7f8bd to
3b761cd
Compare
3b761cd to
05d2ae3
Compare
|
I wonder if " Size = erlang:external_size(Term)" line can penalize performance when sending a lot of small objects. Maybe this calculation can be omitted when |
Yup I can do that! From our benchmarks |
src/gen_rpc_helper.erl
Outdated
| {ok, Compress} = application:get_env(?APP, compress), | ||
| do_term_to_iovec(Term, Compress). | ||
|
|
||
| do_term_to_iovec(Term, Compress) when is_integer(Compress), Compress >= 1 -> |
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.
Please move this function to "Private functions" section.
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.
Done! 4241656
src/gen_rpc_helper.erl
Outdated
|
|
||
| do_term_to_iovec(Term, Compress) when is_integer(Compress), Compress >= 1 -> | ||
| {ok, CompressionThreshold} = application:get_env(?APP, compression_threshold), | ||
|
|
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.
Please remove empty lines in the function bodies or replace them with comments.
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.
Done! 4241656
Two new options: * compress: A number (default = 0) from 0 to 9 to define level of compression. * compression_threshold: The minimum amount of bytes (default = 1024) needed to be worth compressing the TCP message sent.
Co-authored-by: ieQu1 <[email protected]>
4241656 to
7ff7b63
Compare
|
Ok! I've rebased the branch with master and I think I've addressed all comments 🙇 |
7ff7b63 to
b3fe872
Compare
Two new options:
We have been using this for months in production 👍 . It's specially useful when casts are batched with
max_batch_size > 0