Skip to content

Optimize parser - #1117

Merged
csmarchbanks merged 4 commits into
masterfrom
optimize-parser
Jul 8, 2025
Merged

Optimize parser#1117
csmarchbanks merged 4 commits into
masterfrom
optimize-parser

Conversation

@csmarchbanks

@csmarchbankscsmarchbanks commented Jul 2, 2025

Copy link
Copy Markdown
Member

Several commits that help alleviate the CPU increase reported in #1114. The performance is still worse than 0.22.1 but moving in the correct direction, and I don't know if we will be able to match performance with the additional features.

For reference, here are the benchmark results from my laptop. We still have a ways to go to get back to original peformance.

----------------------------------------------------------------------------------------------------------- benchmark: 3 tests ----------------------------------------------------------------------------------------------------------
Name (time in us) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_text_string_to_metric_families (0001_v0.21.1) 60.3750 (1.0) 90.5000 (1.0) 63.5184 (1.0) 2.5867 (1.0) 62.9170 (1.0) 0.5410 (1.0) 706;1090 15.7435 (1.0) 6499 1
test_benchmark_text_string_to_metric_families (0008_optimiz) 197.5420 (3.27) 295.6670 (3.27) 205.3111 (3.23) 5.4140 (2.09) 203.6250 (3.24) 2.0841 (3.85) 230;293 4.8707 (0.31) 2543 1
test_benchmark_text_string_to_metric_families (0011_v0.22.1) 296.1660 (4.91) 412.5830 (4.56) 307.6600 (4.84) 7.9195 (3.06) 305.2080 (4.85) 3.4160 (6.31) 202;225 3.2503 (0.21) 1614 1
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
@csmarchbanks
csmarchbanks changed the base branch from master to parser-benchmarkJuly 3, 2025 14:31
This saves ~10% in the benchmark.
Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
Enumerating rather than using a while loop saves significant CPU when
looking for an unquoted character. This ends up improving the benchmark
~20% on its own.
Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
Split the term into the label name and label value portions in one swoop
rather than starting from the beginning to find an = character after
already going through the full term. This saves ~5% on the benchmark.
Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
ywwg
ywwg approved these changes Jul 8, 2025

@ywwgywwg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for working on this <3

Base automatically changed from parser-benchmark to masterJuly 8, 2025 15:56
@csmarchbanks
csmarchbanks merged commit 26da805 into masterJul 8, 2025
11 checks passed
@csmarchbanks
csmarchbanks deleted the optimize-parser branch July 8, 2025 15:57
Sign up for freeto 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

@csmarchbanks@ywwg