Values should box BaseFns #61

Closed
opened 2025-07-02 16:55:58 +00:00 by scott · 1 comment
Owner

Currently, Value::BaseFn takes ownership of the BaseFn inside, and those are 32 bytes wide. That means that Values are 32 bytes wide, too.

We can get Value down to 8 bytes by putting BaseFns in a Box. Do that. It's an easy win.

Currently, `Value::BaseFn` takes ownership of the `BaseFn` inside, and those are 32 bytes wide. That means that `Value`s are 32 bytes wide, too. We can get `Value` down to 8 bytes by putting `BaseFn`s in a `Box`. Do that. It's an easy win.
scott added the
optimization
label 2025-07-02 16:55:58 +00:00
scott added this to the Expanded: CC2 milestone 2025-07-02 17:16:25 +00:00
Author
Owner

Done. This, however, only reduces us to 24 bytes. Keywords and interned strings are, under the hood, &'static strs, which are 16 bytes wide. That means Value has three 8-byte aligned fields: the tag, a pointer, and then a size (usize) for the &'static strs.

The only way to get smaller would be to Box the &'static strs, which means two dereferences, and that gets us from 24 to 16. The only way to get smaller is to use NaN boxing or tagged pointers, both of which require unsafe rust. So that's NOT for now.

Done. This, however, only reduces us to 24 bytes. Keywords and interned strings are, under the hood, `&'static str`s, which are 16 bytes wide. That means `Value` has three 8-byte aligned fields: the tag, a pointer, and then a size (`usize`) for the `&'static str`s. The only way to get smaller would be to `Box` the `&'static str`s, which means two dereferences, and that gets us from 24 to 16. The only way to get smaller is to use NaN boxing or tagged pointers, both of which require unsafe rust. So that's NOT for now.
scott closed this issue 2025-07-03 19:35:36 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: twc/ludus#61
No description provided.