Skip to content

Support Alpha architecture for processor_count #549

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

Merged

Conversation

graaff
Copy link
Contributor

@graaff graaff commented Jul 4, 2016

Alpha machines with Linux do have /proc/cpuinfo but its format is
different from normal Linux machines, and most specifically the
processor entry is missing. Moreover, Alpha machines can be configured
to compartimentalize their CPUs into different machines leading to
further confusion when reading /proc/cpuinfo.

Using /usr/bin/nproc seems to be the most reliable method of determining
the number of processors on Alpha. Since reading /proc/cpuinfo is not
reliable this patch places the nproc method before trying /proc/cpuinfo.

For futher reference see our downstream bug report at
https://bugs.gentoo.org/show_bug.cgi?id=587986

I expect the choice of putting the nproc rule before /proc/cpuinfo may be controversial if only for the "start process" performance penalty on Linux, but given that /proc/cpuinfo returns "0" on alpha machines I didn't see another option apart from doing more rewriting.

Things that came to mind where to special-case alpha in a way similar to mingw/mswin, or to rewrite the /proc/cpuinfo check in a what tihat includes the check for /^processor/, or to rewrite the elsif mechanism to a set of separate if statements that continue as long as tentative_count = nil.

If you have preferences for any of these let me know and I can look at rewriting the PR.

Alpha machines with Linux do have /proc/cpuinfo but its format is
different from normal Linux machines, and most specifically the
processor entry is missing. Moreover, Alpha machines can be configured
to compartimentalize their CPUs into different machines leading to
further confusion when reading /proc/cpuinfo.

Using /usr/bin/nproc seems to be the most reliable method of determining
the number of processors on Alpha. Since reading /proc/cpuinfo is not
reliable this patch places the nproc method before trying /proc/cpuinfo.

For futher reference see our downstream bug report at
https://bugs.gentoo.org/show_bug.cgi?id=587986
@jdantonio
Copy link
Member

Thank you!

@jdantonio jdantonio merged commit c782b26 into ruby-concurrency:master Jul 5, 2016
@graaff graaff deleted the alpha-processor-count-support branch November 7, 2016 19:36
graaff added a commit to graaff/concurrent-ruby that referenced this pull request Nov 7, 2016
This re-orders the checks for the processor count so that forking is
only done when needed. alpha-linux does not support the processor entry
in /proc/cpuinfo so we must catch that case and fall back to using nproc
which does work on alpha.

This is a rework of ruby-concurrency#549 based on suggestions made in ruby-concurrency#576
pitr-ch pushed a commit to matthewd/concurrent-ruby that referenced this pull request Nov 10, 2016
This re-orders the checks for the processor count so that forking is
only done when needed. alpha-linux does not support the processor entry
in /proc/cpuinfo so we must catch that case and fall back to using nproc
which does work on alpha.

This is a rework of ruby-concurrency#549 based on suggestions made in ruby-concurrency#576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants