-
Notifications
You must be signed in to change notification settings - Fork 713
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
Makes entry splitter work with CharSequence #1284
Conversation
This allows us to split and parse CharSequence instead of String, which reduces allocations when parsing W3C tracestate. This adds a utility `CharSequences` to help with tasks.
This reworks TraceContextExtractor using utilities recently added to brave: openzipkin/brave#1284 The main idea is that this allows us to split tracestate without allocating any strings. The current implementation remains incomplete, but this phase sets the stage for completion.
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.
Worth adding any jmh? String
is workhorse of Java so it'd be nice to confirm it doesn't have any magic defeating CharSequence
even at the expense of some alloc for a realish type of usage.
will do on adding JMH |
Ok rejigged after noticing String's behaviour on subsequence. Here are the bench results in my laptop for somewhat realistic data. The only place this is of real use is when splitting the middle of a string (ex to own an entry). This can happen at least in w3c tracestate and also secondary sampling. $ egrep '(^Bench|p0.999 |gc.alloc.rate.norm)' /tmp/foo
Benchmark Mode Cnt Score Error Units
CharSequencesBenchmarks.regionMatches_hit:regionMatches_hit·p0.999 sample 0.245 us/op
CharSequencesBenchmarks.regionMatches_hit:·gc.alloc.rate.norm sample 15 0.005 ± 0.001 B/op
CharSequencesBenchmarks.regionMatches_miss:regionMatches_miss·p0.999 sample 0.162 us/op
CharSequencesBenchmarks.regionMatches_miss:·gc.alloc.rate.norm sample 15 0.001 ± 0.001 B/op
CharSequencesBenchmarks.withoutSubSequence_middle_max:withoutSubSequence_middle_max·p0.999 sample 0.674 us/op
CharSequencesBenchmarks.withoutSubSequence_middle_max:·gc.alloc.rate.norm sample 15 40.005 ± 0.001 B/op
CharSequencesBenchmarks.withoutSubSequence_middle_max_string:withoutSubSequence_middle_max_string·p0.999 sample 10.880 us/op
CharSequencesBenchmarks.withoutSubSequence_middle_max_string:·gc.alloc.rate.norm sample 15 6040.687 ± 0.033 B/op
CharSequencesBenchmarks.withoutSubSequence_middle_normal:withoutSubSequence_middle_normal·p0.999 sample 1.508 us/op
CharSequencesBenchmarks.withoutSubSequence_middle_normal:·gc.alloc.rate.norm sample 15 40.005 ± 0.001 B/op
CharSequencesBenchmarks.withoutSubSequence_middle_normal_string:withoutSubSequence_middle_normal_string·p0.999 sample 1.710 us/op
CharSequencesBenchmarks.withoutSubSequence_middle_normal_string:·gc.alloc.rate.norm sample 15 424.042 ± 0.002 B/op |
@jeqo one thing I mentioned to rag, but not you yet. The trace-context format is a performance bomb for messaging at the point anyone uses tracestate header. One thing this does is insulate us, such that if receiving 1000 messages doesn't mean allocating some factor N strings, some of which may never be used if the messages are filtered out. |
went ahead and added bench missing for entry splitter. notably it shows nothing is allocated.
|
This reworks TraceContextExtractor using utilities recently added to brave: openzipkin/brave#1284 The main idea is that this allows us to split tracestate without allocating any strings. The current implementation remains incomplete, but this phase sets the stage for completion.
* Overhauls TraceContextExtractor This reworks TraceContextExtractor using utilities recently added to brave: openzipkin/brave#1284 The main idea is that this allows us to split tracestate without allocating any strings. The current implementation remains incomplete, but this phase sets the stage for completion. * foo
This allows us to split and parse CharSequence instead of String, which
reduces allocations when parsing W3C tracestate.
This adds a utility
CharSequences
to help with tasks.