Repository navigation
Shrink System.Diagnostics.Activity by 40 bytes - #37395
Conversation
|
Raised issue for api change https://github.com/dotnet/corefx/issues/37396 |
What did you do to generate the type layout like this (it's great)? |
Using @SergeyTeplyakov's ObjectLayoutInspector and local copies of the changed objects to make it easier to inspect. on NuGet ObjectLayoutInspector.TypeLayout.PrintLayout<Activity>(recursively: true);Doesn't work for |
Aww. I was going to try it on |
Can do a local version and switch in a non ref Span ( |
lmolkova
left a comment
There was a problem hiding this comment.
If you read the values from Http Headers or add them to headers, then you go via strings both ways and save on allocations as the values are immediately what they are directly, as well as the smaller Activity.
There are potential cases when strings are not needed (only binary protocols are used in the service) and tracing system/logger work with ActivityTraceId/SpanId. This is not a real-world scenario (or pretty rare) for now, so I'm ok with making it just a bit less efficient in favor of a more common scenario.
/cc @noahfalk
noahfalk
left a comment
There was a problem hiding this comment.
A few nit things, but LGTM 👍
|
Will consolidate the feedback after the api review https://github.com/dotnet/corefx/issues/37396 |
|
Marking as blocked by API review ... |
|
API review completed. |
|
Removing |
|
Feedback addressed |
|
/azp run corefx-ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Anyone fancy merging? Since its an api change would be better to have it flow through earlier. |
|
Looks like I got the |
ef7b25f to
725f867
Compare
|
@benaadams is it ready to merge? |
@lmolkova yes |
* Shrink Activity * fix threading issues * Handle parsing issues * Fix Commit migrated from dotnet/corefx@edc88b0
* Shrink Activity * fix threading issues * Handle parsing issues * Fix Commit migrated from dotnet/corefx@edc88b0
Shrinks Activity on x64 by 40 bytes from 152 bytes to 112 bytes
ActivitySpanIdandActivityTraceIdare shrunk to pointer size and only used for exchange types; so theinandreadonly refare removed on the apis (needs API review?)ActivitySpanIdandActivityTraceIdare managed structs (contain bothstringandulongs) so can't be Unsafe.Cast to extract theulongdata and the normal way to extract the data is via.ToStringor.ToHexString(for headers) so we can just store them as strings in the first place and not bother the theulongs.The other way is via
.CopyTo, however this only saves on allocation if the input is not a string (direct binary); and the fields are never used as a string, or output as string. That also comes with extra complexity in size of the struct; and requiring continuous passing viainorreadonly ref.If you read the values from Http Headers or add them to headers, then you go via strings both ways and save on allocations as the values are immediately what they are directly, as well as the smaller Activity.
Before
After
cc: @SergeyKanzhelev @lmolkova @davidfowl @stephentoub
Resolves https://github.com/dotnet/corefx/issues/37396
Resolves https://github.com/dotnet/corefx/issues/38486