Skip to content

Add sub signatures performance note to perldelta#24548

Open
bbrtj wants to merge 2 commits into
Perl:bleadfrom
bbrtj:docs/perldelta-signatures
Open

Add sub signatures performance note to perldelta#24548
bbrtj wants to merge 2 commits into
Perl:bleadfrom
bbrtj:docs/perldelta-signatures

Conversation

@bbrtj

@bbrtj bbrtj commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This adds a note to perldelta about signatures having less runtime overhead due to internal changes made to support named parameters (or so I heard).

This was discussed on IRC, and I checked that there is indeed a performance difference. Here is the benchmark code:

use v5.42;

use Benchmark qw(cmpthese);

sub s_raw { my ($x1, $x2, $x3, $x4) = @_; }
sub s_sig ($x1, $x2, $x3, $x4) {}

cmpthese -2, {
	raw => sub { s_raw($_, $_, $_, $_) for 1 .. 1000 },
	signatures => sub { s_sig($_, $_, $_, $_) for 1 .. 1000 },
};

It consistently shows raw case being ~25% faster than signatures on 5.42, and ~5% faster on compiled blead. While this is not the best way to benchmark, that much of a difference should be enough to determine that indeed signatures are now more efficient. Note that raw only serves as a base for comparison here, so that we see efficiency difference between two variants of argument unpacking, without the need to take overall perl interpreter efficiency into account.

Example results:

$ ~/localperl/bin/perl bench.pl
             Rate signatures        raw
signatures 7378/s         --        -3%
raw        7622/s         3%         --

$ perl bench.pl
             Rate signatures        raw
signatures 5183/s         --       -25%
raw        6950/s        34%         --

  • This set of changes requires a perldelta entry, and it is included.

Comment thread pod/perldelta.pod Outdated
@leonerd

leonerd commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Also while you're there, all of the entries should be their own =item lines within a single =over / =back pair, rather than have their own ones.

@bbrtj bbrtj force-pushed the docs/perldelta-signatures branch from edb6454 to b87ab20 Compare July 8, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants