Bug 38833

Summary: [chromium] detect num processors to pass to make -j on Linux
Product: WebKit Reporter: Tony Chang <tony>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, evan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Attachments:
Description Flags
Patch
none
Patch none

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.