-
Notifications
You must be signed in to change notification settings - Fork 561
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
Benchmark.pm uses excessive CPU on OpenBSD #13891
Comments
From jeremy.devenport@gmail.comCreated by jeremy.devenport@gmail.comThe tests for perl 5.20.0 sometimes take a very long time to run on I can reliable reproduce the failure by running lib/Benchmark.t but I perl -MBenchmark -e 'timethis(1, sub { })' OpenBSD5.5$ time ktrace -tc /tmp/perl-v5.20.0/bin/perl5.20.0 $ kdump | grep 'CALL gettimeofday' | wc -l Compare that to a linux box (also 5.20.0, configured with defaults). DebianJessie$ time strace -c perl -MBenchmark -e 'timethis(1, sub { })' real 0m0.095s I tried to track down where the time was going using some debug prints This doesn't show up on linux because gettimeofday is implemented in It looks like if that while loop in Benchmark.pm needs to stay then it Perl Info
|
From @jkeenanOn Sat May 31 18:13:26 2014, jeremy.devenport@gmail.com wrote:
Porters: Investigation and resolution of this ticket would benefit from having smoke reports run on OpenBSD. Can anyone configure this and send results to perl.develop-help.org? Thank you very much. |
The RT System itself - Status changed from 'new' to 'open' |
From @iabynOn Sat, May 31, 2014 at 06:13:26PM -0700, Jeremy Devenport wrote:
can you confirm that on your system, the following one-liner takes time perl -e'$t = (times)[0]; while ($t == (times)[0]) {}' And if so, can you find a minimum bit of 'make work' to add in the {} -- |
From andrew@afresh1.comOn Sat, Jun 07, 2014 at 03:52:52PM +0100, Dave Mitchell wrote:
I can't seem to reproduce this with stock perl-5.20.0, I tried on a couple $ sysctl kern.version hw.model hw.model=Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz This is perl 5, version 20, subversion 0 (v5.20.0) built for OpenBSD.amd64-openbsd kern.version=OpenBSD 5.5-current (GENERIC) #122: Fri May 23 21:23:59 MDT 2014 hw.model=Intel(R) Pentium(R) M processor 1.30GHz ("GenuineIntel" 686-class) This is perl 5, version 20, subversion 0 (v5.20.0) built for OpenBSD.i386-openbsd I also tried on a much slower machine, but I only have 5.20.0 plus OpenBSD's $ sysctl kern.version hw.model hw.model=AlphaStation 200 4/166 This is perl 5, version 20, subversion 0 (v5.20.0) built for alpha-openbsd |
From jeremy.devenport@gmail.com
Yes, that one-liner demonstrates the same problem of high system/user cpu usage: It also seems to be relevant that I'm running OpenBSD under $ time ./perl -Ilib -MBenchmark -e 'timethis(1, sub { }) for 1..10' $ time ./perl -e'$t = (times)[0]; while ($t == (times)[0]) {}' VMware Player It looks like FreeBSD under VirtualBox also takes longer than it Adding somewhere between 1000 and 10,000 floating point divisions into With this change: - while ( ( $t0 = Benchmark->new(0) )->[1] == $tbase ) {} ; $ time ./perl -Ilib -MBenchmark -e 'timethis(1, sub { }) for 1..10' |
From @iabynOn Sun, Jun 08, 2014 at 08:55:56AM -0400, Jeremy Devenport wrote:
I've pushed the following fix to blead: commit 78462dd Benchmark.pm: avoid long walltime on calibration Affected files ... Differences ... Inline Patchdiff --git a/lib/Benchmark.pm b/lib/Benchmark.pm
index 9a43a2b..73b3211 100644
--- a/lib/Benchmark.pm
+++ b/lib/Benchmark.pm
@@ -700,8 +700,18 @@ sub runloop {
# getting a too low initial $n in the initial, 'find the minimum' loop
# in &countit. This, in turn, can reduce the number of calls to
# &runloop a lot, and thus reduce additive errors.
+ #
+ # Note that its possible for the act of reading the system clock to
+ # burn lots of system CPU while we burn very little user clock in the
+ # busy loop, which can cause the loop to run for a very long wall time.
+ # So gradually ramp up the duration of the loop. See RT #122003
+ #
my $tbase = Benchmark->new(0)->[1];
- while ( ( $t0 = Benchmark->new(0) )->[1] == $tbase ) {} ;
+ my $limit = 1;
+ while ( ( $t0 = Benchmark->new(0) )->[1] == $tbase ) {
+ for (my $i=0; $i < $limit; $i++) { my $x = $i / 1.5 } # burn user CPU
+ $limit *= 1.1;
+ }
$subref->();
$t1 = Benchmark->new($n);
$td = &timediff($t1, $t0);
-- A walk of a thousand miles begins with a single step... |
From @bingosOn Mon, Jun 09, 2014 at 11:53:59AM +0100, Dave Mitchell wrote:
This has fixed the tardiness of this particular test on OpenBSD, NetBSD, Many thanks! --
|
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#122003 (status was 'resolved')
Searchable as RT122003$
The text was updated successfully, but these errors were encountered: