-
Notifications
You must be signed in to change notification settings - Fork 171
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
Store short strings inside string's body #1802
base: main
Are you sure you want to change the base?
Conversation
uses the 8 bytes that the pointer to a buffer usually takes and puts up to 8 8-bit characters into it. Currently causes trouble with regex matches.
doesn't seem to catch a lot of strings created, though
Not every single case where an MVMString is created do I check whether it could be in-situ. Some of them seemed a bit unlikely to hit in enough instances to be worth the extra checking. However, some might need metrics gathered on the resulting sizes to really know for sure whether it's worth it. And I'd appreciate any suggestions for places I've missed. |
The CI fails are all because of t/02-rakudo/reproducible-builds.t, I'm not quite sure what the problem is or how to fix it. |
Uses the 8 bytes that the pointer to a buffer usually takes and puts up to eight 8-bit or two 32-bit characters into it.
Started by @timo++.
The time reported by micro-benchmark
MVM_SPESH_BLOCKING=1 nqp-m -e 'my str $s; my int $i := 0; my $n := nqp::time; while $i++ < 10_000_000 { $s := $i }; say(nqp::div_n(nqp::time - $n, 1000000000e0)); say($s)'
drops from ~0.270s to ~0.145s, the number of instructions (for 1m iterations) drops from ~628m to ~555m, and the number of allocation functions called as reported by heaptrack drops from ~10m to ~252k.However, another micro-benchmark
MVM_SPESH_BLOCKING=1 nqp-m -e 'my str $s := "ab.cd.ef.gh.ij.kl.mn.op.qr.st.uv.wx.yz"; my int $i := 0; my @a; nqp::setelems(@a, 30); my $n := nqp::time; while $i++ < 1_000_000 { @a := nqp::split(".", $s); }; say(nqp::div_n(nqp::time - $n, 1000000000e0)); say(@a[0])'
has no significant change in time reported, and the instruction count increased from ~10.2b to ~11.9b, even though the allocation functions called as reported by heaptrack drops from ~15.2m to ~2.2m.