Skip to content

feat(tdigest): Add support for QUANTILE command #2849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: unstable
Choose a base branch
from

Conversation

SharonIV0x86
Copy link
Contributor

Closes #2794

This PR adds support for TDIGEST.QUANTILE command.

@SharonIV0x86 SharonIV0x86 marked this pull request as ready for review March 30, 2025 17:51
@SharonIV0x86
Copy link
Contributor Author

SharonIV0x86 commented Mar 30, 2025

@LindaSummer I have added the basic structure for the QUANTILE command but as you mentioned in the issue, there seems to be a problem with the locking mechanism or something else.

E20250330 23:50:42.491079 130596879718080 redis_tdigest.cc:524] metadata has 24 merged nodes, but got 4

I tried modifying the quantile function as mentioned in the issue and the previous PRs but the issue persists. Any help is appreciated.

@LindaSummer
Copy link
Contributor

LindaSummer commented Apr 1, 2025

Hi @SharonIV0x86 ,

Thanks very much for effort!😊

I'll try to test it in local in recent days and will sync if there is any new updates.

Best Regards,
Edward

@SharonIV0x86
Copy link
Contributor Author

Hi @SharonIV0x86 ,

Thanks very much for effort!😊

I'll try to test it in local in recent days and will sync if there is any new updates.

Best Regards, Edward

Works, till then ill try to fiddle around. Cheers.

@LindaSummer
Copy link
Contributor

Hi @SharonIV0x86 ,

Sorry for delay of updating. 😊

In recent I have some personal affairs which occupied my schedule so maybe a little delay in response.

I'm now working on this ticket and find that there may be some bugs inside it. I will double confirm it and create a PR to fix it if bug exists.

Best Regards,
Edward

@SharonIV0x86
Copy link
Contributor Author

Hi @SharonIV0x86 ,

Sorry for delay of updating. 😊

In recent I have some personal affairs which occupied my schedule so maybe a little delay in response.

I'm now working on this ticket and find that there may be some bugs inside it. I will double confirm it and create a PR to fix it if bug exists.

Best Regards, Edward

No issues, meanwhile i tried looking into it, no matter what i did there seems to be a mismatch between the actual information and the tdigest metadata now one thing i can deduce is that is not in the Quantile function but this seems to be the issue with mergeCurrentBuffer function or some other centroids function being called from the Quantile function.

Or this is related to locks as you suggested.

There is no hurry from my side in fixing this issue but i am also planning to implement the TDIGEST.CDF and TDIGEST.RANK in upcoming weeks and they most likely will depend in this issue.

@LindaSummer
Copy link
Contributor

Hi @SharonIV0x86 ,

I have tested the command line successfully with removing the lock and announcing the command "write" for quick validation after fixing #2878 .

I will try to find a way to improve the performance with less critical section.

Best Regards,
Edward

@SharonIV0x86
Copy link
Contributor Author

SharonIV0x86 commented Apr 13, 2025

Hi @SharonIV0x86 ,

I have tested the command line successfully with removing the lock and announcing the command "write" for quick validation after fixing #2878 .

I will try to find a way to improve the performance with less critical section.

Best Regards, Edward

Okay, thanks for looking into it. So, how should i proceed then? should i wait for #2878 to be merged?

@LindaSummer
Copy link
Contributor

Hi @SharonIV0x86 ,
I have tested the command line successfully with removing the lock and announcing the command "write" for quick validation after fixing #2878 .
I will try to find a way to improve the performance with less critical section.
Best Regards, Edward

Okay, thanks for looking into it. So, how should i proceed then? should i wait for #2878 to be merged?

Hi @SharonIV0x86 ,

Maybe we could wait for it to be merged before this PR.
It will affect our go integration test cases.

If you don't mind, I will try to solve the lock issue since I find that it may not be so easy to just add a lock key in current connection lock management.
After this PR solved, we could follow it for other commands like CDF.

Best Regards,
Edward

@SharonIV0x86
Copy link
Contributor Author

Hi @SharonIV0x86 ,

Maybe we could wait for it to be merged before this PR. It will affect our go integration test cases.

If you don't mind, I will try to solve the lock issue since I find that it may not be so easy to just add a lock key in current connection lock management. After this PR solved, we could follow it for other commands like CDF.

Best Regards, Edward

Absolutely no issues whatsoever, there is no hurry i am happy to wait 😄
Let me know if there’s anything I can help with in the meantime.

@SharonIV0x86
Copy link
Contributor Author

@LindaSummer Hi, i have tested the quantile command after the merging of the #2878 and it works as expected.

However, there is a bit of difference in quantile values when compared to the original implementation of redis tdigest.quantile but i believe kvrocks quantile is more accurate as it uses linear interpolation so it should be good.

I have also added a go test case so if any changes are required pls lmk. 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TDigest: Implement QUANTILE command for TDigest Algorithm
5 participants