Optimizing memory layouts #22
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've been thinking a bunch about how to optimize a number of terms on stacks to keep things small.
We need values that are used at runtime to be as small as possible.
The current memory plan for
Value
is of paramount importance.Currently, it's 64 bytes, because
List
owns animbl::Vector
, which is 64 bytes. We can do better than this:This gets us down to 8 bytes, or 64 bits.
Some notes here:
FnDecl
, orLBox.name
) are indices toVec
s holding&'static str
s yanked from the source code. This saves us a byte over storing&'static str
s directly. This also doesn't come at a very steep cost: equality is comparing theusize
s that are stored there.Regarding NaN boxing: At current the crate I'd like to use for that, https://github.com/CraftSpider/boxing, https://craftspider.github.io/2024/09/shorts-boxing/, only implements boxing for
Box
pointers, but not forRc
--which I need. I have no idea how much faster an interpreter could be if its value type were 8 bytes instead of 16 (or 24). Or how much slower it would be if weBox
ed up ourRc
s. Or how much work it would be to extendboxing
to coverRc
s. Anyway, that's for future me to worry about.Also, we'd have to use
u32
instead ofusize
for indices, and it's probably best to useindex_vec
'sIdx
wrapper so that the index is typed. This would mean that we'd haveKeyword(KwIdx)
andInterned(StrIdx)
. Which, great!