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

Change batch size calculation from message count to message size #388

Conversation

LucioDonda
Copy link
Member

@LucioDonda LucioDonda commented Dec 4, 2024

Related issue
closes #385

Description

After implementing the configuration options for event batching (#306), we need to change the way we build the batch. Instead of specifying batch_size as the number of messages we want to retrieve from the queue to build the message batch, we want to specify the batch size in bytes.

The mechanism that the communicator component uses to retrieve messages needs to be changed, as it will now need to calculate the size of each message when creating the batch.

Configuration options

For this, the already implemented batch_size setting will be used, but will accept the following values ​​instead:

events:
  batch_size: "1M"       # Maximum size of a batch (default: 1 MiB).

Details:

  • Specifies the maximum batch size in bytes.
  • Accepts values with size units: "1024B", "10K", "100M", "1G".
  • Valid range: "1000B" to "100M".

Tests

  • Compilation without warnings in every supported platform
    • Linux

@LucioDonda LucioDonda linked an issue Dec 4, 2024 that may be closed by this pull request
@LucioDonda LucioDonda linked an issue Dec 4, 2024 that may be closed by this pull request
@LucioDonda LucioDonda force-pushed the enhancement/385-change-batch-size-calculation-from-message-count-to-message-size branch 4 times, most recently from 54f39c2 to 54e4f50 Compare December 10, 2024 20:07
@LucioDonda LucioDonda requested a review from cborla December 10, 2024 20:13
@LucioDonda LucioDonda marked this pull request as ready for review December 10, 2024 20:13
@LucioDonda LucioDonda force-pushed the enhancement/385-change-batch-size-calculation-from-message-count-to-message-size branch from 72baa17 to 7455be2 Compare December 10, 2024 21:11
Copy link
Member

@vikman90 vikman90 left a comment

Choose a reason for hiding this comment

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

@LucioDonda Can you clarify why these errors are happening?

On the other hand, please confirm that the maximum proposed batch size matches the maximum body size that the server would accept.

@LucioDonda LucioDonda force-pushed the enhancement/385-change-batch-size-calculation-from-message-count-to-message-size branch 2 times, most recently from 5b109f0 to 019468e Compare December 11, 2024 14:01
@LucioDonda LucioDonda marked this pull request as draft December 11, 2024 15:36
@LucioDonda LucioDonda force-pushed the enhancement/385-change-batch-size-calculation-from-message-count-to-message-size branch 5 times, most recently from c09cfd7 to c21cc9a Compare December 12, 2024 21:16
@LucioDonda LucioDonda marked this pull request as ready for review December 12, 2024 21:40
@LucioDonda LucioDonda force-pushed the enhancement/385-change-batch-size-calculation-from-message-count-to-message-size branch from 898109b to 19556a0 Compare December 18, 2024 14:04
@LucioDonda LucioDonda force-pushed the enhancement/385-change-batch-size-calculation-from-message-count-to-message-size branch 3 times, most recently from 7f944d6 to f60dd92 Compare December 18, 2024 19:21
@LucioDonda LucioDonda force-pushed the enhancement/385-change-batch-size-calculation-from-message-count-to-message-size branch from f60dd92 to 40885d3 Compare December 18, 2024 19:23
Copy link
Member

@jr0me jr0me left a comment

Choose a reason for hiding this comment

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

LGTM!

{
if constexpr (std::is_convertible_v<decltype(key), std::string_view>)
{
// This is a workaround for parsing size units
Copy link
Member

Choose a reason for hiding this comment

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

Please, open an issue to improve this.

Copy link
Member Author

Choose a reason for hiding this comment

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

@TomasTurina Issue created : #447

@TomasTurina TomasTurina merged commit 1eb2738 into master Dec 18, 2024
5 checks passed
@TomasTurina TomasTurina deleted the enhancement/385-change-batch-size-calculation-from-message-count-to-message-size branch December 18, 2024 20:55
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.

Change batch size calculation from message count to message size
6 participants