Skip to content

Conversation

@FabianMeiswinkel
Copy link
Member

Pull Request Template

Description

This PR fixes a regression in tracing introduced by #5422, which can lead to thread contention. The bug is that the locking expects Trace-names to be unique for different logical operations - but many of the strings passed into new root traces (logical operations) are not new string instances (with possibly same value) but constants - so same singelton string instances. In tehse cases the new code will provide unnecessary lock contention. The locking scope should be just the scope of the ITrace instance - so, this PR introduces a new instance-level lock object (something I tried to avoid initially to avoid allocation of a new object-instance per trace). The alternative (Id - is a ValueType) and (children is a List that is exposed via properties - locking it would not be guaranteed to be dead-lock free - woudl be unliekly but not impossble if caller locks on the returned value from the Childred property).

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good!

@kirankumarkolli kirankumarkolli changed the title Fixed possible Thread contention in Traces Diagnostics: Fixes possible Thread contention in Traces Oct 27, 2025
@kirankumarkolli kirankumarkolli merged commit c145985 into master Oct 27, 2025
2 of 29 checks passed
@kirankumarkolli kirankumarkolli deleted the users/fabianm/TraceThreadContentionFix branch October 27, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants