Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 70cf892

Browse files
committed
ExtUtils-Constant: Update to 0.23_07
Benchmarks Recommended is either PROXYSUBS with a small number of constants or PROXYSUBS autoload with many.
1 parent 239c9a1 commit 70cf892

File tree

12 files changed

+129
-18
lines changed

12 files changed

+129
-18
lines changed

Porting/Maintainers.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ package Maintainers;
617617

618618
'ExtUtils::Constant' => {
619619
# Upstream broken
620-
'DISTRIBUTION' => 'RURBAN/ExtUtils-Constant-0.23_06.tar.gz',
620+
'DISTRIBUTION' => 'RURBAN/ExtUtils-Constant-0.23_07.tar.gz',
621621
'FILES' => q[dist/ExtUtils-Constant],
622622
'EXCLUDED' => [
623623
qw( lib/ExtUtils/Constant/Aaargh56Hash.pm

dist/ExtUtils-Constant/README

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ use branch tables making the initial switch statements more efficient, and
3838
choosing a switch strategy to minimise the amount of linear searching of
3939
similar constant names.
4040

41-
For a lot of macros memory and speed is still not comparable to
41+
The best option seems to be PROXYSUBS without options, with the highest speed
42+
and on the lower side of memory usage.
43+
With a lot of macros, memory and speed is still not comparable to
4244
specialized perfect hashes, such as XSConfig or Win32::GUI::Constants
43-
though, but is good enough for POSIX or Sockets.
45+
though, but it is good enough for POSIX or Sockets.
4446

4547
I believe ExtUtils::Constant is completely Unicode safe, but as a consequence
4648
of running various pathological cases as regression tests, the tests will

dist/ExtUtils-Constant/lib/ExtUtils/Constant.pm

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ExtUtils::Constant;
22
use vars qw (@ISA $VERSION @EXPORT_OK %EXPORT_TAGS);
3-
$VERSION = '0.23_06';
3+
$VERSION = '0.23_07';
44
$VERSION = eval $VERSION;
55

66
=head1 NAME
@@ -594,6 +594,55 @@ __END__
594594
595595
=back
596596
597+
=head1 PERFORMANCE
598+
599+
You can calculate simple performance numbers with
600+
C<perl -Mblib t/Constant.t --bench --memtest >/dev/null 2>bench.lst>
601+
and C<grep ^# bench.lst> for 19 constants.
602+
603+
Option Memory [b] Time [s]
604+
<none> 1612758 0.023946
605+
PROXYSUBS 1593553 0.020061
606+
PROXYSUBS autoload 1588555 0.024906
607+
PROXYSUBS push 1608709 0.023361
608+
PROXYSUBS
609+
croak_on_error 1590267 0.023052
610+
PROXYSUBS
611+
croak_on_read 1599747 0.021710
612+
PROXYSUBS
613+
autoload push 1589737 0.021917
614+
PROXYSUBS
615+
croak_on_error push 1590606 0.021669
616+
617+
PROXYSUBS without any option is the fastest, and on the lower
618+
side of memory.
619+
620+
PROXYSUBS autoload is the slowest, but easiest to use.
621+
622+
The old method without PROXYSUBS uses the most memory and is 2nd slowest.
623+
624+
But with >500 constants the picture changes, with PROXYSUBS alone being
625+
the slowest, and PROXYSUBS autoload together with no options being the fastest,
626+
whilst with no options still using by far the most memory.
627+
628+
Option Memory [b] Time [s]
629+
<none> 2572650 0.025867
630+
PROXYSUBS 2145701 0.032594
631+
PROXYSUBS autoload 2133418 0.025888
632+
PROXYSUBS push 2173807 0.037089
633+
PROXYSUBS
634+
croak_on_error 2142773 0.026721
635+
PROXYSUBS
636+
croak_on_read 2145648 0.027261
637+
PROXYSUBS
638+
autoload push 2161453 0.026756
639+
PROXYSUBS
640+
croak_on_error push 2170791 0.026831
641+
642+
There are no numbers compared to perfect hashes yet. The estimation is
643+
that EU-C is ~50% slower and bigger, as seen with L<Win32::GUI::Constants>
644+
and L<XSConfig>. See also L<Perfect::Hash>.
645+
597646
=head1 AUTHOR
598647
599648
Reini Urban <rurban@cpan.org> fixed up ProxySubs and took over maintainance.

dist/ExtUtils-Constant/lib/ExtUtils/Constant/Base.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use vars qw($VERSION);
55
use Carp;
66
use Text::Wrap;
77
use ExtUtils::Constant::Utils qw(C_stringify perl_stringify);
8-
$VERSION = '0.23_06';
8+
$VERSION = '0.23_07';
99

1010
use constant is_perl56 => ($] < 5.007 && $] > 5.005_50);
1111

dist/ExtUtils-Constant/lib/ExtUtils/Constant/ProxySubs.pm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use strict;
33
use vars qw($VERSION @ISA %type_to_struct %type_from_struct %type_to_sv
44
%type_to_C_value %type_is_a_problem %type_num_args
55
%type_temporary);
6-
$VERSION = '0.23_06';
6+
$VERSION = '0.23_07';
77
@ISA = 'ExtUtils::Constant::XS';
88

99
=head1 NAME
@@ -503,8 +503,13 @@ BOOT:
503503
HV *symbol_table = get_hv("$symbol_table", GV_ADD);
504504
EOBOOT
505505
if ($push) {
506+
# silence cperl-only Used once warnings
506507
print $xs_fh <<"EOC";
508+
#ifndef USE_CPERL
507509
AV *push = get_av(\"$push\", GV_ADD);
510+
#else
511+
AV *push = get_av(\"$push\", GV_ADD|GV_ADDMULTI);
512+
#endif
508513
HE *he;
509514
EOC
510515
}

dist/ExtUtils-Constant/lib/ExtUtils/Constant/Utils.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use Carp;
66

77
@ISA = 'Exporter';
88
@EXPORT_OK = qw(C_stringify perl_stringify);
9-
$VERSION = '0.23_06';
9+
$VERSION = '0.23_07';
1010

1111
use constant is_perl55 => ($] < 5.005_50);
1212
use constant is_perl56 => ($] < 5.007 && $] > 5.005_50);

dist/ExtUtils-Constant/lib/ExtUtils/Constant/XS.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require ExtUtils::Constant::Base;
1010
@ISA = qw(ExtUtils::Constant::Base Exporter);
1111
@EXPORT_OK = qw(%XS_Constant %XS_TypeSet);
1212

13-
$VERSION = '0.23_06';
13+
$VERSION = '0.23_07';
1414

1515
$is_perl56 = ($] < 5.007 && $] > 5.005_50);
1616

dist/ExtUtils-Constant/t/Constant.t

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ my $do_utf_tests = $] > 5.006;
2626
my $better_than_56 = $] > 5.007;
2727
# For debugging.
2828
my $keep_files = grep /^--keep-files$/, @ARGV;
29+
30+
# Usage: perl -Mblib t/Constant.t --bench --memtest >/dev/null
31+
# Performance
32+
my $bench = grep /^--bench$/, @ARGV;
33+
# vs Memory usage
34+
my $memtest = grep /^--memtest$/, @ARGV;
35+
if ( $memtest and !can_run("valgrind") ) {
36+
print "# valgrind not found. disabled --memtest\n";
37+
}
2938
$| = 1;
3039

3140
# Because were are going to be changing directory before running Makefile.PL
@@ -278,6 +287,30 @@ sub build_and_run {
278287
}
279288
}
280289

290+
if ($memtest) {
291+
$maketest = "valgrind --tool=massif --massif-out-file=memtest \"$^X\" -Mblib test.pl";
292+
print "# make memcheck = '$maketest'\n";
293+
system "$maketest 2>/dev/null";
294+
open MASSIF, "memtest";
295+
my $mem_heap = 0;
296+
while(<MASSIF>) {
297+
my ($mem) = ($_ =~ /^mem_heap_B=(\d+)/);
298+
$mem_heap = $mem if $mem and $mem > $mem_heap;
299+
}
300+
close MASSIF;
301+
print STDERR "# memtest: $mem_heap\n";
302+
unlink "memtest";
303+
}
304+
if ($bench) {
305+
require Time::HiRes;
306+
$maketest = "\"$^X\" -Mblib test.pl";
307+
print "# make bench = '$maketest'\n";
308+
my $t0 = [Time::HiRes::gettimeofday()];
309+
system $maketest;
310+
my $time = Time::HiRes::tv_interval($t0);
311+
print STDERR "# bench: $time\n";
312+
}
313+
281314
my $makeclean = "$make clean";
282315
print "# make = '$makeclean'\n";
283316
@makeout = `$makeclean`;
@@ -362,6 +395,10 @@ sub write_and_run_extension {
362395

363396
my $c = tie *C, 'TieOut';
364397
my $xs = tie *XS, 'TieOut';
398+
my %options;
399+
if ($wc_args and ref $wc_args->[1]) {
400+
$options{$_} = 1 for keys %{$wc_args->[1]};
401+
}
365402

366403
ExtUtils::Constant::WriteConstants
367404
(C_FH => \*C,
@@ -391,7 +428,11 @@ sub write_and_run_extension {
391428
}
392429
};
393430

394-
print "# $name\n# $dir/$subdir being created for $p_args ...\n";
431+
if ($bench or $memtest) {
432+
print STDERR "# $name\n# $dir/$subdir being created for $p_args ...\n";
433+
} else {
434+
print "# $name\n# $dir/$subdir being created for $p_args ...\n";
435+
}
395436
mkdir $subdir, 0777 or die "mkdir: $!\n";
396437
chdir $subdir or die $!;
397438

@@ -454,7 +495,7 @@ EOT
454495
print FH "\t$_\n" foreach (@$export_names);
455496
print FH ");\n";
456497
# Print the AUTOLOAD subroutine ExtUtils::Constant generated for us
457-
print FH autoload ($package, $]);
498+
print FH autoload ($package, $]) unless $options{autoload};
458499
print FH "bootstrap $package \$VERSION;\n1;\n__END__\n";
459500
close FH or die "close $pm: $!\n";
460501

@@ -541,6 +582,11 @@ foreach my $args (@args)
541582
{
542583
# Simple tests
543584
start_tests();
585+
my %options;
586+
if ($args and ref $args->[1]) {
587+
$options{$_} = 1 for keys %{$args->[1]};
588+
}
589+
544590
my $parent_rfc1149 =
545591
'A Standard for the Transmission of IP Datagrams on Avian Carriers';
546592
# Test the code that generates 1 and 2 letter name comparisons.
@@ -563,6 +609,15 @@ foreach my $args (@args)
563609
#define perl "rules"
564610
EOT
565611

612+
if ($bench) {
613+
for (0..500) {
614+
my $key = '';
615+
$key .= chr(ord('A')+int(rand(57))) for 0..3+int(rand(6));
616+
$key =~ s/\W//g;
617+
$compass{$key} = int(rand(6));
618+
}
619+
}
620+
566621
while (my ($point, $bearing) = each %compass) {
567622
$header .= "#define $point $bearing\n"
568623
}

dist/Module-CoreList/lib/Module/CoreList.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14743,11 +14743,11 @@ our %delta = (
1474314743
'CPAN::Distribution' => '2.18_01',
1474414744
'Cpanel::JSON::XS' => '3.0231',
1474514745
'Cwd' => '4.67c',
14746-
'ExtUtils::Constant' => '2.23_06',
14747-
'ExtUtils::Constant::Base' => '2.23_06',
14748-
'ExtUtils::Constant::ProxySubs' => '2.23_06',
14749-
'ExtUtils::Constant::Utils' => '2.23_06',
14750-
'ExtUtils::Constant::XS' => '2.23_06',
14746+
'ExtUtils::Constant' => '2.23_07',
14747+
'ExtUtils::Constant::Base' => '2.23_07',
14748+
'ExtUtils::Constant::ProxySubs' => '2.23_07',
14749+
'ExtUtils::Constant::Utils' => '2.23_07',
14750+
'ExtUtils::Constant::XS' => '2.23_07',
1475114751
'ExtUtils::Install' => '2.04_01',
1475214752
'ExtUtils::ParseXS' => '3.34_02',
1475314753
'ExtUtils::ParseXS::Constants' => '3.34_02',

pod/perlcdelta.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ warnings has been to restricted to the four magic names "EXPORT",
12081208
with "EXPORT" will now throw the "used only once" warning as all other
12091209
symbols.
12101210

1211-
=item ExtUtils-Constant 0.23_06
1211+
=item ExtUtils-Constant 0.23_07
12121212

12131213
Fix ProxySubs to generate code also valid for 5.6 - 5.14.
12141214
Add testcases for all ProxySubs options.

0 commit comments

Comments
 (0)