Command-Run

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


There is an additional reason to prefer `:utf8` over
`:encoding(utf8)` in long-running processes.  Repeatedly pushing and
popping the `:encoding(utf8)` layer (which happens on each nofork
execution when opening and closing temporary files) causes a
cumulative performance degradation in Perl's PerlIO subsystem.  This
affects **all** PerlIO operations in the process, not just the ones
using the encoding layer.

In benchmarks, nofork with `:encoding(utf8)` is actually **slower**
than fork after many iterations, due to this leak.  Raw mode avoids
the issue entirely.

    # Benchmark: code ref with stdin (100-byte input, 1000 iterations)
    fork:                  399/s (baseline)
    nofork + :encoding:    316/s (0.8x — slower than fork!)
    nofork + :utf8 (raw): 13,433/s (34x faster)

## Zero-Modification Callee Integration

A key advantage of this mechanism is that **callee modules typically
require no modification** to work with nofork+raw mode.

Many Perl modules use `use open` pragma or equivalent to set up

lib/Command/Run.pm  view on Meta::CPAN


There is an additional reason to prefer C<:utf8> over
C<:encoding(utf8)> in long-running processes.  Repeatedly pushing and
popping the C<:encoding(utf8)> layer (which happens on each nofork
execution when opening and closing temporary files) causes a
cumulative performance degradation in Perl's PerlIO subsystem.  This
affects B<all> PerlIO operations in the process, not just the ones
using the encoding layer.

In benchmarks, nofork with C<:encoding(utf8)> is actually B<slower>
than fork after many iterations, due to this leak.  Raw mode avoids
the issue entirely.

    # Benchmark: code ref with stdin (100-byte input, 1000 iterations)
    fork:                  399/s (baseline)
    nofork + :encoding:    316/s (0.8x — slower than fork!)
    nofork + :utf8 (raw): 13,433/s (34x faster)

=head2 Zero-Modification Callee Integration

A key advantage of this mechanism is that B<callee modules typically
require no modification> to work with nofork+raw mode.

Many Perl modules use C<use open> pragma or equivalent to set up



( run in 0.688 second using v1.01-cache-2.11-cpan-96521ef73a4 )