Skip to content

Conversation

@majocha
Copy link
Contributor

@majocha majocha commented Feb 13, 2024

This keeps a shadow diagnostics async state in AsyncLocals, and compare it with the current implementation, failing whenever they diverge.

The idea is to find out when and why it happens and to bring the behavior to some unification, so we can be sure AsyncLocal is a valid and safe replacement for current ThreadStatics + NodeCode.

It's useful to run some tests in debug, with the setting to break on System.Exception.
Then we can not only observe what diverged:
image

but also view the log of changes:
image

with some, not often useful, call stacks:
image

@github-actions
Copy link
Contributor

❗ Release notes required

@majocha,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

* <Informative description>. ([PR #XXXXX](https://github.com/dotnet/fsharp/pull/XXXXX))

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

You can open this PR in browser to add release notes: open in github.dev

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/8.0.300.md No release notes found or release notes format is not correct

@majocha
Copy link
Contributor Author

majocha commented Feb 14, 2024

At the moment I'm not sure how to continue with this in light of #16712.

@0101
Copy link
Contributor

0101 commented Feb 15, 2024

At the moment I'm not sure how to continue with this in light of #16712.

I guess disregard anything Transparent Compiler related in the testing? Since that possibly doesn't work correctly now it's not something we can compare against.

But presumably what was there before does work, so we could just check if that stays the same.

@majocha
Copy link
Contributor Author

majocha commented Feb 20, 2024

I'm afraid this is impossible task. I think threadstatics behavior is not 100% deterministic in tests, I even see different results depending on how many tests I run simultaneously. Nothing is fully reproducible here, it just kind of eventually converges on some final state.
There is always potential for one task picking up threadstatics of a different one, whenever it happens to be started on or switched to the same thread, see #16712
With some careful massaging of the code in BuildGraph.fs we can make it almost fully deterministic, but then it's not the same code anymore that we want to test for.

@majocha majocha closed this Feb 20, 2024
@auduchinok
Copy link
Member

I think threadstatics behavior is not 100% deterministic in tests, I even see different results depending on how many tests I run simultaneously. Nothing is fully reproducible here, it just kind of eventually converges on some final state.

I think it should be possible to have more (lots of? 🙂) asserts in tests, maybe? They would check that, for example, we don't have diagnostics without logger or in a wrong phase.

@majocha
Copy link
Contributor Author

majocha commented Mar 4, 2024

Yes, one thing we had was the AssertFalseDiagnosticsLogger, but it was disabled for as long as this repo exists.
I think now I have some better idea what's going on: #16778

@majocha majocha deleted the asynclocal-compare branch September 20, 2024 08:11
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.

3 participants