Skip to content

Conversation

@edgurgel
Copy link

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.

We have been using this for months in production 👍 . It's specially useful when casts are batched with max_batch_size > 0

@ieQu1
Copy link
Member

ieQu1 commented Dec 23, 2025

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 compression_threshold = 0.

@edgurgel
Copy link
Author

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 compression_threshold = 0.

Yup I can do that!

From our benchmarks erlang:external_size/1 was extremely fast for small objects so as long as the threshold was not huge like a few megabytes it was not noticeable

{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 ->
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! 4241656


do_term_to_iovec(Term, Compress) when is_integer(Compress), Compress >= 1 ->
{ok, CompressionThreshold} = application:get_env(?APP, compression_threshold),

Copy link
Member

@ieQu1 ieQu1 Dec 25, 2025

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! 4241656

edgurgel and others added 4 commits January 23, 2026 13:24
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.
@edgurgel
Copy link
Author

Ok! I've rebased the branch with master and I think I've addressed all comments 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants