WebKit Bugzilla
Attachment 342681 Details for
Bug 186443
: Test262-Runner: Improve files queue to optimize CPU usage/balancing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186443-20180613152554.patch (text/plain), 6.60 KB, created by
Leo Balter
on 2018-06-13 12:25:55 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Leo Balter
Created:
2018-06-13 12:25:55 PDT
Size:
6.60 KB
patch
obsolete
>Subversion Revision: 232778 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index ab44be59a657c2f276f631243287f0214fb7472d..e1762fdbaf29a032e1939bbe3ec5d285cd2ba24d 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,15 @@ >+2018-06-08 Leo Balter <leonardo.balter@gmail.com> >+ >+ Test262-Runner: Improve files queue to optimize CPU usage/balancing >+ https://bugs.webkit.org/show_bug.cgi?id=186443 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch creates a queue manager for to keep the child process open while the parent process feed each child with test files to run. >+ * Scripts/test262/Runner.pm: >+ (processCLI): >+ (main): >+ > 2018-06-12 Valerie R Young <valerie@bocoup.com> > > test262/Runner.pm: fix one test (can't find jsc) >diff --git a/Tools/Scripts/test262/Runner.pm b/Tools/Scripts/test262/Runner.pm >index f2f412828dbc4be8a94ce7dc34760ae9ac62d741..feb129a7cfe625925b30d892a7543de6828cb559 100755 >--- a/Tools/Scripts/test262/Runner.pm >+++ b/Tools/Scripts/test262/Runner.pm >@@ -42,6 +42,8 @@ use FindBin; > use Env qw(DYLD_FRAMEWORK_PATH); > use Config; > use Time::HiRes qw(time); >+use IO::Handle; >+use IO::Select; > > my $Bin; > BEGIN { >@@ -74,7 +76,7 @@ if (eval {require Pod::Usage; 1;}) { > } > > # Commandline settings >-my $max_process; >+my $maxProcesses; > my @cliTestDirs; > my $verbose; > my $JSC; >@@ -125,7 +127,7 @@ sub processCLI { > 'j|jsc=s' => \$JSC, > 't|t262=s' => \$test262Dir, > 'o|test-only=s@' => \@cliTestDirs, >- 'p|child-processes=i' => \$max_process, >+ 'p|child-processes=i' => \$maxProcesses, > 'h|help' => \$help, > 'release' => \$release, > 'v|verbose' => \$verbose, >@@ -244,12 +246,12 @@ sub processCLI { > %filterFeatures = map { $_ => 1 } @features; > } > >- $max_process ||= getProcesses(); >+ $maxProcesses ||= getProcesses(); > > print "\n-------------------------Settings------------------------\n" > . "Test262 Dir: $test262Dir\n" > . "JSC: $JSC\n" >- . "Child Processes: $max_process\n"; >+ . "Child Processes: $maxProcesses\n"; > > print "Test timeout: $timeout\n" if $timeout; > print "DYLD_FRAMEWORK_PATH: $DYLD_FRAMEWORK_PATH\n" if $DYLD_FRAMEWORK_PATH; >@@ -266,7 +268,6 @@ sub processCLI { > print "--------------------------------------------------------\n\n"; > } > >- > sub main { > processCLI(); > >@@ -301,52 +302,107 @@ sub main { > } > } > >- # If we are processing many files, fork process >- if (scalar @files > $max_process * 5) { >+ my $pm = Parallel::ForkManager->new($maxProcesses); >+ my $select = IO::Select->new(); >+ >+ my @children; >+ my @parents; >+ my $activeChildren = 0; >+ >+ my @resultsfhs; >+ >+ # Open each process >+ PROCESSES: >+ foreach (0..$maxProcesses-1) { >+ my $i = $_; > > # Make temporary files to record results >- my @resultsfhs; >- for (my $i = 0; $i <= $max_process-1; $i++) { >- my ($fh, $filename) = getTempFile(); >- $resultsfhs[$i] = $fh; >+ my ($fh, $filename) = getTempFile(); >+ $resultsfhs[$i] = $fh; >+ >+ socketpair($children[$i], $parents[$i], 1, 1, 0); >+ my $child = $children[$i]; >+ my $parent = $parents[$i]; >+ $child->autoflush(1); >+ $parent->autoflush(1); >+ >+ # seeds each child with a file; >+ >+ my $pid = $pm->start; >+ if ($pid) { # parent >+ $select->add($child); >+ # each child starts with a file; >+ my $file = shift @files; >+ chomp $file; >+ if ($file) { >+ print $child "$file\n"; >+ $activeChildren++; >+ } >+ >+ next PROCESSES; > } > >- my $pm = Parallel::ForkManager->new($max_process); >- my $filesperprocess = int(scalar @files / $max_process); >+ # children will start here >+ srand(time ^ $$); # Creates a new seed for each fork >+ CHILD: >+ while (<$parent>) { >+ my $file = $_; >+ chomp $file; >+ if ($file eq 'END') { >+ last; >+ } > >- FILES: >- for (my $i = 0; $i <= $max_process-1; $i++) { >- $pm->start and next FILES; # do the fork >- srand(time ^ $$); # Creates a new seed for each fork >+ processFile($file, $resultsfhs[$i]); >+ print $parent "signal\n"; >+ } > >- my $first = $filesperprocess * $i; >- my $last = $i == $max_process-1 ? scalar @files : $filesperprocess * ($i+1); >+ $child->close(); >+ $pm->finish; >+ } > >- for (my $j = $first; $j < $last; $j++) { >- processFile($files[$j], $resultsfhs[$i]); >- }; >+ my @ready; >+ FILES: >+ while ($activeChildren and @ready = $select->can_read($timeout)) { >+ foreach (@ready) { >+ my $readyChild = $_; >+ my $childMsg = <$readyChild>; >+ chomp $childMsg; >+ $activeChildren--; >+ my $file = shift @files; >+ if ($file) { >+ chomp $file; >+ print $readyChild "$file\n"; >+ $activeChildren++; >+ } elsif (!$activeChildren) { >+ last FILES; >+ } >+ } >+ } > >- $pm->finish; # do the exit in the child process >- }; >+ foreach (@children) { >+ print $_ "END\n"; >+ } > >- $pm->wait_all_children; >+ foreach (@parents) { >+ $_->close(); >+ } > >- # Read results from file into @results and close >- for (my $i = 0; $i <= $max_process-1; $i++) { >- seek($resultsfhs[$i], 0, 0); >- push @results, LoadFile($resultsfhs[$i]); >- close $resultsfhs[$i]; >- } >+ my $count = 0; >+ for my $parent (@parents) { >+ my $child = $children[$count]; >+ print $child "END\n"; >+ $parent->close(); >+ $count++; > } >- # Otherwising, running sequentially is fine >- else { >- my ($resfh, $resfilename) = getTempFile(); >- foreach my $file (@files) { >- processFile($file, $resfh); >- }; >- seek($resfh, 0, 0); >- @results = LoadFile($resfh); >- close $resfh; >+ >+ $pm->wait_all_children; >+ >+ # Read results from file into @results and close >+ foreach (0..$maxProcesses-1) { >+ my $i = $_; >+ seek($resultsfhs[$i], 0, 0); >+ push @results, LoadFile($resultsfhs[$i]); >+ close $resultsfhs[$i]; > } > > close $deffh; >@@ -938,7 +994,7 @@ Print a brief help message and exits. > > =item B<--child-processes, -p> > >-Specify number of child processes. >+Specify the number of child processes. > > =item B<--t262, -t> >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186443
:
342318
|
342324
|
342601
|
342602
|
342607
|
342646
|
342681
|
342699
|
342745
|
342782
|
342934
|
342951