InCerryGit opened a new pull request, #724:
URL: https://github.com/apache/rocketmq-clients/pull/724
<!-- Please make sure the target branch is right. In most case, the target
branch should be `master`. -->
### Which Issue(s) This PR Fixes
Optimization message id generator performance.
### Brief Description
We are using RocketMQ for high-throughput message sending and receiving and
have identified some performance bottlenecks. This is one of a series of
performance optimization pull requests aimed at improving the efficiency of the
message ID generator. Based on the following benchmark tests, we can conclude
that there has been an approximate 50% reduction in time consumption and a 70%
reduction in memory usage.
```
BenchmarkDotNet v0.13.12, Windows 11
(10.0.22631.3296/23H2/2023Update/SunValley3)
Intel Core i7-14700K, 1 CPU, 28 logical and 20 physical cores
.NET SDK 8.0.202
[Host] : .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.3 (8.0.324.11423), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Gen0 | Allocated |
|----------- |---------:|---------:|---------:|-------:|----------:|
| Next | 35.24 ns | 0.274 ns | 0.243 ns | 0.0088 | 152 B |
| BeforeNext | 72.86 ns | 0.567 ns | 0.502 ns | 0.0426 | 736 B |
```
Additionally, the strong dependency of the MessageIdGenerator on time has
been decoupled by using the TimeProvider from the .NET base class library. The
abstraction of IUtilities decouples the strong dependency on the Utilities
static class, facilitating better unit testing and ensuring code quality.
### How Did You Test This Change?
Unit tests were created using the same parameters to record the Ids
generated by the old Next method, to compare and verify the consistency between
the new and old result methods.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]