Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change ddsketch mapping to improve performance. (#11561)
**What this PR does / why we need it**: We've found that the index mapping of our quantile over time approximation has a big impact on the CPU. Changing the implementation gives us around 50%. The mapping is used during the `At` calls to the iterator. ``` › benchstat logarithmic.log cubic.log sort.log pool.log goos: linux goarch: amd64 pkg: github.com/grafana/loki/pkg/logql cpu: AMD Ryzen 7 3700X 8-Core Processor │ logarithmic.log │ cubic.log │ sort.log │ pool.log │ │ sec/op │ sec/op vs base │ sec/op vs base │ sec/op vs base │ QuantileBatchRangeVectorIteratorAt/1-samples-16 819.7n ± 2% 1052.5n ± 5% +28.40% (p=0.002 n=6) 1055.0n ± 1% +28.71% (p=0.002 n=6) 303.7n ± 4% -62.96% (p=0.002 n=6) QuantileBatchRangeVectorIteratorAt/1000-samples-16 60.34µ ± 8% 49.32µ ± 13% -18.26% (p=0.002 n=6) 45.94µ ± 4% -23.86% (p=0.002 n=6) 24.97µ ± 3% -58.61% (p=0.002 n=6) QuantileBatchRangeVectorIteratorAt/100000-samples-16 3.032m ± 3% 1.319m ± 1% -56.50% (p=0.002 n=6) 1.316m ± 4% -56.58% (p=0.002 n=6) 1.278m ± 3% -57.86% (p=0.002 n=6) geomean 53.13µ 40.91µ -23.00% 39.96µ -24.79% 21.32µ -59.87% │ logarithmic.log │ cubic.log │ sort.log │ pool.log │ │ B/op │ B/op vs base │ B/op vs base │ B/op vs base │ QuantileBatchRangeVectorIteratorAt/1-samples-16 368.00 ± 0% 368.00 ± 0% ~ (p=1.000 n=6) ¹ 368.00 ± 0% ~ (p=1.000 n=6) ¹ 32.00 ± 0% -91.30% (p=0.002 n=6) QuantileBatchRangeVectorIteratorAt/1000-samples-16 4048.0 ± 0% 4048.0 ± 0% ~ (p=1.000 n=6) ¹ 3920.0 ± 0% -3.16% (p=0.002 n=6) 104.0 ± 0% -97.43% (p=0.002 n=6) QuantileBatchRangeVectorIteratorAt/100000-samples-16 6192.0 ± 0% 6192.0 ± 0% ~ (p=1.000 n=6) ¹ 5936.0 ± 0% -4.13% (p=0.002 n=6) 202.0 ± 5% -96.74% (p=0.002 n=6) geomean 2.048Ki 2.048Ki +0.00% 1.998Ki -2.45% 87.60 -95.82% ¹ all samples are equal │ logarithmic.log │ cubic.log │ sort.log │ pool.log │ │ allocs/op │ allocs/op vs base │ allocs/op vs base │ allocs/op vs base │ QuantileBatchRangeVectorIteratorAt/1-samples-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=6) ¹ 8.000 ± 0% ~ (p=1.000 n=6) ¹ 2.000 ± 0% -75.00% (p=0.002 n=6) QuantileBatchRangeVectorIteratorAt/1000-samples-16 27.000 ± 0% 27.000 ± 0% ~ (p=1.000 n=6) ¹ 23.000 ± 0% -14.81% (p=0.002 n=6) 5.000 ± 0% -81.48% (p=0.002 n=6) QuantileBatchRangeVectorIteratorAt/100000-samples-16 42.000 ± 0% 42.000 ± 0% ~ (p=1.000 n=6) ¹ 34.000 ± 0% -19.05% (p=0.002 n=6) 9.000 ± 0% -78.57% (p=0.002 n=6) geomean 20.86 20.86 +0.00% 18.43 -11.65% 4.481 -78.51% ¹ all samples are equal ``` **Checklist** - [ ] Reviewed the [`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md) guide (**required**) - [ ] Documentation added - [x] Tests updated - [ ] `CHANGELOG.md` updated - [ ] If the change is worth mentioning in the release notes, add `add-to-release-notes` label - [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/setup/upgrade/_index.md` - [ ] For Helm chart changes bump the Helm chart version in `production/helm/loki/Chart.yaml` and update `production/helm/loki/CHANGELOG.md` and `production/helm/loki/README.md`. [Example PR](d10549e) - [ ] If the change is deprecating or removing a configuration option, update the `deprecated-config.yaml` and `deleted-config.yaml` files respectively in the `tools/deprecated-config-checker` directory. [Example PR](0d4416a)
- Loading branch information