Commit c145985
authored
Diagnostics: Fixes possible Thread contention in Traces (#5455)
# 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.
- [x] 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 #IssueNumber1 parent 75175de commit c145985
1 file changed
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
125 | | - | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
175 | | - | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
195 | | - | |
| 197 | + | |
196 | 198 | | |
197 | 199 | | |
198 | 200 | | |
| |||
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
220 | | - | |
| 222 | + | |
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
| |||
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
242 | | - | |
| 244 | + | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| |||
0 commit comments