Reuse Chunk Iterator - #642
Conversation
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
|
Pointing out the function which causes the allocs |
brian-brazil
left a comment
There was a problem hiding this comment.
Reset should always work.
For |
|
Sounds like this isn't quite the right abstraction then. How about something more type specific? |
|
You mean to say have that method to the struct and deference the interface to the type in order to call that method when needed? |
|
Yes, it really depends on what the call site is. |
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
|
I would like to see what the benchmarks look like for this, as when I tested things like this previously it didn't help much. Does this change any of the API semantics? |
|
Tested on the same query and data as described in this comment. Also the code changes that I made in cortex querier to benchmark this is exactly similar to what I did in With repeated benchmarks, apparently, the gain in time seems to decrease. So it's mostly allocs and B/op. |
I am not actually sure what you mean here. |
I am not actually sure what you mean here. |
|
Currently a caller of this code can keep multiple of the returned iterators around, now it's only valid until the next Seek/Next. |
I am setting the iterators while the iterator is being created https://github.com/prometheus/tsdb/blob/cef83448cdf1fd61850b870976786dddcd99dee7/querier.go#L1082 |
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
|
Now I am also re-using |
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
|
I have come up with another way to re-use the iterator. |
|
Here are the benchmarks results from |
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
|
👍 |
|
(Will hold off merging until 2.11.0 is out, just in case if there is a bugfix to be included from tsdb in the release) |
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
Want feedback if something like this would be acceptable.
When there are millions of chunks to be parsed for a query, re-using the chunk iterator saves a lot of allocs and in my benchmark in cortex it shed up to
5+sfor a query. (I don't have an exact number of chunks as of now).