问题描述
按照我关于 CLR 是否可以使用压缩指针的问题,答案是它很没有意义.尽管如此,一些 JVM 正在实现它,那么这种优化的具体好处是什么,因为获得 4 个字节似乎不值得?
Following my question on whether the CLR could use compressed pointers, the answer was that it's pretty pointless. Still, some JVMs are implementing it, so what are the concrete benefits of this optimization, since gaining 4 bytes doesn't seem worth it?
推荐答案
压缩引用具有巨大的价值.首先,在 x86 上,64 位模式解锁了 8 个要使用的新寄存器,这是一个巨大的性能优势.其次,使用 4 字节而不是 8 字节的标头/对象指针显着提高了缓存效率.我们看到 IBM Java 的实际优势相对于完整的"64 位 JVM(您的里程会有所不同)约为 5-10%.这使得迁移到小型 64 位"堆变得简单而轻松,突破了 32 位 JVM 中 ~2gb 的内存限制.(实际的 32 位限制可能在 1700mb 到 ~3.7gb 之间,具体取决于操作系统).
There is huge value in compressed references. First, on x86, 64 bit modes unlock 8 new registers to be used, which is a huge performance win. Second, using 4 byte instead of 8 byte headers / object pointers significantly improves cache efficiency. We see real-world benefits in IBM Java on the order of ~5-10% relative to a "full" 64 bit JVM (your mileage will vary). This makes moving to "small 64 bit" heaps an easy and painless thing, breaking past the ~2gb memory limit in 32 bit JVMs. (the real 32 bit limit it could be anywhere from 1700mb to ~3.7gb depending on the OS).
这篇关于压缩对象指针的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!