www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compressed class references?

reply bearophile <bearophileHUGS lycos.com> writes:
A significant percentage of heap memory in a 64 bit JavaVM is used by
references, that are 8 bytes long. To reduce this problem they have invented
"compressed references" (useful only for 64 bit systems), that turn references
to 32 bit again:

https://blogs.oracle.com/jrockit/entry/understanding_compressed_refer

ftp://public.dhe.ibm.com/software/webserver/appserv/was/WAS_V7_64-bit_performance.pdf

With them the total amount of heap memory decreases. They don't slow down the
class usage significantly, and the memory reduction reduces the CPU cache
pressure, increasing the performance a bit.

Will this idea be useful for 64 bit D/DMD too, for D GC-managed class
references (not for raw pointers)?

Bye,
bearophile
Mar 11 2012
parent reply =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= <xtzgzorex gmail.com> writes:
On 12-03-2012 01:41, bearophile wrote:
 A significant percentage of heap memory in a 64 bit JavaVM is used by
references, that are 8 bytes long. To reduce this problem they have invented
"compressed references" (useful only for 64 bit systems), that turn references
to 32 bit again:

 https://blogs.oracle.com/jrockit/entry/understanding_compressed_refer

 ftp://public.dhe.ibm.com/software/webserver/appserv/was/WAS_V7_64-bit_performance.pdf

 With them the total amount of heap memory decreases. They don't slow down the
class usage significantly, and the memory reduction reduces the CPU cache
pressure, increasing the performance a bit.

 Will this idea be useful for 64 bit D/DMD too, for D GC-managed class
references (not for raw pointers)?

 Bye,
 bearophile
This probably can't work for D. The problem is that D allows casting references to pointers. As we all know, a pointer is a distinct type from a reference, and casting a pointer to e.g. an integer type is perfectly valid and sometimes necessary. So, that is to say, this would blow up when doing the reference -> pointer conversion. You could do it such that when one does the ref -> ptr conversion, the reference is simply expanded to a normal pointer, and vice versa. However, I'm not sure if this will hold water in the long run. -- - Alex
Mar 11 2012
parent deadalnix <deadalnix gmail.com> writes:
Le 12/03/2012 01:44, Alex Rønne Petersen a écrit :
 On 12-03-2012 01:41, bearophile wrote:
 A significant percentage of heap memory in a 64 bit JavaVM is used by
 references, that are 8 bytes long. To reduce this problem they have
 invented "compressed references" (useful only for 64 bit systems),
 that turn references to 32 bit again:

 https://blogs.oracle.com/jrockit/entry/understanding_compressed_refer

 ftp://public.dhe.ibm.com/software/webserver/appserv/was/WAS_V7_64-bit_performance.pdf


 With them the total amount of heap memory decreases. They don't slow
 down the class usage significantly, and the memory reduction reduces
 the CPU cache pressure, increasing the performance a bit.

 Will this idea be useful for 64 bit D/DMD too, for D GC-managed class
 references (not for raw pointers)?

 Bye,
 bearophile
This probably can't work for D. The problem is that D allows casting references to pointers. As we all know, a pointer is a distinct type from a reference, and casting a pointer to e.g. an integer type is perfectly valid and sometimes necessary. So, that is to say, this would blow up when doing the reference -> pointer conversion. You could do it such that when one does the ref -> ptr conversion, the reference is simply expanded to a normal pointer, and vice versa. However, I'm not sure if this will hold water in the long run.
Additionally, 64bits pointer is good for us : http://www.deadalnix.me/2012/03/05/impact-of-64bits-vs-32bits-when-u ing-non-precise-gc/ (shameless autopromotion inside).
Mar 11 2012