Optimize parser by csmarchbanks · Pull Request #1117 · prometheus/client_python

@csmarchbanks

Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>

@csmarchbanks changed the base branch from master to parser-benchmark

July 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

Base automatically changed from parser-benchmark to master

July 8, 2025 15:56