thanos-io / promql-engine

Multi-threaded PromQL engine implementation based on the Volcano paper.
Apache License 2.0
133 stars 52 forks source link

Fix resizing rate buffer tail #393

Closed fpetkovski closed 6 months ago

fpetkovski commented 6 months ago

We use a single slice to rotate buffers for matrix selectors in order to reuse memory. Sizing the slice is done using slices.Grow, but this method does not ensure exact capacity, it only guarantees that the slice will have at least the requested capacity.

To fix the issue, we need to use a subslice explicitly. We saw this issue in production with native histogram queries and it's not easy to reproduce with a test.

fpetkovski commented 6 months ago

We do not seem to be using this technique for the ext function because it's still not implemented for native histograms. The idea of buffer rotation is to reuse histogram objects, which we ignore for x functions.