Skip to content

Commit ac6fd5b

Browse files
committed
v2.3 - Dependency versions, show perl multi/thread
1 parent 3f05587 commit ac6fd5b

File tree

7 files changed

+118
-30
lines changed

7 files changed

+118
-30
lines changed

Changes

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Revision history for Benchmark-DKbench
22

3+
2.3 2023-09-25
4+
- Show Perl threads/multi config.
5+
- Minimum module version for passing benchmarks.
6+
- Improvements for Strawberry Perl (prefer the much faster WSL though - or at least cygwin).
7+
38
2.2 2023-09-21
49
- Time::Piece test is optional for all platforms.
510
- Switched to monotonic clock instead of wall.

Makefile.PL

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,27 @@ my %WriteMakefileArgs = (
3030
PREREQ_PM => {
3131
'Astro::Coord::Constellations' => '0',
3232
'Astro::Coord::Precession' => '0',
33+
'CryptX' => '0.067',
3334
'Crypt::JWT' => '0.032',
3435
'CSS::Inliner' => '0',
35-
'DateTime' => '0',
36+
'DateTime' => '1.52',
3637
'DBD::Mock' => '0',
37-
'DBI' => '0',
38+
'DBI' => '1.642',
3839
'File::ShareDir' => '0',
3940
'HTML::FormatText' => '0',
4041
'HTML::Parser' => '0',
4142
'HTML::TreeBuilder' => '0',
42-
'Imager' => '1',
43+
'Imager' => '1.007',
4344
'Image::PHash' => '0.3',
44-
'JSON::XS' => '0',
45+
'JSON::XS' => '4.0',
4546
'Math::MatrixReal' => '0',
4647
'Math::DCT' => '0',
47-
'Moose' => '0',
48+
'Moose' => '2.2005',
4849
'MCE::Loop' => '0',
4950
'SQL::Inserter' => '0',
5051
'SQL::Abstract::Classic' => '0',
5152
'System::CPU' => '0',
52-
'System::Info' => '0',
53+
'System::Info' => '0.057',
5354
'Test::Harness' => '0',
5455
'Test::Requires' => '0',
5556
'Text::Levenshtein::XS' => '0',

README.md

+37-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ scenario.
2828

2929
# INSTALLATION
3030

31+
See the ["setup\_dkbench"](#setup_dkbench) script below for more on the installation of a couple
32+
of optional benchmarks and standardizing your benchmarking environment, otherwise
33+
here are some general guidelines for verious systems.
34+
35+
## Linux / WSL etc
36+
3137
The only non-CPAN software required to install/run the suite is a build environment
3238
for the C/XS modules (C compiler, make etc.) and Perl. On the most popular Linux
3339
package managers you can easily set up such an environment (as root or with sudo):
@@ -45,8 +51,34 @@ root/sudo is the easiest, will install for all users):
4551

4652
cpanm -n Benchmark::DKbench
4753

48-
See the `setup_dkbench` script below for more on the installation of a couple of
49-
optional benchmarks and standardizing your benchmarking environment.
54+
## Solaris
55+
56+
You will need to install the Oracle Solaris Studio development package to have a
57+
compiler environment, and to add its `bin` directory to your PATH, before installing
58+
the benchmark suite.
59+
60+
## Strawberry Perl
61+
62+
If you are on Windows, you should be using the Windows Subsystem for Linux (WSL)
63+
for running Perl or, if you can't (e.g. old Windows verions), cygwin instead.
64+
The suite should still work on Strawberry Perl, as long as you don't try to run
65+
tests when installing (some dependencies will not pass them). The simplest way is
66+
with [App::cpanminus](https://metacpan.org/pod/App%3A%3Acpanminus) (most Strawberry Perl verions have it installed):
67+
68+
cpanm -n Benchmark::DKbench
69+
70+
otherwise with the base CPAN shell:
71+
72+
perl -MCPAN -e shell
73+
74+
> notest install Benchmark::DKbench
75+
76+
and then note that the scripts get the batch extension appended, so `dkbench.bat`
77+
runs the suite (and `setup_dkbench.bat` can assist with module versions, optional
78+
benchmarks etc.).
79+
80+
Be aware that Strawberry Perl is slower, on my test system I get almost 50% slower
81+
performance than WSL and 30% slower than cygwin.
5082

5183
# SCRIPTS
5284

@@ -88,7 +120,8 @@ multi vs single threaded scalability.
88120

89121
The scores are calibrated such that a reference CPU (Intel Xeon Platinum 8481C -
90122
Sapphire Rapids) would achieve a score of 1000 in a single-core benchmark run using
91-
the default software configuration (Linux/Perl 5.36.0 with reference CPAN modules).
123+
the default software configuration (Linux/Perl 5.36.0 built with multiplicity and
124+
threads, with reference CPAN module versions).
92125

93126
The multi-thread scalability should approach 100% if each thread runs on a full core
94127
(i.e. no SMT), and the core can maintain the clock speed it had on the single-thread
@@ -106,7 +139,7 @@ there is an option to disable it, which forces a single-thread run.
106139
Simple installer to check/get the reference versions of CPAN modules and download
107140
the Genbank data file required for the BioPerl benchmarks of the DKbench suite.
108141

109-
It assumes that you have some software already installed (see INSTALLATION above),
142+
It assumes that you have some software already installed (see ["INSTALLATION"](#installation) above),
110143
try `setup_dkbench --help` will give you more details.
111144

112145
setup_dkbench [--force --sudo --test --data=s --help]

dkbench

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ if ($opt{threads} || !$max_threads || $max_threads == 1) {
112112
}
113113

114114
sub check_kit {
115-
warn "! Perl version v5.36.0 recommended as a comparison base\n"
115+
warn "! Perl version v5.36 recommended as a comparison base\n"
116116
unless $^V =~ /v5.36.\d/;
117117

118118
my %mod_ver = Benchmark::DKbench::Setup::cpan_versions();
@@ -123,7 +123,7 @@ sub check_kit {
123123
my $ver = eval "\$${module}::VERSION" || 'none';
124124
unless ($ver eq $mod_ver{$module}) {
125125
my $msg = "! $module $mod_ver{$module} recommended as a comparison base ($ver found).";
126-
$msg .= " Older installed versions may cause issues to benchmarks."
126+
$msg .= " Older versions may show benchmark failures."
127127
if $mod_ver{$module} cmp $ver; # $ver is less
128128
if ($module =~ /^Bio/ && $ver eq 'none') {
129129
$opt{skip_bio} = 1;

lib/Benchmark/DKbench.pm

+52-11
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package Benchmark::DKbench;
33
use strict;
44
use warnings;
55

6+
use Config;
67
use Digest;
78
use Digest::MD5 qw(md5_hex);
89
use Encode;
910
use File::Spec::Functions;
1011
use List::Util qw(min max sum);
11-
use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
12+
use Time::HiRes qw(CLOCK_MONOTONIC);
1213
use Time::Piece;
1314

1415
use Astro::Coord::Constellations 'constellation_for_eq';
@@ -35,10 +36,11 @@ use Text::Levenshtein::Damerau::XS;
3536
use Text::Levenshtein::XS;
3637

3738
use Exporter 'import';
38-
our @EXPORT = qw(system_identity suite_run calc_scalability);
39-
our $datadir = dist_dir("Benchmark-DKbench");
39+
our @EXPORT = qw(system_identity suite_run calc_scalability);
40+
our $datadir = dist_dir("Benchmark-DKbench");
41+
my $mono_clock = $^O !~ /win/i || $Time::HiRes::VERSION >= 1.9764;
4042

41-
our $VERSION = '2.2';
43+
our $VERSION = '2.3';
4244

4345
=head1 NAME
4446
@@ -70,6 +72,12 @@ scenario.
7072
7173
=head1 INSTALLATION
7274
75+
See the L</"setup_dkbench"> script below for more on the installation of a couple
76+
of optional benchmarks and standardizing your benchmarking environment, otherwise
77+
here are some general guidelines for verious systems.
78+
79+
=head2 Linux / WSL etc
80+
7381
The only non-CPAN software required to install/run the suite is a build environment
7482
for the C/XS modules (C compiler, make etc.) and Perl. On the most popular Linux
7583
package managers you can easily set up such an environment (as root or with sudo):
@@ -87,8 +95,34 @@ root/sudo is the easiest, will install for all users):
8795
8896
cpanm -n Benchmark::DKbench
8997
90-
See the C<setup_dkbench> script below for more on the installation of a couple of
91-
optional benchmarks and standardizing your benchmarking environment.
98+
=head2 Solaris
99+
100+
You will need to install the Oracle Solaris Studio development package to have a
101+
compiler environment, and to add its C<bin> directory to your PATH, before installing
102+
the benchmark suite.
103+
104+
=head2 Strawberry Perl
105+
106+
If you are on Windows, you should be using the Windows Subsystem for Linux (WSL)
107+
for running Perl or, if you can't (e.g. old Windows verions), cygwin instead.
108+
The suite should still work on Strawberry Perl, as long as you don't try to run
109+
tests when installing (some dependencies will not pass them). The simplest way is
110+
with L<App::cpanminus> (most Strawberry Perl verions have it installed):
111+
112+
cpanm -n Benchmark::DKbench
113+
114+
otherwise with the base CPAN shell:
115+
116+
perl -MCPAN -e shell
117+
118+
> notest install Benchmark::DKbench
119+
120+
and then note that the scripts get the batch extension appended, so C<dkbench.bat>
121+
runs the suite (and C<setup_dkbench.bat> can assist with module versions, optional
122+
benchmarks etc.).
123+
124+
Be aware that Strawberry Perl is slower, on my test system I get almost 50% slower
125+
performance than WSL and 30% slower than cygwin.
92126
93127
=head1 SCRIPTS
94128
@@ -130,7 +164,8 @@ multi vs single threaded scalability.
130164
131165
The scores are calibrated such that a reference CPU (Intel Xeon Platinum 8481C -
132166
Sapphire Rapids) would achieve a score of 1000 in a single-core benchmark run using
133-
the default software configuration (Linux/Perl 5.36.0 with reference CPAN modules).
167+
the default software configuration (Linux/Perl 5.36.0 built with multiplicity and
168+
threads, with reference CPAN module versions).
134169
135170
The multi-thread scalability should approach 100% if each thread runs on a full core
136171
(i.e. no SMT), and the core can maintain the clock speed it had on the single-thread
@@ -148,7 +183,7 @@ there is an option to disable it, which forces a single-thread run.
148183
Simple installer to check/get the reference versions of CPAN modules and download
149184
the Genbank data file required for the BioPerl benchmarks of the DKbench suite.
150185
151-
It assumes that you have some software already installed (see INSTALLATION above),
186+
It assumes that you have some software already installed (see L</"INSTALLATION"> above),
152187
try C<setup_dkbench --help> will give you more details.
153188
154189
setup_dkbench [--force --sudo --test --data=s --help]
@@ -368,7 +403,9 @@ sub system_identity {
368403
my $arch = System::CPU::get_arch || '';
369404
$arch = " ($arch)" if $arch;
370405
print "--------------- Software ---------------\nDKbench v$VERSION\n";
371-
print "Perl $^V\n";
406+
printf "Perl $^V (%sthreads, %smulti)\n",
407+
$Config{usethreads} ? '' : 'no ',
408+
$Config{usemultiplicity} ? '' : 'no ',;
372409
print "OS: $osn\n--------------- Hardware ---------------\n";
373410
print "CPU type: $model$arch\n";
374411
print "CPUs: $ncpu";
@@ -507,9 +544,9 @@ sub bench_run {
507544
my ($benchmark, $srand) = @_;
508545
$srand //= 1;
509546
srand($srand); # For repeatability
510-
my $t0 = clock_gettime(CLOCK_MONOTONIC);
547+
my $t0 = _get_time();
511548
my $out = $benchmark->[2]->($benchmark->[3]);
512-
my $time = sprintf("%.3f", clock_gettime(CLOCK_MONOTONIC)-$t0);
549+
my $time = sprintf("%.3f", _get_time()-$t0);
513550
my $r = $out eq $benchmark->[0] ? 'Pass' : "Fail ($out)";
514551
return $time, $r;
515552
}
@@ -1218,6 +1255,10 @@ sub _decode_jwt2 {
12181255
return $payload;
12191256
}
12201257

1258+
sub _get_time {
1259+
return $mono_clock ? Time::HiRes::clock_gettime(CLOCK_MONOTONIC) : Time::HiRes::time();
1260+
}
1261+
12211262
# Helper package for Moose benchmark
12221263

12231264
{

setup_dkbench

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ may show 'Fail' under Pass/Fail and scores may not be comparable to the baseline
3131
This might be perfectly fine for your purposes - in fact it might be intended if
3232
you are benchmarking to compare different software instead of hardware.
3333
34-
This installer assumes you have at least cpanm already installed
35-
(C<curl -L https://cpanmin.us | perl - --sudo App::cpanminus>).
34+
This installer assumes you have at least cpanm (L<App::cpanminus>) already installed.
35+
If not, on must systems you can do that with:
36+
37+
# System-wide with sudo:
38+
curl -L https://cpanmin.us | perl - --sudo App::cpanminus
39+
40+
# Locally or system-wide when root
41+
curl -L https://cpanmin.us | perl - App::cpanminus
3642
3743
You will also need to have a build enviroment set up (compiler, make etc). If you
3844
want to add a couple of optional BioPerl bencharks you'd want an XML library in
@@ -62,6 +68,8 @@ version lower than 5.14 make sure you install L<IO::Socket::IP> 0.41 or lower fi
6268
6369
cpanm -n http://cpan.metacpan.org/authors/id/P/PE/PEVANS/IO-Socket-IP-0.41.tar.gz
6470
71+
Some benchmarks will report failure on "ancient" Perls.
72+
6573
=cut
6674

6775
use strict;

t/simple.t

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use File::ShareDir 'dist_dir';
66
my $threads;
77
my @std = capture {$threads = system_identity()};
88
like($std[0], qr/CPU/, 'System identity');
9-
warn $std[0];
9+
diag $std[0];
1010

1111
my %opt = (
1212
iter => 1,
@@ -20,21 +20,21 @@ my %opt = (
2020
my (%stats1, %stats2);
2121
@std = capture {%stats1 = suite_run({%opt, no_mce=>1})};
2222
like($std[0], qr/Overall Time/, 'Bench');
23-
warn $std[0];
23+
diag $std[0];
2424

2525
if ($threads && $threads > 1) {
2626
$opt{include} = 'Astro';
2727
$opt{ver} = 1;
2828
@std = capture {%stats2 = suite_run({%opt, threads=>2})};
29-
warn $std[0];
29+
diag $std[0];
3030
} else {
3131
%stats2 = %stats1;
3232
$stats2{threads} = 2;
3333
}
3434

3535
@std = capture {calc_scalability(\%opt, \%stats1, \%stats2)};
3636
like($std[0], qr/scalability/, 'Scalability');
37-
warn $std[0];
37+
diag $std[0];
3838

3939
@std = capture {
4040
%stats1 = suite_run({
@@ -48,7 +48,7 @@ warn $std[0];
4848
)
4949
};
5050
like($std[0], qr/Overall Avg Score/, 'Aggregate');
51-
warn $std[0];
51+
diag $std[0];
5252

5353
%stats2 = %stats1;
5454
$stats2{threads} = 2;

0 commit comments

Comments
 (0)