Skip to content
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

Implement Native histogram Binary operations and Change Functions for Compatibility with v3.1.0 #503

Open
wants to merge 19 commits into
base: update-prometheus-3.0
Choose a base branch
from

Conversation

@SungJin1212 SungJin1212 force-pushed the Implement-missing-parts branch 6 times, most recently from 4018238 to c3a5bbd Compare January 3, 2025 12:14
@pedro-stanaka
Copy link
Contributor

I would suggest updating the title to better reflect what you are actually doing. Are those PRs part of the Prometheus 3.0 update?

@SungJin1212
Copy link
Author

Yeah, this PR is for the Prometheus 3.0 update.

@SungJin1212 SungJin1212 marked this pull request as draft January 3, 2025 13:48
@SungJin1212 SungJin1212 changed the title Implement missing parts Implement Delayed name dropping and Native histogram Jan 3, 2025
@SungJin1212 SungJin1212 changed the title Implement Delayed name dropping and Native histogram Implement Delayed name dropping and Native histogram Binary operations Jan 3, 2025
@harry671003 harry671003 requested a review from yeya24 January 4, 2025 05:40
@@ -389,6 +406,14 @@ func (a *avgAcc) AddVector(vs []float64, hs []*histogram.FloatHistogram) error {
}
for _, h := range hs {
if err := a.Add(0, h); err != nil {
if errors.Is(err, histogram.ErrHistogramsIncompatibleSchema) {
// skip warning
Copy link
Contributor

Choose a reason for hiding this comment

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

Why dont we also write a warning here ( and in the other cases )?

Copy link
Author

Choose a reason for hiding this comment

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

At the Prometheus it is a warning but we get the fail if we return the error. So, I temporality return nil.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can add warnings too here - we have a package for it "execution/warning" I think

Copy link
Contributor

@MichaHoffmann MichaHoffmann left a comment

Choose a reason for hiding this comment

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

I think delayed name removal has couple bugs; as some functions are not implemented in the function operator and either have special operators or are pushed into the vector operator (like timestamp) or matrix operator (like any range vector function). I would vote that we ignore delayed name removal for now since its behind feature flag in prometheus anyway. If its decided that its going to be removed we have spent effort here that we need to roll back later. Otherwise looks great, thank you for the effort!

@SungJin1212
Copy link
Author

@MichaHoffmann
Yes, It's a draft PR, and I gradually update it under some decisions. :D

@SungJin1212 SungJin1212 force-pushed the Implement-missing-parts branch from c3a5bbd to 9b14ea6 Compare January 5, 2025 01:13
@SungJin1212 SungJin1212 marked this pull request as ready for review January 6, 2025 01:51
@SungJin1212
Copy link
Author

@MichaHoffmann
I think we need to upgrade the Prometheus to 3.1.0 to apply prometheus/prometheus#15250, and some package structures have been changed.

@harry671003
Copy link
Contributor

@SungJin1212 - Could you also change the branch name in the workflow configuration to update-prometheus-3.0, so that it'll trigger the tests?

https://github.com/thanos-io/promql-engine/blob/update-prometheus-3.0/.github/workflows/test.yaml#L7

@MichaHoffmann
Copy link
Contributor

@MichaHoffmann
I think we need to upgrade the Prometheus to 3.1.0 to apply prometheus/prometheus#15250, and some package structures have been changed.

I think should not implement the delayed name removal flag here yet! Or at least it should be a separate PR but I think we should not do it unless it's the default in Prometheus

@yeya24
Copy link
Contributor

yeya24 commented Jan 8, 2025

@SungJin1212 Maybe let's do what @MichaHoffmann to temporarily remove the delayed name removal flag.

If the only failed test is warning and info comparison, I think we are ok to merge to unblock 3.0 upgrade even if it failed the CI.

@@ -287,6 +309,7 @@ func (c *countAcc) Reset(_ float64) {
}

type avgAcc struct {
ctx context.Context
Copy link
Contributor

Choose a reason for hiding this comment

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

can we just add it to the "Add" and "AddVector" method as first argument instead as a struct field of the accumulator?

@@ -50,7 +52,7 @@ func (t *vectorTable) timestamp() int64 {

func (t *vectorTable) aggregate(vector model.StepVector) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add ctx here instead of using it as a struct field?

if err != nil {
return nil, err
}
if ok {
if h != nil {
sv.AppendHistogram(o.pool, uint64(sampleId), h)
} else {
sv.AppendSample(o.pool, uint64(sampleId), f)
} else if f != nil {
Copy link
Author

Choose a reason for hiding this comment

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

@MichaHoffmann
I made the float64 to pointer to skip the value append when the engine should append nothing.

@SungJin1212 SungJin1212 force-pushed the Implement-missing-parts branch 2 times, most recently from 9d2e6ce to 1c3604e Compare January 13, 2025 07:57
@SungJin1212 SungJin1212 changed the title Implement Delayed name dropping and Native histogram Binary operations Implement Native histogram Binary operations and Change Functions for Compatibility with v3.1.0 Jan 13, 2025
@SungJin1212 SungJin1212 force-pushed the Implement-missing-parts branch from 741014f to a904f7b Compare January 14, 2025 02:16
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
@SungJin1212 SungJin1212 force-pushed the Implement-missing-parts branch from a904f7b to f99e6db Compare January 14, 2025 02:39
@@ -12,6 +12,8 @@ import (

"github.com/cespare/xxhash/v2"
"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/promql/parser/posrange"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we group with the other prometheus imports?

if err != nil {
return model.StepVector{}, err
if errors.Is(err, annotations.PromQLInfo) || errors.Is(err, annotations.PromQLWarning) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why does computeBinaryPairing produce an "info/warning" error? that should not happen i think

Copy link
Author

@SungJin1212 SungJin1212 Jan 15, 2025

Choose a reason for hiding this comment

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

If the vectorElemBinop return err, it produces err containing info/warnings.

The reason why use continue is to ignore append. The current implementation return model.StepVector{}, nil, then it appends 0.
We get the fail like this test caes:

eval_info range from 0 to 24m step 6m left_histograms == bool right_floats_for_histograms
  # No results.

case parser.DIV:
return 0, hlhs.Copy().Div(rhs).Compact(0), true, nil
case parser.ADD, parser.SUB, parser.POW, parser.MOD, parser.EQLC, parser.NEQ, parser.GTR, parser.LSS, parser.GTE, parser.LTE, parser.ATAN2:
err := annotations.NewIncompatibleTypesInBinOpInfo("histogram", opName, "float", posrange.PositionRange{})
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think we should return an error and an annotation at this point; that feels redundant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Prometheus also does it, but can we at least add the annotations somewhere else then?

engine/sort.go Outdated
@@ -7,6 +7,7 @@ import (
"math"

"github.com/facette/natsort"

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Some of these files contain changes that are not relevant like adding whitespace or re-ordering the imports. Could you remove them?

Signed-off-by: SungJin1212 <[email protected]>
@SungJin1212 SungJin1212 force-pushed the Implement-missing-parts branch from f60cb6c to 85b9e94 Compare January 16, 2025 02:20
@SungJin1212 SungJin1212 force-pushed the Implement-missing-parts branch from c2252cf to 5d75bd3 Compare January 16, 2025 11:35
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.

5 participants