Skip to content

ThreadPoolWorkQueue.numOutstandingThreadRequests is not being padded as requested, despite the explicit sequential layout #38215

@kouvel

Description

@kouvel

Jitted code generated for ThreadPoolWorkQueue.EnsureThreadRequested shows that the offset to the field is not cache-line separated from prior fields as requested.

Replacing the field declaration with the following seems to work as expected:

        [StructLayout(LayoutKind.Sequential)]
        private struct CacheLineSeparated
        {
            private readonly Internal.PaddingFor32 pad1;

            public volatile int numOutstandingThreadRequests;

            private readonly Internal.PaddingFor32 pad2;
        }

        private CacheLineSeparated _separated;

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedNew issue has not been triaged by the area owner

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions