Use a single array for buffering rate data points#140855
Use a single array for buffering rate data points#140855dnhatn merged 11 commits intoelastic:mainfrom
Conversation
371d577 to
0c5a312
Compare
a1262fb to
d49c6bd
Compare
|
Buildkite benchmark this with tsdb-metricsgen-240m-highcardinality please |
💚 Build Succeeded
This build ran two tsdb-metricsgen-240m-highcardinality benchmarks to evaluate performance impact of this PR. History |
|
Hi @dnhatn, I've created a changelog YAML for you. |
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
| } | ||
|
|
||
| final void prepareSlicesOnly(int groupId, long firstTimestamp) { | ||
| if (valueCount > 0 && sliceGroupIds.get(sliceCount - 1) == groupId) { |
There was a problem hiding this comment.
Naive question: is there an issue if sliceCount is 0?
There was a problem hiding this comment.
I see, it gets incremented on the first value. Maybe an assert would help, just a nit.
...ompute/src/main/java/org/elasticsearch/compute/aggregation/AbstractRateGroupingFunction.java
Outdated
Show resolved
Hide resolved
...ompute/src/main/java/org/elasticsearch/compute/aggregation/AbstractRateGroupingFunction.java
Outdated
Show resolved
Hide resolved
...ompute/src/main/java/org/elasticsearch/compute/aggregation/AbstractRateGroupingFunction.java
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/compute/aggregation/X-RateGroupingAggregatorFunction.java.st
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/compute/aggregation/X-RateGroupingAggregatorFunction.java.st
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/compute/aggregation/X-RateGroupingAggregatorFunction.java.st
Show resolved
Hide resolved
.../generated-src/org/elasticsearch/compute/aggregation/RateLongGroupingAggregatorFunction.java
Show resolved
Hide resolved
kkrik-es
left a comment
There was a problem hiding this comment.
Good job, Nhat. This should be faster, and it'll show up more once we reduce the other overheads.
…pute/aggregation/AbstractRateGroupingFunction.java Co-authored-by: Kostas Krikellas <131142368+kkrik-es@users.noreply.github.com>
…pute/aggregation/AbstractRateGroupingFunction.java Co-authored-by: Jonas Kunz <j+github@kunzj.de>
|
@kkrik-es @JonasKunz Thanks for the review! |
|
@kkrik-es @JonasKunz I did another round of benchmarking. I think this change reduced the query time of |
This change switches to a single array for buffering data points in rate aggregation, providing several benefits: 1. Minimal memory waste: Previously, each group over-allocated 1/8 or an extra page of the required memory to minimize allocations. For example, with 10,000 time series and 30 time-buckets each, this could reserve an extra 10,000 * 30 * 16,384 = 4,915,200,000 bytes (~4.9GB), and with 8 concurrent drivers, up to 40GB of extra memory. 2. Fewer objects, making it more GC-friendly. 3. Easier future disk spill: With a single array, spilling the initial pages to disk is easier to implement. This approach may result in more "slices" than before, since slices cannot be combined across segments. However, the slice merging process has been improved to reduce this overhead. Performance tests with 100 hosts (270 million data points) show a 10% reduction in rate_1h response time (from 420ms to 380ms), though performance was not the primary goal of this change.
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
This change switches to a single array for buffering data points in rate aggregation, providing several benefits: 1. Minimal memory waste: Previously, each group over-allocated 1/8 or an extra page of the required memory to minimize allocations. For example, with 10,000 time series and 30 time-buckets each, this could reserve an extra 10,000 * 30 * 16,384 = 4,915,200,000 bytes (~4.9GB), and with 8 concurrent drivers, up to 40GB of extra memory. 2. Fewer objects, making it more GC-friendly. 3. Easier future disk spill: With a single array, spilling the initial pages to disk is easier to implement. This approach may result in more "slices" than before, since slices cannot be combined across segments. However, the slice merging process has been improved to reduce this overhead. Performance tests with 100 hosts (270 million data points) show a 10% reduction in rate_1h response time (from 420ms to 380ms), though performance was not the primary goal of this change. (cherry picked from commit 5c1521c)
This change switches to a single array for buffering data points in rate aggregation, providing several benefits: 1. Minimal memory waste: Previously, each group over-allocated 1/8 or an extra page of the required memory to minimize allocations. For example, with 10,000 time series and 30 time-buckets each, this could reserve an extra 10,000 * 30 * 16,384 = 4,915,200,000 bytes (~4.9GB), and with 8 concurrent drivers, up to 40GB of extra memory. 2. Fewer objects, making it more GC-friendly. 3. Easier future disk spill: With a single array, spilling the initial pages to disk is easier to implement. This approach may result in more "slices" than before, since slices cannot be combined across segments. However, the slice merging process has been improved to reduce this overhead. Performance tests with 100 hosts (270 million data points) show a 10% reduction in rate_1h response time (from 420ms to 380ms), though performance was not the primary goal of this change. (cherry picked from commit 5c1521c)
This change switches to a single array for buffering data points in rate aggregation, providing several benefits:
Minimal memory waste: Previously, each group over-allocated 1/8 or an extra page of the required memory to minimize allocations. For example, with 10,000 time series and 30 time-buckets each, this could reserve an extra 10,000 * 30 * 16,384 = 4,915,200,000 bytes (~4.9GB), and with 8 concurrent drivers, up to 40GB of extra memory.
Fewer objects, making it more GC-friendly.
Easier future disk spill: With a single array, spilling the initial pages to disk is easier to implement.
This approach may result in more "slices" than before, since slices cannot be combined across segments. However, the slice merging process has been improved to reduce this overhead.
Performance tests with 100 hosts (270 million data points) show a 10% reduction in rate_1h response time (from 420ms to 380ms), though performance was not the primary goal of this change.