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

pal init: Init membarrier() before first thread to improve start time #106724

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ PAL_IsDebuggerPresent();
#define PAL_INITIALIZE_ENSURE_STACK_SIZE 0x20
#define PAL_INITIALIZE_REGISTER_SIGNALS 0x40
#define PAL_INITIALIZE_REGISTER_ACTIVATION_SIGNAL 0x80
#define PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS 0x100

// PAL_Initialize() flags
#define PAL_INITIALIZE (PAL_INITIALIZE_SYNC_THREAD | \
Expand All @@ -206,7 +207,8 @@ PAL_IsDebuggerPresent();
PAL_INITIALIZE_DEBUGGER_EXCEPTIONS | \
PAL_INITIALIZE_ENSURE_STACK_SIZE | \
PAL_INITIALIZE_REGISTER_SIGNALS | \
PAL_INITIALIZE_REGISTER_ACTIVATION_SIGNAL)
PAL_INITIALIZE_REGISTER_ACTIVATION_SIGNAL | \
PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS)

typedef DWORD (PALAPI_NOEXPORT *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
Expand Down
15 changes: 10 additions & 5 deletions src/coreclr/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,16 @@ Initialize(
goto CLEANUP0a;
}

if (flags & PAL_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS)
{
// Initialize before first thread is created for faster load on Linux
if (!InitializeFlushProcessWriteBuffers())
{
palError = ERROR_PALINIT_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS;
goto CLEANUP0a;
}
}

// The gSharedFilesPath is allocated dynamically so its destructor does not get
// called unexpectedly during cleanup
gSharedFilesPath = InternalNew<PathCharString>();
Expand Down Expand Up @@ -787,11 +797,6 @@ PAL_InitializeCoreCLR(const char *szExePath, BOOL runningInExe)
return ERROR_PALINIT_PROCABORT_INITIALIZE;
}

if (!InitializeFlushProcessWriteBuffers())
{
return ERROR_PALINIT_INITIALIZE_FLUSH_PROCESS_WRITE_BUFFERS;
}

return ERROR_SUCCESS;
}

Expand Down
Loading