NaN boxing!

 new new list compose Reply to this message Top page
+ (text/plain)
+ (text/html)

Delete this message
Author: Kaz Kylheku
To: TXR Users
Subject: NaN boxing!

Hi All,

I pushed out a series of commits which support the "NaN boxing" scheme for dynamically typed value representation.

Under NaN boxing, floating-point values aren't heap allocated; they fit directly into the value word. Floating-point calculations stop consing memory.

TXR 281:

1> (pprof (+ 1.0 3 4 5 6 7))
malloc bytes: 0
gc heap bytes: 160
total: 160
milliseconds: 0

Current, built with NaN boxing:

1> (pprof (+ 1.0 3 4 5 6 7))
malloc bytes: 0
gc heap bytes: 0
total: 0
milliseconds: 0

NaN boxing is new and experimental; but TXR builds and all tests pass. It is enabled using:

./configure --nan-boxing

which will deposit a #define CONFIG_NAN_BOXING 1 into config.h.

Eventually it will be the default on 64 it platforms, possible to disable with --no-nan-boxing.

Under NaN boxing, we lose quite a bit of fixnum precision: fixnum integers are reduced from 62 bits to 50 bits. The run-time has more bit fiddling to deal with to decode values so code that doesn't benefit from NaN boxing may be slightly affected.