r/programming • u/simon_o • Oct 07 '26
Janet on x32: 32-bit Pointers, 64-bit Speed, 25% Less RAM
https://alexalejandre.com/programming/lisp/janet-for-the-x32-abi/
14
Upvotes
r/programming • u/simon_o • Oct 07 '26
5
u/simon_o Oct 07 '26 edited Oct 07 '26
I think the core lesson from this (regardless of the adoption of x32) is:
So while 32bit pointers are too small these days for general-purpose software, pointer that are more realistically sized to the available memory can be hugely beneficial (vs. 64bit pointers' theoretical 2⁶⁴).
For instance, I aim for 38bit pointers which gives me an addressable space of 512GB (at 8byte padding), leaving 26 bits for other purposes.
9
u/rabid_briefcase Oct 07 '26
Interesting for your project, but I'm not sure how transferrable it is.
I mean, yes, but also it is very much a project-specific optimization choice, in a scenario where often no optimization is necessary.
If you're on a project where you're building a quick running tool or utility that takes seconds to run and occupies a few megabytes, knowing you're running on a machine with gigabytes available, it's an optimization that is unnecessary.
If you're on a data project that takes multiple gigabytes, well, you get 2GB of address space to work with, 3 if you set the right flags, and even then thanks to fragmentation, it's likely not an option that is available. When you're working with a lot of data, 32-bit address space just isn't an option.
I'd say in the Great Big World of Software, there are relatively few that fit in the sweet spot of using a few hundred megabytes of memory while also being meaningfully performance critical where the cost spent processing pointers is measurable for performance.
I mean, there are certainly thousands of programs in existence where it could be a meaningful optimization, and it's something to be aware of, but at the same time, it's not something most people and projects would meaningfully benefit from.