Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

small string #141

Open
rurban opened this issue Apr 30, 2016 · 1 comment
Open

small string #141

rurban opened this issue Apr 30, 2016 · 1 comment
Assignees
Milestone

Comments

@rurban
Copy link
Member

rurban commented Apr 30, 2016

Store the PV bytes directly in the head, no body, just a simple short 3-15 char asciiz string. So far 7 with 64bit.
Similar as Mike Pall's lua patch or my p2 variant, just easier, as we already have a free sv_any ptr to the string.
And if we move the sv_flags before the refcnt, and use most refcnt bytes (leaving one, with the highest bit for this special case), we can store more than just 3 chars for 32bit and 7 chars for 64bit. max 4 more on 32bit and 8 more on 64bit.

@rurban rurban self-assigned this Apr 30, 2016
@rurban rurban added this to the v5.26.0 milestone Jun 8, 2016
rurban pushed a commit that referenced this issue Nov 18, 2016
e.g. adding ".pm" to "warnings": 8 + 3 = 11. needing a len=12.
SvLEN is already 12, but sv_grow realloced to 8+3+3=14+1=15->16.

various people decided over time in the front and in the back to add just
another one for safety.  sv_grow adds the one for \0 already, so there's no
need in the front.  only the SvGROW macro logic, which checks against SvLEN.
But even this had it off-by-one.

memory numbers (DEBUGGING):
miniperl -e0            262890 => 262833 byte
miniperl -Ilib -E0      425636 => 423040 byte
perl Config ...         797578 => 796932 byte

$ PERL_HASH_SEED=0 valgrind --tool=massif --massif-out-file=massif.perl.p0
./perl -Ilib -MConfig -Mwarnings -Mstrict -V:ccflags ; grep -h mem_heap_B=
massif.perl.p0 |cut -c12-|sort -rn|head -n1

With #141 smallstrings the first goes down to 262689 bytes.
rurban pushed a commit that referenced this issue Nov 2, 2018
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Nov 25, 2018
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Mar 18, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Apr 1, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Apr 5, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Apr 5, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Apr 30, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jun 12, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jun 24, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jun 26, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jun 27, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jul 1, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jul 2, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jul 2, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jul 3, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Aug 25, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Dec 17, 2019
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jan 19, 2020
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
rurban pushed a commit that referenced this issue Jan 19, 2020
stored inlined in SvPVX, pointing from (char*)SvANY.
The SvSPOK() check using the ptr from SvANY to pv is easier
than checking the flags. Needed flags are only SVs_TEMP and SVf_UTF8.
Now we could even move the flags down and use it to store even more chars.
Now SvPVX,SvCUR,SvLEN are really not lvalues anymore.
Add a SvCUR_inc and SvCUR_dec for convenience.

Add a fast shortcut for bodyless sv_setsv()/SPV to copy just the heads
and adjust SvANY.

See [cperl #141]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant