Repository navigation
profile: avoid unused label map allocations and clear labelX in postDecode - #1064
Merged
Merged
Conversation
…ecode For every sample with labels, `postDecode` previously allocated all three label maps (`Label`, `NumLabel`, and `NumUnit`) sized to `len(s.labelX)`, assigned an empty `NumUnit` map even when numeric labels carried no units, and never cleared the raw `s.labelX` slice after populating the maps. Count string, numeric, and unit entries first so only non-empty maps are allocated with appropriate capacity hints, leave `s.NumUnit` nil when no units are present, and clear `s.labelX` consistently with the other `*X` fields in `postDecode`. ``` name old time/op new time/op delta ParseLabels/num_label-64 35.5ms ± 4% 32.8ms ± 5% -7.54% (p=0.009 n=6+6) ParseLabels/num_label_with_unit-64 41.9ms ± 2% 39.7ms ± 5% -5.13% (p=0.009 n=5+6) ParseLabels/string_label-64 35.5ms ± 4% 34.4ms ± 4% ~ (p=0.132 n=6+6) ParseLabels/many_labels-64 80.7ms ± 2% 62.3ms ± 3% -22.86% (p=0.002 n=6+6) name old inuse-alloc/op new inuse-alloc/op delta ParseLabels/num_label-64 20.1MB ± 0% 18.4MB ± 0% -8.14% (p=0.000 n=5+6) ParseLabels/num_label_with_unit-64 27.6MB ± 0% 26.9MB ± 0% -2.37% (p=0.008 n=5+5) ParseLabels/string_label-64 19.3MB ± 0% 18.6MB ± 0% -3.39% (p=0.002 n=6+6) ParseLabels/many_labels-64 70.9MB ± 0% 28.2MB ± 0% -60.16% (p=0.002 n=6+6) name old alloc/op new alloc/op delta ParseLabels/num_label-64 33.9MB ± 0% 31.9MB ± 0% -5.79% (p=0.002 n=6+6) ParseLabels/num_label_with_unit-64 41.4MB ± 0% 40.4MB ± 0% -2.37% (p=0.002 n=6+6) ParseLabels/string_label-64 34.1MB ± 0% 32.1MB ± 0% -5.76% (p=0.002 n=6+6) ParseLabels/many_labels-64 94.5MB ± 0% 62.3MB ± 0% -34.06% (p=0.004 n=5+6) name old allocs/op new allocs/op delta ParseLabels/num_label-64 297k ± 0% 257k ± 0% -13.74% (p=0.002 n=6+6) ParseLabels/num_label_with_unit-64 338k ± 0% 318k ± 0% -6.04% (p=0.002 n=6+6) ParseLabels/string_label-64 297k ± 0% 257k ± 0% -13.74% (p=0.002 n=6+6) ParseLabels/many_labels-64 706k ± 0% 543k ± 0% -23.15% (p=0.026 n=5+6) ```
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1064 +/- ##
==========================================
+ Coverage 73.50% 73.55% +0.05%
==========================================
Files 46 46
Lines 7941 7957 +16
==========================================
+ Hits 5837 5853 +16
Misses 2082 2082
Partials 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nolanmar511
approved these changes
Nov 5, 2026
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.
For every sample with labels,
postDecodepreviously allocated all three label maps (Label,NumLabel, andNumUnit) sized tolen(s.labelX), assigned an emptyNumUnitmap even when numeric labels carried no units, and never cleared the raws.labelXslice after populating the maps.Count string, numeric, and unit entries first so only non-empty maps are allocated with appropriate capacity hints, leave
s.NumUnitnil when no units are present, and clears.labelXconsistently with the other*Xfields inpostDecode.