Skip to content

fix(tsdb): backport zero sample schema optimization from pr 17071 #1001

Merged
krajorama merged 1 commit intor361from
krajo/r361-port-pr1000
Oct 10, 2025
Merged

fix(tsdb): backport zero sample schema optimization from pr 17071 #1001
krajorama merged 1 commit intor361from
krajo/r361-port-pr1000

Conversation

@krajorama
Copy link
Copy Markdown
Contributor

Cherry pick of #1000 from r360.

  • fix(tsdb): backport zero sample schema optimization from pr 17071

There is an optimization in
prometheus/prometheus#17071 that ensures that the injected zero histogram sample has the same schema as the next sample.

It turns out that if there are at least three samples: a normal sample (schema>0), zero sample(schema=0), normal sample (schema>0) then the histogram rate function will find the lowest schema and normalize all to that, meaning that the normal samples will be downscaled to schema 0. In dashboards it will look like as if we lost the resolution.

See https://github.com/prometheus/prometheus/blob/9e4d23ddafcdc00021cd8630e78bb819e84ccac9/promql/functions.go#L344

So the optimization is actually needed to not loose resolution on read back. Alternatively we should use per sample CT as metadata instead, but that would be a big rewrite of TSDB and PromQL.

Which issue(s) does the PR fix:

Does this PR introduce a user-facing change?

NONE

)

* fix(tsdb): backport zero sample schema optimization from pr 17071

There is an optimization in
prometheus/prometheus#17071
that ensures that the injected zero histogram sample has the same schema
as the next sample.

It turns out that if there are at least three samples:
a normal sample (schema>0), zero sample(schema=0), normal sample (schema>0)
then the histogram rate function will find the lowest schema and normalize
all to that, meaning that the normal samples will be downscaled to schema
0. In dashboards it will look like as if we lost the resolution.

See https://github.com/prometheus/prometheus/blob/9e4d23ddafcdc00021cd8630e78bb819e84ccac9/promql/functions.go#L344

So the optimization is actually needed to not loose resolution on
read back. Alternatively we should use per sample CT as metadata
instead, but that would be a big rewrite of TSDB and PromQL.

Signed-off-by: György Krajcsovits <[email protected]>
@krajorama krajorama enabled auto-merge (squash) October 10, 2025 06:34
@krajorama krajorama disabled auto-merge October 10, 2025 06:54
@krajorama krajorama changed the base branch from main to r361 October 10, 2025 06:55
@krajorama krajorama merged commit f68e351 into r361 Oct 10, 2025
31 checks passed
@krajorama krajorama deleted the krajo/r361-port-pr1000 branch October 10, 2025 07:05
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