Small Buffer Optimization for string and friends
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Apr 7 22:56:38 PDT 2012
Walter and I discussed today about using the small string optimization
in string and other arrays of immutable small objects.
On 64 bit machines, string occupies 16 bytes. We could use the first
byte as discriminator, which means that all strings under 16 chars need
no memory allocation at all.
It turns out statistically a lot of strings are small. According to a
variety of systems we use at Facebook, the small buffer optimization is
king - it just works great in all cases. In D that means better speed,
better locality, and less garbage.
For this to happen, we need to start an effort of migrating built-in
arrays into runtime, essentially making them templates that the compiler
lowers to. So I have two questions:
1. What happened to the new hash project? We need to take that to
completion.
2. Is anyone willing to start the effort of migrating built-in slices
into templates?
Thanks,
Andrei
More information about the Digitalmars-d
mailing list