Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10611] ProcessInfo.activeProcessorCount too high in containerized Linux #4714

Closed
zwaldowski opened this issue May 3, 2019 · 1 comment
Assignees
Labels

Comments

@zwaldowski
Copy link

Previous ID SR-10611
Radar None
Original Reporter @zwaldowski
Type Bug
Status Resolved
Resolution Done
Environment

Linux 5e26e3cddd2b 4.15.0-1035-aws #37-Ubuntu SMP Mon Mar 18 16:15:14 UTC 2019 x86_64 Linux

Docker: 18.09.1

Swift: 5.0.1

Additional Detail from JIRA
Votes 0
Component/s Foundation, Package Manager
Labels Bug
Assignee @spevans
Priority Medium

md5: 4f042c19156dc727b189f6d17bffe19f

Issue Description:

ProcessInfo.activeProcessorCount (via __CFActiveProcessorCount(0)) uses sysconf(_SC_NPROCESSORS_ONLN). This result is undesirably high when in a managed environment, like a Docker container: it returns the online CPU count of the system as a whole, which may not respect quotas put in place by an administrator using cgroups. This may lead to Swift code (including Swift Package Manager, and thus the building of Swift code) being terminated unexpectedly because it's trying to parallelize too aggressively.

Expected Results:
The active processor count reflects a value appropriate for the execution context.

Actual Results:
swift build intermittently gets killed by the system when running under some CI platforms.

Prior art:
Mono: https://bugzilla.xamarin.com/show_bug.cgi?id=39279
.NET CLR: https://github.com/dotnet/coreclr/issues/10690
Java: https://bugs.openjdk.java.net/browse/JDK-8146115

@spevans
Copy link

spevans commented May 3, 2019

Potential solution: apple/swift-corelibs-foundation#2215

cc ianpartridge (JIRA User)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants