You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove more PAL wrappers from pal/src/misc - #137579
Named objects: PAL objects are never created with a name, so delete CPalString (pal/src/misc/strutil.cpp), CObjectAttributes, the named object list and LocateObject from the PAL object manager.
perfjitdump.cpp: move it to the VM next to its only user, perfmap.cpp, and drop the PAL_ prefix.
time.cpp: delete it.
PAL_nanosleep: use nanosleep directly in its two callers.
QueryThreadCycleTime: use clock_gettime(CLOCK_THREAD_CPUTIME_ID) in the utilcode and superpmi cycle timers. Delete GetThreadTimesInternal, which only it used, and its PAL test.
GetSystemInfo: delete it and its PAL test.
Fill g_SystemInfo directly on Unix, and trim the PAL SYSTEM_INFO to the two fields that are used.
Use minipal_getpagesize for the page size in the DAC and metadata, and PAL_GetLogicalCpuCountFromOS for the processor count in EventPipe and superpmi.
Compile isRetAddr and the TOP_MEMORY/BOT_MEMORY helpers only where they are used (x86, Windows).
Remove the configure checks that are left without users.
`FormatMessageW`: all Unix callers are in utilcode, so handle them there:
- `SString::FormatMessage` expands `%1`..`%10` inserts itself for
`FORMAT_MESSAGE_FROM_STRING`, and uses the error message table for
`FORMAT_MESSAGE_FROM_SYSTEM`.
- `FormatRuntimeErrorVA` (`posterror.cpp`) uses the error message table.
- Move the error message table from `pal/src/misc/errorstrings.cpp` to
`utilcode/errorstrings.cpp` as `GetSystemErrorMessage`.
- Delete `pal/src/misc/fmtmessage.cpp` and its PAL tests.
Named objects: PAL objects are never created with a name, so delete
`CPalString` (`pal/src/misc/strutil.cpp`), `CObjectAttributes`, the named
object list and `LocateObject` from the PAL object manager.
`perfjitdump.cpp`: move it to the VM next to its only user, `perfmap.cpp`,
and drop the `PAL_` prefix.
`time.cpp`: delete it.
- `PAL_nanosleep`: use `nanosleep` directly in its two callers.
- `QueryThreadCycleTime`: use `clock_gettime(CLOCK_THREAD_CPUTIME_ID)` in
the utilcode and superpmi cycle timers. Delete `GetThreadTimesInternal`,
which only it used, and its PAL test.
`GetSystemInfo`: delete it and its PAL test.
- Fill `g_SystemInfo` directly on Unix, and trim the PAL `SYSTEM_INFO` to
the two fields that are used.
- Use `minipal_getpagesize` for the page size in the DAC and metadata, and
`PAL_GetLogicalCpuCountFromOS` for the processor count in EventPipe and
superpmi.
- Compile `isRetAddr` and the `TOP_MEMORY`/`BOT_MEMORY` helpers only where
they are used (x86, Windows).
Remove the configure checks that are left without users.
Co-authored-by: Cursor <[email protected]>
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.
- `perfjitdump.cpp`: drop `<cstddef>`, which conflicts with musl's
`uint8_t` after `common.h`.
- Cycle timers: WASI has no `CLOCK_THREAD_CPUTIME_ID`.
Co-authored-by: Cursor <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The changes span Unix startup, diagnostics, profiling, and PAL/VM/DAC boundaries, while formatter tests are removed and cross-platform build and runtime validation was unavailable.
No open issues 🎉
What changed in this PR
This PR reduces CoreCLR’s Platform Abstraction Layer (PAL) by moving specialized functionality closer to its callers and replacing thin Unix wrappers with direct platform calls.
Changes:
Move error-message handling into utilcode and JIT dump support into the VM.
Remove unused named-object infrastructure and replace PAL timing and system-information wrappers.
Remove obsolete PAL tests, declarations, build entries, and configure checks.
- Use `minipal_sleep` for the pipe open retry and in `ep_rt_thread_sleep`
on all platforms.
- Sample profiler: use `minipal_microdelay` for sub-millisecond sampling
rates.
- Delete `TOP_MEMORY`/`BOT_MEMORY` and the early out in `isRetAddr` that
used them.
Co-authored-by: Cursor <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The new sleep call turns the default 1 ms interval into a one-second wait on Unix and bypasses Mono’s GC-safe transition, degrading sampling and potentially delaying garbage collection.
The seconds were computed from milliseconds, so delays of 1ms or more slept
1000 times too long. Also retry the sleep when nanosleep is interrupted.
Co-authored-by: Cursor <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The direct sleep bypasses Mono’s GC-safe transition, leaving the sampling thread GC-unsafe and potentially extending GC pauses by up to the configured sampling interval.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Restore GC-safe sleep for Mono sampling thread
src/native/eventpipe/ep-sample-profiler.c:103
On Mono, this direct sleep bypasses the GC-safe transition in src/mono/mono/eventpipe/ep-rt-mono.h:1102-1113; the attached sampling thread remains GC-unsafe because Mono's EP_GCX_PREEMP_ENTER is only a brace. Cooperative or hybrid garbage collection can therefore wait for the sampler to wake, adding up to the configured sampling interval to a GC pause. Restore ep_rt_thread_sleep here and preserve sub-millisecond sleep precision in the CoreCLR adapter at src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h:1154.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Named objects: PAL objects are never created with a name, so delete
CPalString(pal/src/misc/strutil.cpp),CObjectAttributes, the named object list andLocateObjectfrom the PAL object manager.perfjitdump.cpp: move it to the VM next to its only user,perfmap.cpp, and drop thePAL_prefix.time.cpp: delete it.PAL_nanosleep: usenanosleepdirectly in its two callers.QueryThreadCycleTime: useclock_gettime(CLOCK_THREAD_CPUTIME_ID)in the utilcode and superpmi cycle timers. DeleteGetThreadTimesInternal, which only it used, and its PAL test.GetSystemInfo: delete it and its PAL test.g_SystemInfodirectly on Unix, and trim the PALSYSTEM_INFOto the two fields that are used.minipal_getpagesizefor the page size in the DAC and metadata, andPAL_GetLogicalCpuCountFromOSfor the processor count in EventPipe and superpmi.isRetAddrand theTOP_MEMORY/BOT_MEMORYhelpers only where they are used (x86, Windows).Remove the configure checks that are left without users.
FormatMessageWmoved to #137598.