-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SVLS-6336 fix: support tag that are not key-value pairs #826
Conversation
BenchmarksComparisonBenchmark execution time: 2025-01-27 20:57:37 Comparing candidate commit 8b06f81 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 52 metrics, 2 unstable metrics. CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
BaselineOmitted due to size. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #826 +/- ##
==========================================
- Coverage 71.37% 71.37% -0.01%
==========================================
Files 317 317
Lines 46605 46637 +32
==========================================
+ Hits 33263 33285 +22
- Misses 13342 13352 +10
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small performance nit. Otherwise LGTM
@@ -89,15 +88,23 @@ impl SortedTags { | |||
pub fn to_chars(&self) -> Vec<Chars> { | |||
let mut tags_as_chars = Vec::new(); | |||
for (k, v) in &self.values { | |||
tags_as_chars.push(format!("{}:{}", k, v).into()); | |||
if v.is_empty() { | |||
tags_as_chars.push(Chars::from(k.to_string())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For bare tags, you can optimize this a little further:
Ustr::as_str
(the type ofk
) gives you a&'static str
Bytes::from_static
can be constructed from&'static [u8]
, which you can get from the&'static str
by calling.to_bytes()
- you can then jump from
Bytes
toChars
viaChars::from_bytes
(which does return aResult<T, E>
but should be safe to call.expect
on since the safety condition it's validating is that you passed in valid UTF-8, which we know we did since we got ourBytes
directly from a&str
, which should always be valid UTF-8`
The end result is that we'll always skip the allocation for bare tags, and the only cost we'll pay is the UTF-8 validation, which is minimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This second optimization seems a bit less readable, add the expect
path and requires an extra dependency for Bytes::from_static, so I would just use a pre allocated string as in the similar code too, unless there is a strong feeling about optimizing this
77a88e9
to
bd0027f
Compare
* fix: support tag that are not key-value pairs * fix comment * add test for tag with multiple columns * use more efficient string concatenation * clippy
Allow tags that are not a pair key:value to be passed. Use an empty string as value and do not serialize a column with empty string in that case