-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b39
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8019755 | 8 | Ioi Lam | P4 | Closed | Fixed | b97 |
Reported by Chris P:
If you make Symbol._refcount a short rather than an int, and co-locate with _length, then we can save 4 bytes per Symbol:
class Symbol : public MetaspaceObj {
...
volatile int _refcount;
int _identity_hash;
unsigned short _length; // number of UTF8 characters in the symbol
jbyte _body[1];
...
}
I don't think it would be very common for the _refcount to overflow (> 32767) , and we already handle that by just pinning the refcount and keeping it live.
However, _refcount needs to be updated atomically, and I don't think there is any way of doing this with a 16-bit value other than to use locking rather than Atomic::inc/dec. CVM uses 8 bits for the refcount, and all type system APIs are protected with a lightweight lock. More expensive, but less footprint, and in the end does not affect application throughput (but may impact startup). It might be worth measuing the vmRSS footprint savings with this change. If it seems worth doing, use a lock to protect _refcount. If there is a performance concern, maybe we could make lock vs atomic a buildtime option, and use the lock for embedded. Actually it could easily be a runtime option instead of buildtime.
If you make Symbol._refcount a short rather than an int, and co-locate with _length, then we can save 4 bytes per Symbol:
class Symbol : public MetaspaceObj {
...
volatile int _refcount;
int _identity_hash;
unsigned short _length; // number of UTF8 characters in the symbol
jbyte _body[1];
...
}
I don't think it would be very common for the _refcount to overflow (> 32767) , and we already handle that by just pinning the refcount and keeping it live.
However, _refcount needs to be updated atomically, and I don't think there is any way of doing this with a 16-bit value other than to use locking rather than Atomic::inc/dec. CVM uses 8 bits for the refcount, and all type system APIs are protected with a lightweight lock. More expensive, but less footprint, and in the end does not affect application throughput (but may impact startup). It might be worth measuing the vmRSS footprint savings with this change. If it seems worth doing, use a lock to protect _refcount. If there is a performance concern, maybe we could make lock vs atomic a buildtime option, and use the lock for embedded. Actually it could easily be a runtime option instead of buildtime.
- backported by
-
JDK-8019755 Reduce Symbol::_refcount from 4 bytes to 2 bytes
- Closed
- duplicates
-
JDK-8010831 Save 3 bytes per instance of Symbol
- Closed
- relates to
-
JDK-8011048 Possible reading from unmapped memory in UTF8::as_quoted_ascii()
- Closed
-
JDK-8087143 Reduce Symbol::_identity_hash to 2 bytes
- Resolved