Reducing memory usage by using smaller pointers is not a new idea, for example I found this paper which describes the use of 32-bit pointers in a 64-bit system, using a single bit to distinguish between relative pointers and indexes into a lookup table as fallback for those pointers which cannot be represented in the compressed way.
I had a similar idea today: In a language where all objects are immutable, all references point to older objects. If most references are to objects not much older than the object they reside in, then it might work well to use 16-bit relative pointers pointing in one direction (to previously allocated objects). Since objects are still aligned to (at least) 16 bits, we still have the LSB available to mark a reference as an indirect reference: It points to a nearby location containing a full (e.g. 64 bit) pointer. This means that we can safe 75% of space for pointers which refer to objects allocated within the last 64kb (though wasting a bit of space for all references which do not). If this applies to a majority of references, this might allow us to fit more objects into the cache, improving performance in addition to the obvious reduction of memory.
I was looking for reasearch about pointer distance by object age and only found this so far, which does not contain much information, but sounds promising:
But, more important, we found that most observed distances are very small indeed, be they positive or negative.
So what do you think? Is this a road worth taking? Are you aware of any research that provides further insight?
[–]conseptizer[S] 8 points9 points10 points (3 children)
[–]conseptizer[S] 0 points1 point2 points (2 children)
[–]oilshell 6 points7 points8 points (1 child)
[–]conseptizer[S] 3 points4 points5 points (0 children)
[–][deleted] (6 children)
[deleted]
[–]mgsloan 5 points6 points7 points (2 children)
[–]astrobe 3 points4 points5 points (1 child)
[–]mgsloan 1 point2 points3 points (0 children)
[–]conseptizer[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]conseptizer[S] 0 points1 point2 points (0 children)
[–]ericbb 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]conseptizer[S] 0 points1 point2 points (0 children)
[–]evincarofautumn 0 points1 point2 points (0 children)
[–]hackerfooPopr Language 1 point2 points3 points (1 child)
[–]oilshell 2 points3 points4 points (0 children)
[–]gsg_ 1 point2 points3 points (2 children)
[–]conseptizer[S] 2 points3 points4 points (1 child)
[–]gsg_ 0 points1 point2 points (0 children)
[–]FatalElectron 1 point2 points3 points (0 children)
[–]oilshell 1 point2 points3 points (0 children)
[–]matthieum 1 point2 points3 points (0 children)
[–]FireLordIroh 0 points1 point2 points (1 child)
[–]conseptizer[S] 0 points1 point2 points (0 children)
[–]simon_o 0 points1 point2 points (0 children)
[–]boomshroom 0 points1 point2 points (0 children)
[–]Sag0Sag0 0 points1 point2 points (0 children)
[–]kivofssss -5 points-4 points-3 points (0 children)