Skip to content

Conversation

@Saumya40-codes
Copy link
Contributor

limit the number of map access calls in limit_ratio, as it won't be needed to check whether to add samples or not.

For instant queries:
limitk, limit_ratio doesn't require to sort values at the end.

@Saumya40-codes Saumya40-codes marked this pull request as ready for review June 5, 2025 04:12
Signed-off-by: Saumya Shah <[email protected]>
engine/sort.go Outdated
return lblsCmp < 0
}

if s.sortOrder == noValueSort {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used? It looks very weird. Maybe we can just avoid calling this function (& sorting) overall?

Copy link
Contributor Author

@Saumya40-codes Saumya40-codes Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/thanos-io/promql-engine/blob/main/engine/sort.go#L100C1-L104C5 for limit k/_ratio, we set sortOrder to noValueSort.

Of what I saw, we would need sort if some grouping is used, though sorting sample values would be just extra step as its not needed in two of these aggregations.

Maybe we can just avoid calling this function (& sorting) overall?

Right, but is it ok if order in which samples are, differs? this is just for when some groupings are used for instant queries

Signed-off-by: Saumya Shah <[email protected]>
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.

2 participants