3 ms·
> However, that is not something that is easy to create a microbenchmark for. The benefit of nan-boxing is that we don’t have to dereference a pointer to get th
by naasking 2y ago
> However, that is not something that is easy to create a microbenchmark for. The benefit of nan-boxing is that we don’t have to dereference a pointer to get the float.
That's not the only benefit. The main benefit is arguably that you don't have to allocate floats on the heap and garbage collect them. Numerical code allocates lots of numbers, so having these all be inline rather than heap-allocated saves lots of space and time.
- hinkley 2y agoThe wasted space has administrative overhead, and the administrative overhead can partially poison the cache.
- naasking 2y agoDo you mean wasted space inside the pointers, or on the heap?
- hinkley 2y agoIf you malloc or roll your own every allocation has to be big enough to be put back on the free list. And the overhead for combining adjacent segments back together, which will involve additional cache lines at least 12.5% of the time. cache line / pointer size, and anything larger than a pointer has higher probability. If you GC then it’s more pointer chasing during mark. Which will cache thrash at least one CPU, even if it’s not the one where most of the code is running.