diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-10-19 09:52:03 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-11-27 07:05:01 -0800 |
commit | 9fd2152b911b1c311a72e55728050bfa2fc67ca6 (patch) | |
tree | 950b43e85d3be67b4356dde499e02327ddaa844c /sv.h | |
parent | db2c6cb33ec067c880a2cb3c4efdb33f7e3e3d0f (diff) | |
download | perl-9fd2152b911b1c311a72e55728050bfa2fc67ca6.tar.gz |
Min string length for COW
We have two separate length thresholds for when copy-on-write kicks
in, one for when a buffer would have had to be (re)allocated
(SV_COW_THRESHOLD) and another for when there is already a large
enough buffer available (SV_COWBUF_THRESHOLD).
Benchmarking against mktables and against Test.Simple’s test suite
(see JS::Test::Simple on CPAN) run with WWW::Scripter and JE shows
that 0/1250 is the best combination, at least on 32-bit darwin.
Apparently, copying into an existing buffer is much faster than the
bookkeeping overhead of sv_force_normal_flags (which I see no way to
speed up).
I have defined these conditionally with #ifndef, so that platform-spe-
cific hints can override them with values appropriate to the platform.
Also, refactor things in sv_setsv_flags slightly to avoid using SvLEN
and SvCUR repeatedly.
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1853,6 +1853,12 @@ mg.c:1024: warning: left-hand operand of comma expression has no effect /* Note: To allow 256 COW "copies", a refcnt of 0 means 1. */ # define CowREFCNT(sv) (*(U8 *)(SvPVX(sv)+SvLEN(sv)-1)) # define SV_COW_REFCNT_MAX ((1 << sizeof(U8)*8) - 1) +# ifndef SV_COW_THRESHOLD +# define SV_COW_THRESHOLD 0 /* min string length for cow */ +# endif +# ifndef SV_COWBUF_THRESHOLD +# define SV_COWBUF_THRESHOLD 1250 /* min string length for cow */ +# endif /* over existing buffer */ # endif #endif /* PERL_OLD_COPY_ON_WRITE */ |