-
Notifications
You must be signed in to change notification settings - Fork 580
SV PV COW 255 doesn't support strings under 9 SvCUR() bytes long #23261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't understand why COW is advantageous on small strings. |
Do you want 500 or 1000 copies of the 5 letter string "undef" in ur perl process? Plus round to 16 bytes plus 8 or 16 bytes for malloc internals, plus 24 bytes for threaded win perl? How about hv_intrnext() and list to list assignment, 500 or 1000 more copies of 5 byte string "undef", how many times is perl supposed to malloc()/free() cycle a 1 byte long string like "1" or "undef"? It's a performance problem. A profiling tool says the pvx buffer of newSVpvs(""); on win64 cost 70 bytes. Most allocs in a perl vm on the bellcurve are mid 70s bytes peaking at 82-85 bytes. So yes COW for strings 8 bytes and under are very necessary. They cost TEN times their own length in final memory cost. IdK why on win64 70 bytes is the lowest alloc perl makes, it's not a unit of eight so I'm guessing the profiler has private access to the windows malloc system and windows keeps 8 bytes behind the pointer, plus a secret 4 bytes somewhere else in address space of overhead and the other four bytes are anti-security exploit intergrity metadata. |
though this is a special case for literals and copies of them. From memory when the current CoW was introduced CoWing short strings ended up slower than doing a normal copy, YMMV for systems with a slow malloc() (looking at a certain popular non-POSIX platform). |
I'd be open or give a thumbs up, if Sending 500 or 1000 bytes of CPU instructions will go through the cpu by calling free(), just to save 50 bytes with a COW. Eghhh. Modern systems have the DDR RAM to not be that desperate over private bytes/spinning rust paging file access anymore. But COW 255 vs Newx()+memcpy bc SvPVX is empty, COW 255 should always be done. There is a huge amount of For The current COW APIs in blead, IMO have a very unoptimized path, that I made this bug ticket, since I don't know if the right logic should be to ignore the slack/waste logic if total string length <= 16 or <=8 and PVs always get COW 255 copied, or the slack/waste logic needs other algo tweaks.
1250 and 80 are the other 2 cutoffs. My complaint is about |
I've only skimmed that ticket, but the key point/blocker seemed to be that
Did that happen, or is that a task still to be done? These open issues refer to
Would we be best served by a single meta-issue that summarises the problems with |
Uh oh!
There was an error while loading. Please reload this page.
Description
from sv.c
8 bytes or smaller strings can't 255 COW because of ^^^^^ added in 5.19.12 in
#13800
e8c6a47
Author: Yves Orton [email protected]
Date: 5/11/2014 6:37:33 AM
Message:
Implement "max waste" thresholds to avoid problems with COW and deliberately overallocated pvs
https://rt.perl.org/Ticket/Display.html?id=121796
Steps to Reproduce
Expected behavior
That tiny strings can SVPV 255 COW. 8 bytes and under are often tokens/fields/keys/prop names/string-ified integers/stringified 1 or 0 bools/api func calls or var names/json prop names. All of those are very high frequency to see bounce around at runtime on end user code.
Perl_sv_grow()
/PERL_STRLEN_ROUNDUP
/PERL_STRLEN_EXPAND_SHIFT
/PERL_STRLEN_NEW_MIN
/newSVpvn
/etc should not be discriminating against short strings held in Perl API's Newx() backed, API min buf length of 0x10==SvLEN().Perl configuration
The text was updated successfully, but these errors were encountered: