Use inline arrays in GCMemoryInfoData. - #131827
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @dotnet/area-system-runtime |
There was a problem hiding this comment.
Pull request overview
This PR updates GCMemoryInfoData to use inline arrays (InlineArray5<GCGenerationInfo> and InlineArray2<TimeSpan>) in order to avoid MemoryMarshal.CreateReadOnlySpan when exposing generation info and pause durations via ReadOnlySpan<T>.
Changes:
- Replaces the per-element backing fields for generation info and pause durations with
InlineArray5<T>/InlineArray2<T>fields. - Updates
GCMemoryInfo.PauseDurationsandGCMemoryInfo.GenerationInfoto return spans directly from the inline-array fields. - Adds
using System.Runtime.CompilerServices;for inline-array types.
|
@jkotas is there a way that we could make the runtime/src/coreclr/vm/corelib.h Lines 1445 to 1451 in 815a631 |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Try changing the C++ definition of |
|
Done, thanks. I first thought I had to encode the managed field's type in the declaration, but turns out that's not the case. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (3)
src/libraries/System.Private.CoreLib/src/System/GCMemoryInfo.cs:191
- If
GCMemoryInfoDatakeeps span accessors (to avoid exposing writable inline-array fields), this property should return the accessor rather than the backing field.
public ReadOnlySpan<GCGenerationInfo> GenerationInfo => _data._generationInfo;
src/libraries/System.Private.CoreLib/src/System/GCMemoryInfo.cs:75
- These inline-array fields were previously private (via the individual element fields). Making them
internalwidens the writable surface area for what appears to be runtime-filled layout data, and a repo-wide search shows no other managed code needs direct field access. Consider keeping the fieldsprivateand exposing internalReadOnlySpan<T>accessors (still avoidingMemoryMarshal.CreateReadOnlySpan).
internal InlineArray5<GCGenerationInfo> _generationInfo;
internal InlineArray2<TimeSpan> _pauseDurations;
src/libraries/System.Private.CoreLib/src/System/GCMemoryInfo.cs:181
- If
GCMemoryInfoDatakeeps span accessors (to avoid exposing writable inline-array fields), this property should return the accessor rather than the backing field.
This issue also appears on line 191 of the same file.
public ReadOnlySpan<TimeSpan> PauseDurations => _data._pauseDurations;
|
CI is about to get green. |
|
/ba-g Build Monitor Helix Jobs stuck |
Removes two uses of
MemoryMarshal.CreateReadOnlySpan.