Uh oh!
There was an error while loading. Please reload this page.
AsyncLocal diagnostics, clean slate - #16779
Conversation
❗ Release notes required
|
Uh oh!
There was an error while loading. Please reload this page.
majocha
commented
May 9, 2024
I think this is good for a review now. |
psfinaki
left a comment
There was a problem hiding this comment.
Okay so I finally gathered some mental resources for reviewing this :)
I added a few remarks and questions mostly for my understanding. Overall these are good changes since removing custom CEs reduces cognitive load of the code. Also I think it's a good moment to get this in.
Thanks!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
vzarytovskii
commented
May 21, 2024
majocha
commented
May 21, 2024
ah, ok I'm seeing the issue now. |
We used
nodeCE, a customizedasyncCE variant to ensureDiagnosticsThreadStaticsflow from thread to thread along with the execution of asynchronous compiler tasks.AsyncLocal<'T>achieves this without the need for a specialized CE.from documetation:
This allows us to just remove
NodeCodeand replacenodeexpressions withasync.Tests show
AsyncLocalworks as expected in scenarios involvingtask,async,Async.SwitchToNewThread()SwitchToThreadPool(),Thread.Start()as well as TPL parallel execution.MultipleDiagnosticsLoggers.Parallelgenerally for use in place ofNodeCode.Parallel. Replays diagnostics onto caller's logger preserving the given order of computations.MultipleDiagnosticsLoggers.SequentialreplacesNodeCode.Parallel. UnlikeAsync.Sequentialit starts immediately on the same thread so It automatically uses caller's diagnostics context.AsyncLocaldiagnostics flow in async and sync contexts.Previous attempts: #16602, #16645