Pass concrete types to promql functions#16797
Merged
bboreham merged 5 commits intoprometheus:mainfrom Jul 23, 2025
Merged
Conversation
9013b6f to
da0e01a
Compare
bboreham
reviewed
Jul 2, 2025
Member
bboreham
left a comment
There was a problem hiding this comment.
Thanks! A lot of strong typing!
Great to see several performance improvements between 15% and 38%.
A few suggestions below.
Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: darshanime <deathbullet@gmail.com>
Signed-off-by: darshanime <deathbullet@gmail.com>
eec8bdc to
7157606
Compare
Signed-off-by: darshanime <deathbullet@gmail.com>
7157606 to
2d4e6c7
Compare
Contributor
Author
|
@bboreham could you ptal again? |
tcp13equals2
pushed a commit
to tcp13equals2/prometheus
that referenced
this pull request
Aug 18, 2025
) Currently, the promql functions take the interface slice []parser.Value as an argument, which is being implemented by the conrete types Vector, Matrix etc. This PR replaces the interface with the concrete types, resulting in improved performance. The inspiration for this PR came from prometheus#16698 which does this for binops. I extended the idea to all promql functions Signed-off-by: darshanime <deathbullet@gmail.com> * pass single Matrix Signed-off-by: darshanime <deathbullet@gmail.com> --------- Signed-off-by: darshanime <deathbullet@gmail.com> Signed-off-by: Andrew Hall <andrew.hall@grafana.com>
roidelapluie
added a commit
to roidelapluie/prometheus
that referenced
this pull request
Feb 5, 2026
When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by prometheus#16797 which changed function signatures to use concrete types instead of interfaces. The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first. Fixes prometheus#18018 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
bwplotka
pushed a commit
that referenced
this pull request
Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by #16797 which changed function signatures to use concrete types instead of interfaces. The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first. Fixes #18018 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock
pushed a commit
to wbollock/prometheus
that referenced
this pull request
Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by prometheus#16797 which changed function signatures to use concrete types instead of interfaces. The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first. Fixes prometheus#18018 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Signed-off-by: Will Bollock <wbollock@linode.com>
wbollock
pushed a commit
to wbollock/prometheus
that referenced
this pull request
Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by prometheus#16797 which changed function signatures to use concrete types instead of interfaces. The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first. Fixes prometheus#18018 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock
pushed a commit
to wbollock/prometheus
that referenced
this pull request
Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by prometheus#16797 which changed function signatures to use concrete types instead of interfaces. The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first. Fixes prometheus#18018 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock
pushed a commit
to wbollock/prometheus
that referenced
this pull request
Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by prometheus#16797 which changed function signatures to use concrete types instead of interfaces. The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first. Fixes prometheus#18018 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock
pushed a commit
to wbollock/prometheus
that referenced
this pull request
Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by prometheus#16797 which changed function signatures to use concrete types instead of interfaces. The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first. Fixes prometheus#18018 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
wbollock
pushed a commit
to wbollock/prometheus
that referenced
this pull request
Feb 6, 2026
When using the @ modifier with a timestamp that has no data, several PromQL range functions were panicking with "index out of range [0] with length 0". This was introduced by prometheus#16797 which changed function signatures to use concrete types instead of interfaces. The panic occurred because functions were accessing array elements (matrixVal[0], vectorVals[0][0]) without checking if the arrays were empty first. Fixes prometheus#18018 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the promql functions take the interface slice
[]parser.Valueas an argument, which is being implemented by the conrete typesVector,Matrixetc. This PR replaces the interface with the concrete types, resulting in improved performance (see benchmark below). The inspiration for this PR came from #16698 which does this for binops. I extended the idea to all promql functionsbenchmarking results