Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncLocal diagnostics, clean slate #16779

Merged
merged 98 commits into from May 15, 2024
Merged

AsyncLocal diagnostics, clean slate #16779

merged 98 commits into from May 15, 2024

Conversation

majocha
Copy link
Contributor

@majocha majocha commented Feb 28, 2024

We used node CE, a customized async CE variant to ensure DiagnosticsThreadStatics flow 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:

AsyncLocal<T> Class
Represents ambient data that is local to a given asynchronous control flow, such as an asynchronous method.

This allows us to just remove NodeCode and replace node expressions with async.

Tests show AsyncLocal works as expected in scenarios involving task, async, Async.SwitchToNewThread() SwitchToThreadPool(), Thread.Start() as well as TPL parallel execution.

  • Added concurrent diagnostics logging for running many computations:
  • MultipleDiagnosticsLoggers.Parallel generally for use in place of NodeCode.Parallel. Replays diagnostics onto caller's logger preserving the given order of computations.
  • MultipleDiagnosticsLoggers.Sequential replaces NodeCode.Parallel. Unlike Async.Sequential it starts immediately on the same thread so It automatically uses caller's diagnostics context.
  • Added tests for AsyncLocal diagnostics flow in async and sync contexts.

Previous attempts: #16602, #16645

Copy link
Contributor

github-actions bot commented Feb 28, 2024

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/8.0.400.md
vsintegration/src docs/release-notes/.VisualStudio/17.11.md

@majocha majocha closed this Feb 28, 2024
@majocha
Copy link
Contributor Author

majocha commented May 9, 2024

I think this is good for a review now.

@abonie abonie self-requested a review May 13, 2024 17:17
Copy link
Member

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

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

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!

src/Compiler/Utilities/illib.fs Show resolved Hide resolved
src/Compiler/Driver/GraphChecking/GraphProcessing.fs Outdated Show resolved Hide resolved
src/Compiler/Facilities/DiagnosticsLogger.fsi Outdated Show resolved Hide resolved
src/Compiler/Facilities/DiagnosticsLogger.fsi Show resolved Hide resolved
src/Compiler/Facilities/DiagnosticsLogger.fs Show resolved Hide resolved
@vzarytovskii
Copy link
Member

@majocha i saw reports from @ForNeVeR that some of the changes result in the deadlock

@majocha
Copy link
Contributor Author

majocha commented May 21, 2024

ah, ok I'm seeing the issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants