Repository navigation
Conversation
Signed-off-by: g4lb <galevgi@gmail.com>
Signed-off-by: g4lb <galevgi@gmail.com>
Signed-off-by: g4lb <galevgi@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The text encoders checked each byte of a label value three times to find
\,"and\n. Nowneeds_escapingchecks eight bytes at a time with a zero-byte test. Values shorter than eight bytes use one padded word. The result does not change, so values that need escaping go towrite_str_escapedas before.The counter
_totalsuffix is now one write instead of two.Benchmarks (Apple M5, rustc 1.98.0)
cargo bench --bench text, 12 interleaved rounds againstmaster, Mann-Whitney test:masterencode_realistic_string_labelsencode_escaped_label_valuesprometheus_text_encode_realistic_string_labelsprometheus_text_encode_escaped_label_valuesA local benchmark with 500 label values that need escaping is 18% faster, and a registry with 10 counter and gauge series is 7% faster.
encodeandprometheus_text_encodedid not change significantly, and I measured no significant slowdown. I did not measure other architectures.Checks
cargo fmt,cargo clippy --workspace --all-targets -- -D warningsandcargo test --all --all-featurespass.encoding::text::encodeandencoding::prometheus_text::encodematched on 300k random registries. The registries have counters, gauges, histograms, exemplars, info metrics, units, sub-registries, and label values with\,",\nand non-ASCII text.