Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add NUMA and thread affinity support for Unix #10938

Merged
merged 2 commits into from
Apr 19, 2017

Conversation

janvorli
Copy link
Member

This change adds new PAL functions for NUMA and thread affinity support
for Unix and also enables related code in GC and VM for FEATURE_PAL.

It doesn't reflect the limits imposed by CGROUPS on systems with
CGROUPS enables yet.

@janvorli janvorli added area-PAL os-freebsd FreeBSD OS os-linux Linux OS (any supported distro) os-mac-os-x OS-X aka Mac OS labels Apr 13, 2017
@janvorli janvorli added this to the 2.0.0 milestone Apr 13, 2017
@janvorli janvorli self-assigned this Apr 13, 2017
@janvorli janvorli requested a review from jkotas April 13, 2017 14:17
@janvorli
Copy link
Member Author

Fixes #1986

@janvorli janvorli force-pushed the unix-gc-thread-affinity-support branch 2 times, most recently from 40819cf to 2b3318a Compare April 13, 2017 14:56
@jkotas
Copy link
Member

jkotas commented Apr 13, 2017

How are we going to test this? (The NUMA part in particular.)

BOOL success = TRUE;

LOGEXIT("GetNumaProcessorNodeEx returns BOOL %d\n", success);
PERF_EXIT(GetNumaProcessorNodeEx);

Choose a reason for hiding this comment

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

nit: is this supposed to be GetNumaHighestNodeNumber?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for spotting that, I have fixed it.

@janvorli
Copy link
Member Author

@dotnet-bot test tizen armel cross debug build

@janvorli
Copy link
Member Author

@jkotas, as for the individual functions, I have tested them locally on my native Linux box that has 8 cores in two NUMA nodes. Regarding different NUMA configurations testing, some can be done on a VM. As for performance testing, I don't have a clear plan yet, ideally, we could use some real world benchmark like the techempower running on a physical machine with more processors / NUMA nodes and measure performance with the NUMA stuff enabled and disabled.

@janvorli janvorli force-pushed the unix-gc-thread-affinity-support branch from 2b3318a to fb6129e Compare April 14, 2017 07:31
This change adds new PAL functions for NUMA and thread affinity support
for Unix and also enables related code in GC and VM for FEATURE_PAL.

It doesn't reflect the limits imposed by CGROUPS on systems with
CGROUPS enables yet.
@janvorli
Copy link
Member Author

@dotnet-bot test Windows_NT x64 Debug Build and Test please

@janvorli
Copy link
Member Author

@dotnet-bot test Ubuntu arm Cross Release Build please

2 similar comments
@janvorli
Copy link
Member Author

@dotnet-bot test Ubuntu arm Cross Release Build please

@janvorli
Copy link
Member Author

@dotnet-bot test Ubuntu arm Cross Release Build please

@hseok-oh
Copy link

@dotnet-bot test Ubuntu arm Cross Release Build

@janvorli
Copy link
Member Author

@swgillespie, @adityamandaleeka could you please review?


/*++
Function:
FreeLookupArrays
Copy link
Member

Choose a reason for hiding this comment

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

AllocateLookupArrays

Copy link
Member Author

Choose a reason for hiding this comment

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

Sigh. Thank you for spotting that.


for (int i = 0; i < numaNodesCount; i++)
{
int st = numa_node_to_cpus(i, mask);
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we're not doing anything with this return value. Assert that it's 0?

Copy link
Member

Choose a reason for hiding this comment

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

Same thing below

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding assert, the only failure of this function could be that the mask is not large enough, but since the mask is allocated by the numa_allocate_cpumask function, that cannot happen.


if (currentGroupCpus != 0)
{
g_groupToCpuCount[currentGroup] = currentGroupCpus;
Copy link
Member

@adityamandaleeka adityamandaleeka Apr 19, 2017

Choose a reason for hiding this comment

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

g_groupToCpuCount[currentGroup] is set here for whatever currentGroup is when we get here. What if we filled a group and moved on to the next one in the for loop above (near line 175)?

Do we not need to set g_groupToCpuCount for those groups (and also the affinity mask below)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we do. It is missing. Thank you for spotting it.

else
{
// The process has affinity in more than one group, in such case
// the function needs to return zero in both masks.
Copy link
Member

Choose a reason for hiding this comment

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

The comment here says we need to return 0 in both masks, but unless I'm missing something we're not setting systemMask to 0, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. Thank you!

@janvorli
Copy link
Member Author

@adityamandaleeka I've reflected your feedback.

Copy link
Member

@adityamandaleeka adityamandaleeka left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-PAL os-freebsd FreeBSD OS os-linux Linux OS (any supported distro) os-mac-os-x OS-X aka Mac OS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants