feat(layer)!: make adding multiple dynamic fields cheaper#35
Merged
Conversation
Contributor
There was a problem hiding this comment.
Rust Benchmark (1.89.0)
Details
| Benchmark suite | Current: d5faf2c | Previous: b24ff4a | Ratio |
|---|---|---|---|
new_span/single_thread/1 |
316 ns/iter (± 4) |
287 ns/iter (± 11) |
1.10 |
new_span/multithreaded/1 |
22674 ns/iter (± 1163) |
39198 ns/iter (± 2227) |
0.58 |
new_span/single_thread/10 |
3162 ns/iter (± 13) |
2872 ns/iter (± 18) |
1.10 |
new_span/multithreaded/10 |
27591 ns/iter (± 1180) |
41613 ns/iter (± 1981) |
0.66 |
new_span/single_thread/50 |
15766 ns/iter (± 303) |
14399 ns/iter (± 215) |
1.09 |
new_span/multithreaded/50 |
56669 ns/iter (± 2876) |
56299 ns/iter (± 3008) |
1.01 |
event/root/single_threaded/1 |
767 ns/iter (± 11) |
835 ns/iter (± 5) |
0.92 |
event/root/multithreaded/1 |
22756 ns/iter (± 751) |
39424 ns/iter (± 2299) |
0.58 |
event/unique_parent/single_threaded/1 |
1003 ns/iter (± 6) |
1112 ns/iter (± 6) |
0.90 |
event/unique_parent/multithreaded/1 |
25631 ns/iter (± 899) |
44411 ns/iter (± 2604) |
0.58 |
event/shared_parent/multithreaded/1 |
23573 ns/iter (± 956) |
40319 ns/iter (± 3093) |
0.58 |
event/multi-parent/multithreaded/1 |
28332 ns/iter (± 1159) |
41106 ns/iter (± 2016) |
0.69 |
event/root/single_threaded/10 |
7671 ns/iter (± 34) |
8221 ns/iter (± 108) |
0.93 |
event/root/multithreaded/10 |
34475 ns/iter (± 1885) |
46927 ns/iter (± 2828) |
0.73 |
event/unique_parent/single_threaded/10 |
10037 ns/iter (± 59) |
11189 ns/iter (± 46) |
0.90 |
event/unique_parent/multithreaded/10 |
44032 ns/iter (± 1980) |
53694 ns/iter (± 2472) |
0.82 |
event/shared_parent/multithreaded/10 |
40493 ns/iter (± 1439) |
48937 ns/iter (± 2569) |
0.83 |
event/multi-parent/multithreaded/10 |
66042 ns/iter (± 2744) |
80030 ns/iter (± 2840) |
0.83 |
event/root/single_threaded/50 |
38293 ns/iter (± 106) |
41238 ns/iter (± 727) |
0.93 |
event/root/multithreaded/50 |
91483 ns/iter (± 5168) |
106986 ns/iter (± 7248) |
0.86 |
event/unique_parent/single_threaded/50 |
50328 ns/iter (± 308) |
55732 ns/iter (± 689) |
0.90 |
event/unique_parent/multithreaded/50 |
129107 ns/iter (± 9187) |
132678 ns/iter (± 7031) |
0.97 |
event/shared_parent/multithreaded/50 |
118203 ns/iter (± 11101) |
131620 ns/iter (± 7785) |
0.90 |
event/multi-parent/multithreaded/50 |
416102 ns/iter (± 26399) |
418921 ns/iter (± 28946) |
0.99 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
Motivation
Adding multiple dynamic fields was expensive because it had to always allocate the string for each key on every tracing invocation as well as create a
serde_json::Value.Solution
Now the strings may be
&'static strif known beforehand and the values may be left asimpl Serializeif they're available. The fields will be serialized into the output string as needed.