WebKit Bugzilla
Attachment 342601 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-20180612181543.patch (text/plain), 6.23 KB, created by
Leo Balter
on 2018-06-12 15:15:44 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Leo Balter
Created:
2018-06-12 15:15:44 PDT
Size:
6.23 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..8f4860178b6aee5d5a9a656df853f78919deaf57 100755 >--- a/Tools/Scripts/test262/Runner.pm >+++ b/Tools/Scripts/test262/Runner.pm >@@ -37,6 +37,7 @@ use File::Temp qw(tempfile tempdir); > use File::Spec::Functions qw(abs2rel); > use File::Basename qw(dirname); > use File::Path qw(mkpath); >+use List::Util qw(min max); > use Cwd qw(abs_path); > use FindBin; > use Env qw(DYLD_FRAMEWORK_PATH); >@@ -74,7 +75,7 @@ if (eval {require Pod::Usage; 1;}) { > } > > # Commandline settings >-my $max_process; >+my $maxProcesses; > my @cliTestDirs; > my $verbose; > my $JSC; >@@ -125,7 +126,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 +245,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; >@@ -301,52 +302,91 @@ sub main { > } > } > >- # If we are processing many files, fork process >- if (scalar @files > $max_process * 5) { >+ my $pm = Parallel::ForkManager->new($maxProcesses); > >- # 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 @children; >+ my @parents; > >- my $pm = Parallel::ForkManager->new($max_process); >- my $filesperprocess = int(scalar @files / $max_process); >+ my @resultsfhs; > >- 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 >+ # Open each process >+ FILES: >+ foreach (0..$maxProcesses-1) { >+ my $i = $_; > >- my $first = $filesperprocess * $i; >- my $last = $i == $max_process-1 ? scalar @files : $filesperprocess * ($i+1); >+ # Make temporary files to record results >+ my ($fh, $filename) = getTempFile(); >+ my $resultsfh = $resultsfhs[$i]; >+ $resultsfh = $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 $file = shift @files; >+ chomp $file; >+ if ($file) { >+ print $child "$file\n"; >+ } else { >+ last; >+ } > >- for (my $j = $first; $j < $last; $j++) { >- processFile($files[$j], $resultsfhs[$i]); >- }; >+ $pm->start and next FILES; >+ # children will start here >+ srand(time ^ $$); # Creates a new seed for each fork >+ CHILD: >+ while (1) { >+ my $file = $parent->getline; >+ chomp $file; >+ if ($file eq 'END') { >+ last CHILD; >+ } > >- $pm->finish; # do the exit in the child process >- }; >+ processFile($file, $resultsfh); >+ print $parent "signal\n"; >+ } > >- $pm->wait_all_children; >+ print "$i closing...\n"; >+ $child->close(); >+ $pm->finish; >+ } > >- # 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]; >+ while (scalar @files) { >+ my $count = 0; >+ CHILD: >+ foreach my $child (@children) { >+ if ($child->getline) { >+ my $file = shift @files; >+ if (!$file) { >+ last CHILD; >+ } >+ chomp $file; >+ # print "sending $file to child $count\n"; >+ print $child "$file\n"; >+ } >+ $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; >+ >+ my $count = 0; >+ for my $parent (@parents) { >+ my $child = $children[$count]; >+ print $child "END\n"; >+ $parent->close(); >+ $count++; >+ } >+ >+ $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 +978,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