feat: add DDSketch quantile#56342
Conversation
|
@SmitaRKulkarni I had to close this #55305 because of a messed up rebase. Please review this instead. I added the docs and address comments from the other PR |
|
I would appreciate it if someone could trigger workflows. |
|
This is an automated comment for commit 068f6e2 with description of existing statuses. It's updated for the latest CI running ⏳ Click here to open a full report in a separate page Successful checks
|
How can I get the fuzzer to pass a reasonable relative accuracy? The value |
It looks like the msan fuzzer builds indicate possible memory violations here: src/AggregateFunctions/QuantileDDSketch.h:25 and here src/AggregateFunctions/QuantileDDSketch.h:31. |
They are failing because the passed relative accuracy is too low which demands bins beyond allocatable and program crashes. If you change the relative accuracy to a reasonable value it works without crashing. |
|
QuantileBFloat16 test is failing for ubsan, ParallelReplicas and QuantileDDSketch if failing for ubsan. It seems like a timeout. How can I troubleshoot or are they occasional intermittent failures? |
|
I will resolve the conflicts |
I think QuantileBFloat16 test failure is un-related, it's failing because its not able to connect to the server (likely the server has crashed from the other test failure.) The main error seems to be the following Possible overflows are happening here during addition. Probably, the easiest way is to fix is to use |
|
@bharatnc Thanks, that was helpful. I saw other files but didn't pay attention to |
I would do something like this: https://pastila.nl/?0052513d/409c97e2bb061b060eacf41ae73ceae2#IkYx5MhJoZnbPjohZ4NQNw== (untested), on the off chance you're in the mood for rewriting everything. |
I will give it a try. If you believe it could improve the performance by multifold I want to give it a try. |
To give some clarity on this, I was trying to keep the state compatible with the DDSketch proto https://github.com/DataDog/sketches-java/blob/master/src/protobuf/proto/DDSketch.proto. The clickHouse-go client would directly write the rows with the compatible serialized state. This will enable ingesting the pre-aggregated sketches (usually on the web service application) and then computing percentiles at the query time. |
Cool! Hack a quick prototype first, to check if it's really fast enough to be worth rewriting the rest. (Though it's also less code, so might be worth rewriting even if not much faster, but that's less important and more subjective.) |
Makes sense, please add a comment about it in the code, with the link. Otherwise it just looks like random crazy overengineering tbh :) |
|
@al13n321 I tried the suggestion in a separate branch and it improved the performance by ~20%. And then I revisited your comment here about the virtual functions #56342 (comment). The last time when I added |
|
I started looking into small object optimization. Is it okay if that is addressed in the follow-up PR? This has gone through many changes at this point and has been reviewed. Since it will be an enhancement that doesn't break anything, I think it's better to address it in a follow-up PR without adding more new changes to this already reviewed PR. Let me know what do you think? |
|
@srikanthccv, totally ok. |
|
Looks mergable, except for the fuzzer failure from before: https://s3.amazonaws.com/clickhouse-test-reports/56342/b55529b5850abc4cc3578b96582c92476c1b558a/fuzzer_astfuzzerubsan/report.html - did you explain or fix it? It didn't happen this time, but I don't see anything that looks like a fix, so it's probably not fixed and will come back. Maybe try to reproduce it by running the last few queries with substring "DDSketch" from |
|
hmm, I posted a comment before resolved but it seems to have been not delivered. @al13n321 The commit I made which caused the overflow was an incorrect change and shouldn't have been committed. Here is what happened. The |
All requested things are done.
|
@al13n321 @alexey-milovidov @bharatnc Thanks for the reviews and help. I will send a follow-up PR for small object optimization after testing against the ClickBench data. |
Fixes #6739
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add
quantileDDSketchaggregate function as well as the correspondingquantilesDDSketchandmedianDDSketch. It is based on the DDSketch https://www.vldb.org/pvldb/vol12/p2195-masson.pdf.Documentation entry for user-facing changes
Documentation is written (mandatory for new features)
Motivation: It is very important to calculate accurate quantiles fast. The OpenTelemetry project is the emerging standard in the observability ecosystem, and the preferred way to record the latencies is
ExponentialHistogram. Having this feature in ClickHouse makes it more adaptable.Parameters: relative accuracy
Example use: