Skip to content

textparse: CreatedTimestamp now returns int64 value; optimized proto CT parsing#16072

Merged
bwplotka merged 1 commit intomainfrom
protoparse-ct
Mar 7, 2025
Merged

textparse: CreatedTimestamp now returns int64 value; optimized proto CT parsing#16072
bwplotka merged 1 commit intomainfrom
protoparse-ct

Conversation

@bwplotka
Copy link
Member

@bwplotka bwplotka commented Feb 24, 2025

..instead of *int64. This is as an optimization and ease of use. We already accepted in many places (proto histograms, PRW) that CT (or any timestamp really) 0 means not set. I added todos for normal timestamps too.

Additionally I added trivial fast path for protobuf CreatedTimestamp implementation, was visible on allocs/s in #16046 (comment)

For proto:

benchstat v1.txt v3.txt                               
goos: darwin
goarch: arm64
pkg: github.com/prometheus/prometheus/model/textparse
cpu: Apple M1 Pro
                                       │    v1.txt    │               v3.txt               │
                                       │    sec/op    │   sec/op     vs base               │
CreatedTimestampPromProto/case=no-ct-2   22.450n ± 1%   2.232n ± 3%  -90.06% (p=0.002 n=6)
CreatedTimestampPromProto/case=ct-2      14.725n ± 5%   1.874n ± 1%  -87.27% (p=0.002 n=6)
geomean                                   18.18n        2.045n       -88.75%

                                       │   v1.txt   │                 v3.txt                 │
                                       │    B/op    │    B/op     vs base                    │
CreatedTimestampPromProto/case=no-ct-2   16.00 ± 0%    0.00 ± 0%  -100.00% (p=0.002 n=6)
CreatedTimestampPromProto/case=ct-2      8.000 ± 0%   0.000 ± 0%  -100.00% (p=0.002 n=6)
geomean                                  11.31                    ?                      ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

                                       │   v1.txt   │                 v3.txt                 │
                                       │ allocs/op  │ allocs/op   vs base                    │
CreatedTimestampPromProto/case=no-ct-2   1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.002 n=6)
CreatedTimestampPromProto/case=ct-2      1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.002 n=6)
geomean                                  1.000                    ?                      ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

Copy link
Member

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Why do we need such a long benchmark?
Shouldn't it show up in existing benchmarks?

@bwplotka
Copy link
Member Author

Why do we need such a long benchmark?

To focus on CT part. Happy to remove.

Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

LGTM

I don't mind leaving the benchmark command as a comment, it's convenient :)

..instead of *int64. This is as an optimization and ease of use. We already
accepted in many places (proto histograms, PRW) that CT (or any timestamp really) 0
means not set.

Signed-off-by: bwplotka <bwplotka@gmail.com>
@bwplotka bwplotka enabled auto-merge (squash) March 7, 2025 10:00
@bwplotka bwplotka merged commit dc85d67 into main Mar 7, 2025
45 checks passed
@bwplotka bwplotka deleted the protoparse-ct branch March 7, 2025 12:43
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.

3 participants