Skip to content

Dynamic send #276

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

Merged
merged 12 commits into from
Feb 26, 2025
Merged

Dynamic send #276

merged 12 commits into from
Feb 26, 2025

Conversation

allevo
Copy link
Collaborator

@allevo allevo commented Feb 19, 2025

This PR implements a new method to send a message:

  • batch_send follows the same flow as send
  • every message is queued on a dedicated Tokio task and sent asynchronously
  • if the internal producer is closed, the task stops to send
  • remove batch_publishing_delay params (breaking)
  • put integration tests under tests to avoid parallel execution. Parallel execution causes problems running the tests locally due to the limitation of the OS file description number.
  • fix typo on method (publising_id -> publishing_id) (breaking)
  • add an hardcoded timeout (1sec) to send_with_confirm

I introduced also a bin to calculate the latency performance to proof the improvement on low send rate. The bin creates a producer and a consumer. Every minute, 50 messages with the current timestamp are sent to RabbitMQ and the consumer store the metric. Every minute, a log is printed with the statistics.

Before this PR:

$ cargo run --release --bin perf-producer
stats: Stats { average_latency: 59.54067, messages_received: 3000 }
stats: Stats { average_latency: 62.840668, messages_received: 3000 }
stats: Stats { average_latency: 58.391335, messages_received: 3000 }
stats: Stats { average_latency: 58.668335, messages_received: 3000 }

After this PR:

$ cargo run --release --bin perf-producer
stats: Stats { average_latency: 5.1963334, messages_received: 3000 }
stats: Stats { average_latency: 5.195667, messages_received: 3000 }
stats: Stats { average_latency: 5.288, messages_received: 3000 }
stats: Stats { average_latency: 5.148667, messages_received: 3000 }

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 42.40000% with 144 lines in your changes missing coverage. Please review.

Project coverage is 89.00%. Comparing base (be36db2) to head (38b956a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/bin/perf-producer.rs 0.00% 132 Missing ⚠️
src/producer.rs 89.58% 10 Missing ⚠️
src/client/mod.rs 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #276      +/-   ##
==========================================
- Coverage   90.17%   89.00%   -1.17%     
==========================================
  Files          80       81       +1     
  Lines        7390     7541     +151     
==========================================
+ Hits         6664     6712      +48     
- Misses        726      829     +103     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@allevo allevo marked this pull request as ready for review February 19, 2025 13:39
@@ -66,3 +66,6 @@ path="examples/superstreams/send_super_stream.rs"
name="environment_deserialization"
path="examples/environment_deserialization.rs"

[[bin]]
name = "perf-producer"
path = "src/bin/perf-producer.rs"
Copy link
Contributor

Choose a reason for hiding this comment

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

As this file is doing perf-tests any possibility to move it in the tests folder? (maybe creating a folder like performances)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have different possibilities:

  • put it under bench folder where, typically, you put performance tests, commonly developed with criterion crate. Anyway, this actually isn't a benchmark in the same sense of criterion which invokes the function multiple time and measure the duration.
  • put it under tests folder and threat it as a integration test. Anyway, as a test, the output is not shown to the developer without the appropriate flag (--nocapture).
  • put it under bin and threat is as a binary, as in this PR. You can run it using cargo run --release --bin perf-producer and print the output easily.

Anyway, I don't have a strong opinion on that and I can follow a different solution. let me know how you want to proceed.

Copy link
Contributor

@DanielePalaia DanielePalaia Feb 25, 2025

Choose a reason for hiding this comment

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

I don't have a strong opinion too. As a preference I would choose the bench folder. It can be also useful in case in the future we want to add other performance tests and group them together

Copy link
Contributor

@DanielePalaia DanielePalaia left a comment

Choose a reason for hiding this comment

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

Looks good to me! @wolf4ood If you want to do a final validation too!

@Gsantomaggio
Copy link
Member

This is not relevant, but is there a way to increase the code coverage?

@Gsantomaggio Gsantomaggio merged commit 9afa930 into rabbitmq:main Feb 26, 2025
1 of 3 checks passed
@Gsantomaggio
Copy link
Member

Thanks a lot @allevo @DanielePalaia

@github-actions github-actions bot mentioned this pull request Feb 26, 2025
@github-actions github-actions bot mentioned this pull request Apr 18, 2025
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.

3 participants