[release/5.0-rc2] Optimize the allocation and speed of ActivitySet/GetCustomProperty #41908
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.
Backport of #41840 to release/5.0-rc2
#41840 contains the perf numbers before and after the fix.
/cc @tarekgh
Customer Impact
In 5.0 We have exposed the APIs
Get/SetCutomProperty
inActivity
class. It has been reported by Azure monitoring team (and other teams) this API is allocating too much memory when calling the setter. These APIs are used in the Open Telemetry implementation which deals with many activity objects and set a custom property values to such objects.The fix here is reduce the allocation and enhance the speed of these APIs.
Testing
Manually tested and ran the whole regression testing on the fix.
Risk
very low as we are not changing any logic of the APIs. We are just switched the implementation to use Dictionary<,> instead of ConcurrentDictionary<,>.