Skip to content

Emulate sched_getaffinity #2101

@sporksmith

Description

@sporksmith

We often see warnings about software making calls to the unspported sched_getaffinity syscall. Most software recovers from it failing, but in addition to it being nice to get rid of the warning noise, some software may use the result to help decide e.g. how many worker threads to spawn.

In such cases it'd likely help simulation performance to report a small number of CPUs (e.g. 1), so that such use-cases spawn a minimal number of such worker threads. Shadow only executes one thread on a given emulated Host at once, so additional worker threads in an emulated Process won't particularly help parallelization.

For example, we get this line instderr when executing java -version using OpenJDK:

OpenJDK 64-Bit Server VM warning: sched_getaffinity failed (Function not supported)- using online processor count (12) which may exceed available processors

It'd also be useful to find where it's getting the online processor count (probably somewhere in /proc...?) and intercept that as well. From this message it looks like reporting an affinity with only 1 available processor in sched_getaffinity would be sufficient to minimize worker threads, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugError or flaw producing unexpected results

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions