Evgeny Kuvardin created KAFKA-21755:
---------------------------------------
Summary: Reduce redundant scans in SampledStat
Key: KAFKA-21755
URL: https://issues.apache.org/jira/browse/KAFKA-21755
Project: Kafka
Issue Type: Improvement
Reporter: Evgeny Kuvardin
Assignee: Evgeny Kuvardin
In Kafka's {{{}RateLimiter{}}}, we primarily use the {{SampledStat}} class.
We can optimize it as follows:
1. public Sample oldest(long now) - remember old snapshot and not iterate
over all interval
We can get significant performance on sample count >=20
2. After a purge, remember the earliest possible next expiration. Until that
time, another purge cannot remove anything, so it can return immediately.
3. Borrow subtract on eviction for WindowedSum.
After some research we can do follow
- Recording updates the current sample and a retained total.
- Expiring or recycling a sample subtracts its contribution.
- Measurement reads the total instead of summing all samples.
Benchmarks should demonstrate that the new implementation improves performance
with sample sizes ranging from 5 to 100.
A reasonable upper limit for typical usage is 100 samples.
Additionally, benchmarks should run with 1,000 samples to identify potential
corner cases and ensure that the new implementation does not suffer from
performance degradation as the number of samples increases.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)