Repository navigation
Compress t-digest to prevent memory leakage - #234
Conversation
SimenB
left a comment
There was a problem hiding this comment.
Can you remove your package-lock changes (I've updated it on master), and add a changelog entry? 🙂
f4eaacb to
154ca9e
Compare
154ca9e to
7c9e119
Compare
|
@SimenB of course, here is the updated version. Thanks for your work and have a happy new year 🎆🎉🎈! |
|
Thanks for your investigation and fixes! The PR looks good to me.. Just out of curiosity, why does this fix the leak? |
|
Still missing the update in the changelog btw! |
|
@siimon could you merge if all is good? |
|
Sorry for the slow updates, but I still want to know what implications this has and why it solves the leak.. Is it a known problem in the tdigest library or are we using it in a wrong way? |
|
@atd-schubert Do you care to inform us :-)? |
|
@siimon @firasdib Sorry I was away the last two weeks... During my research I found out that Summaries are leaking memory while Histograms don't. I wrote a leakage test for it (see: #142 (comment)). While analyzing the heap dumps I recognized that t-digest add each value to an array. Of course this will end-up in a leaking behavior. In the description of the t-digest module is mentioned that you should compress the data especially after adding a big dataset. After compressing it will still have an accurate result, but don't have to keep all entries in the array. In prom-client data is added continuously. Compressing on every entry will end up in a lot of processing and make the module quite slow. In addition, compressing of a small dataset will not have any effect. This is why I decide to compress every 1000 measurements as default. After making these changes the above mentioned leakage test will not detect a leaking behavior anymore. As long as you add enough measurements, of course. So in the end - and according to your question - it is a known issue of the t-digest library, but it works as designed and with the compression you are able to eliminate or at least reduce that issue. So maybe it is also some kind of using it the wrong way... |
|
Published in 11.5.3 |
As already described in #142 the Summary is leaking memory. This fix will call the compress method of t-digist. To prevent compressing a too small set of measurements and increasing performance, it will call the compress method every 1000 measurements by default. You can also specify another count with option
compressCountin the Summary options.