In perl.git, the branch smoke-me/bulk88/rt125296-wip-COPFILE-threads-withSVCHEKCOW has been created
<http://perl5.git.perl.org/perl.git/commitdiff/1234c64280dd56df0cc82732d3f339d2b41cc8bc?hp=0000000000000000000000000000000000000000> at 1234c64280dd56df0cc82732d3f339d2b41cc8bc (commit) - Log ----------------------------------------------------------------- commit 1234c64280dd56df0cc82732d3f339d2b41cc8bc Author: Daniel Dragan <[email protected]> Date: Wed Feb 24 03:48:45 2016 -0500 WIP Store CHEKs as COW SVs with offset -in hv.c prevent HEK_HASH from being used when the SV key has an offseted CHEK in it, HEK_HASH is for the full "_<" prefixed string to look up debugging globs faster on ithreads from COPs when debugging perl code with perl5db, there is not hash number acceleration for offseted HEKs -in hv.c, SvSHARED_HASH contains a SvPVX, while in some funcs, str = SvPV(sv); already ran earlier, so to avoid the extra mem deref, just use var str or its analog instead of looking into the SV head again this could be a seperate commit -in pp_ctl.c to speed up caller, a kindda high use part of perl, instead of Newx-ing a copy of cop_file, COW it, since it really is a [C]HEK under the hood, but it needs the "_<" chars stripped off. By knowing shared HEKs and CHEKs are both malloced, and therefore will always be aligned to atleast 4 bytes, because of 4 byte pointers, a very tiny "OOK" trick can be done that cuts upto 3 chars off the start of the HEK. Cutting off "_<" is only 2 chars. Reversing the HEK OOK to get the original HEK *, is a cheap "ptr &= ~0x3" CPU instruction. Carrying over the offset when copying a SV HEK COW to another SV as a HEK COW is more complicated. I've thought about whether HEK OOK should be implemented on N0_ITHREADS too, since CopFILE on NO_ITHREADS is #define CopFILE(c) (CopFILEGV(c) ? GvNAME(CopFILEGV(c))+2 : NULL) and has that "+2", and caller on NO_ITHREADS would get the same COW improvement as on USE_ITHREADS with HEK OOK. Note, the SV OOK code would corrupt the HEK's string portion and therefore HEK's hash number so the SV OOK code can't be used as is on HEKs. Perhaps with more special casing the SV OOK flag could mean something else that doesn't corrupt the HEK buffer for SvLEN=0 and SVf_IsCOW but I can't think of an implementation. -in pp_ctl.c pp_require now stores a CHEK as the value in %INC, this saves another Newx buffer of memory -in sv.c allow CHEKs and offseted [C]HEKs to propagate through ithreads, psuedoforks, and sv_setsv'es -in toke.c all the SV's created by __FILE__ token previously had unique Newxed PV buffers, they should be shared, CHEK allows them to be shared now, this saves memory, no real CPU saved since compile time happens once -This commit has no API and leaks implementation everywhere. HALP!!!! -Most of the diff lines in B.xs will disappear if this is squashed since they were created 1 commit ago -XXX create newSVhek_flags or keep the low 2 bits of ptr are "flags" thing? SVs_TEMP will also have to be added to newSVhek_flags if newSVhek_flags is ever created, like newSVpvn_flags has SVs_TEMP. M embed.fnc M ext/B/B.xs M hv.c M mro_core.c M pp_ctl.c M proto.h M sv.c M sv.h M toke.c commit 33b05fad159bd3a6bd112a626cd89837f7bff656 Author: Daniel Dragan <[email protected]> Date: Sat Feb 20 19:31:27 2016 -0500 WIP GvFILE is now a CHEK on ithreads -newGP now doesn't execute PERL_HASH doesn't covert CopFILE to a hash number, then PL_strtab lookup each time when it is making a GP/GV, now it is just upping refcount on the CHEK -GvFILE_HEK is removed from public API since with threads it would return "_<" prefixed HEK *s which breaks back compat, but GvFILE keeps back compat. -GvFILELEN added since we know this info under the hood -GvFILEGV (basically unused, only use in CORE is by B::, 1 use on CPAN, embperl) is now faster since "_<" adding doesn't need to happen with temp buffers and calling PERL_HASH -a CHEK that goes through hek_dup just has its refcount increased, not a new pointer created -teach S_unshare_hek_or_pvn how to free a HEK* that is really a CHEK* -TODO teach Perl_newSVhek how to store a CHEK * in a SV this is for caller in the future, rember about masks for drop the _< or OOK+HEK M ext/B/B.pm M ext/B/B.xs M gv.c M gv.h M hv.c M sv.c commit 36f61f9dd883bb3405bff2fd27614670dbe0afdd Author: Daniel Dragan <[email protected]> Date: Mon Feb 22 22:32:08 2016 -0500 WIP add API for refcounting CopFILE names with threads #8 This has large memory savings, test prog, perl -MTest::More -e"system 'pause'" before 2196KB Private Bytes Win 7 32 bit to after 2092KB. -On a CHEK the refcount is a U32 for memory savings on 64 bit CPUs while SHEKs are Size_t for refcount because of HE struct, on 32 bit Size_t and U32 happen to be the same thing, if there is future integration the refcount members will have to be the same type, then duping a SHEK or a CHEK is the same code, except that HVhek_COMPILING controls whether to aquire OP_REFCNT_LOCK before touching the ref count, in the future with atomic operations, the refcount can be manipulated with atomic operations regardless if it is a SHEK or CHEK since OP_REFCNT_LOCK lines were removed -TODO figure out how to do static const CHEKs, hash member must be 0 since its process specific randomized (rurban's B stores HEKs in RW static memory and fixes up the hash #s at runtime), add test and branch so that refcount isn't read and written or passed to PerlMemShared_free if static flag is on inidicating static const CHEK -TODO Perl_newGP uses CHEKs not CopFILE, no memcpy and add _< that way -TODO optimize the former alloca to smallbuf or Safefree or savestack newx free M cop.h M cv.h M embed.fnc M embed.h M ext/Devel-Peek/t/Peek.t M gv.c M gv.h M hv.c M hv.h M makedef.pl M op.c M pp_ctl.c M proto.h M scope.h M sv.c M sv.h commit 65dd9e535271a987767e4cf8d05b9d692ef918af Author: Daniel Dragan <[email protected]> Date: Wed Feb 17 02:09:29 2016 -0500 remove usage of obsolete OutCopFILE macro OutCopFILE was added in commit 248c2a4db2 in 5.7.2, and became obsolete in commit e37778c28b in 5.11.0. To allow future commits to use more varieties of CopFILE* macros around core, remove core usage of OutCopFILE. OutCopFILE can't be outright removed as CPAN grep shows some usage without a #ifndef OutCopFILE fallback. M cop.h M deb.c M pp_ctl.c M toke.c M util.c commit f676017372183e4545160ab7a6db7cda9091d2f9 Author: Daniel Dragan <[email protected]> Date: Thu Feb 11 15:21:55 2016 -0500 remove unused arg in gv_fetchfile_flags Since gv_fetchfile_flags was created in commit d9095cec1b in 5.9.5 in 2007 the flags argument has been unused and undefined as to its meaning. Remove the cpu instruction overhead of pushing the flags arg in the callers of gv_fetchfile_flags by changing it to a macro that drops out the flags argument. Only known callers are NYTProf and core's gv_fetchfile according to cpan grep. This commits sets up future refactoring of gv_fetchfile*. M embed.fnc M embed.h M gv.c M gv.h M proto.h ----------------------------------------------------------------------- -- Perl5 Master Repository
