Bug 38833 - [chromium] detect num processors to pass to make -j on Linux
Summary: [chromium] detect num processors to pass to make -j on Linux
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-10 00:16 PDT by Tony Chang
Modified: 2010-05-11 20:51 PDT (History)
2 users (show)

See Also:


Attachments
Patch (1.20 KB, patch)
2010-05-10 00:17 PDT, Tony Chang
no flags Details | Formatted Diff | Diff
Patch (1.20 KB, patch)
2010-05-10 16:34 PDT, Tony Chang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Chang 2010-05-10 00:16:05 PDT
[chromium] detect num processors to pass to make -j on Linux
Comment 1 Tony Chang 2010-05-10 00:17:20 PDT
Created attachment 55523 [details]
Patch
Comment 2 Tony Chang 2010-05-10 00:18:00 PDT
Since evan knows perl, maybe he can review?  The previous code was hard coded to use -j4.
Comment 3 Evan Martin 2010-05-10 11:27:15 PDT
This looks fine to me.

I ran it by a perl-hacker friend and he suggested the following.  Note that if the grep fails for some reason in your original code your numCpus ends up being 0, which might be bad.

my $numCpus = (grep /processor/, `cat /proc/cpuinfox`) || 1;

In list context, `` splits on lines so the grep works linewise, and then when you stuff the list that grep returns into scalar context (numCpus) it gets the length of the list.  Perl is so awesome in a scary sort of way!

Your original code LGTM as well.
Comment 4 Tony Chang 2010-05-10 16:34:48 PDT
Created attachment 55620 [details]
Patch
Comment 5 Tony Chang 2010-05-10 16:35:48 PDT
Comment on attachment 55620 [details]
Patch

Updated to use perl's grep and to have a fallback in case of failure.
Comment 6 Tony Chang 2010-05-11 20:51:25 PDT
Comment on attachment 55620 [details]
Patch

Clearing flags on attachment: 55620

Committed r59201: <http://trac.webkit.org/changeset/59201>
Comment 7 Tony Chang 2010-05-11 20:51:30 PDT
All reviewed patches have been landed.  Closing bug.