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

JIT: Initialize jitstdout lazily #92123

Merged
merged 7 commits into from
Sep 19, 2023

Conversation

jakobbotsch
Copy link
Member

Avoid duplicating a handle and doing several I/O operations on the startup path. Fixes #91856 as a side effect.

Avoid duplicating a handle and doing several I/O operations on the
startup path. Fixes dotnet#91856 as a side effect.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 15, 2023
@ghost ghost assigned jakobbotsch Sep 15, 2023
@ghost
Copy link

ghost commented Sep 15, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Avoid duplicating a handle and doing several I/O operations on the startup path. Fixes #91856 as a side effect.

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -


FILE* jitstdout()
{
if (s_jitstdout != nullptr)
Copy link
Member

Choose a reason for hiding this comment

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

s_jitstdout needs to be volatile for this to work reliably. Otherwise, the C++ compiler can compile this as:

var temp = s_jitstdout;
if (s_jitstdout != null)
    return temp;
...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I see. Addressed

@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @EgorBo. Am going to try to see if this can also make .NET 8.

Verified that the code no longer runs during startup/shutdown in release builds (unless e.g. DOTNET_JitDisasm is set), and manually tested a few stdout/JitStdOutFile scenarios on windows/ubuntu.

@jakobbotsch jakobbotsch requested a review from EgorBo September 18, 2023 10:00
@jakobbotsch
Copy link
Member Author

/backport to release/8.0

@github-actions
Copy link
Contributor

Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/6221004616

@github-actions
Copy link
Contributor

@jakobbotsch backporting to release/8.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: JIT: Initialize jitstdout lazily
Using index info to reconstruct a base tree...
M	src/coreclr/jit/codegencommon.cpp
M	src/coreclr/jit/compiler.cpp
M	src/coreclr/jit/ee_il_dll.cpp
M	src/coreclr/jit/error.cpp
M	src/coreclr/jit/fgdiagnostic.cpp
M	src/coreclr/jit/lsra.cpp
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/jit/lsra.cpp
Auto-merging src/coreclr/jit/fgdiagnostic.cpp
Auto-merging src/coreclr/jit/error.cpp
Auto-merging src/coreclr/jit/ee_il_dll.cpp
CONFLICT (content): Merge conflict in src/coreclr/jit/ee_il_dll.cpp
Auto-merging src/coreclr/jit/compiler.cpp
Auto-merging src/coreclr/jit/codegencommon.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 JIT: Initialize jitstdout lazily
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@jakobbotsch an error occurred while backporting to release/8.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@jakobbotsch jakobbotsch merged commit 5ba46f0 into dotnet:main Sep 19, 2023
@jakobbotsch jakobbotsch deleted the avoid-stdout-io-on-startup branch September 19, 2023 15:10
@ghost ghost locked as resolved and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when trying to load an Assembly in a hostfxr environment after calling FreeConsole()
3 participants