mirror of https://github.com/apache/lucene.git
Add Integer awareness to RamUsageEstimator.sizeOf (#11715)
Additionally, update comments to reflect that we have not been VM cache-aware for a long time now.
This commit is contained in:
parent
1d54299011
commit
dbc7a9764a
|
@ -97,6 +97,8 @@ Improvements
|
|||
---------------------
|
||||
* LUCENE-10592: Build HNSW Graph on indexing. (Mayya Sharipova, Adrien Grand, Julie Tibshirani)
|
||||
|
||||
* GITHUB#11715: Add Integer awareness to RamUsageEstimator.sizeOf (Mike Drob)
|
||||
|
||||
Optimizations
|
||||
---------------------
|
||||
|
||||
|
@ -18768,4 +18770,4 @@ First open source release.
|
|||
|
||||
The code has been re-organized into a new package and directory
|
||||
structure for this release. It builds OK, but has not been tested
|
||||
beyond that since the re-organization.
|
||||
beyond that since the re-organization.
|
||||
|
|
|
@ -107,8 +107,7 @@ public final class RamUsageEstimator {
|
|||
primitiveSizes = Collections.unmodifiableMap(primitiveSizesMap);
|
||||
}
|
||||
|
||||
/** JVMs typically cache small longs. This tries to find out what the range is. */
|
||||
static final int LONG_SIZE, STRING_SIZE;
|
||||
static final int INTEGER_SIZE, LONG_SIZE, STRING_SIZE;
|
||||
|
||||
/** For testing only */
|
||||
static final boolean JVM_IS_HOTSPOT_64BIT;
|
||||
|
@ -187,6 +186,7 @@ public final class RamUsageEstimator {
|
|||
NUM_BYTES_ARRAY_HEADER = NUM_BYTES_OBJECT_HEADER + Integer.BYTES;
|
||||
}
|
||||
|
||||
INTEGER_SIZE = (int) shallowSizeOfInstance(Integer.class);
|
||||
LONG_SIZE = (int) shallowSizeOfInstance(Long.class);
|
||||
STRING_SIZE = (int) shallowSizeOfInstance(String.class);
|
||||
}
|
||||
|
@ -208,10 +208,18 @@ public final class RamUsageEstimator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the size of the provided {@link Long} object, returning 0 if it is cached by the JVM and
|
||||
* its shallow size otherwise.
|
||||
* Return the shallow size of the provided {@link Integer} object. Ignores the possibility that
|
||||
* this object is part of the VM IntegerCache
|
||||
*/
|
||||
public static long sizeOf(Long value) {
|
||||
public static long sizeOf(Integer ignored) {
|
||||
return INTEGER_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the shallow size of the provided {@link Long} object. Ignores the possibility that this
|
||||
* object is part of the VM LongCache
|
||||
*/
|
||||
public static long sizeOf(Long ignored) {
|
||||
return LONG_SIZE;
|
||||
}
|
||||
|
||||
|
@ -456,6 +464,8 @@ public final class RamUsageEstimator {
|
|||
size = sizeOf((float[]) o);
|
||||
} else if (o instanceof int[]) {
|
||||
size = sizeOf((int[]) o);
|
||||
} else if (o instanceof Integer) {
|
||||
size = sizeOf((Integer) o);
|
||||
} else if (o instanceof Long) {
|
||||
size = sizeOf((Long) o);
|
||||
} else if (o instanceof long[]) {
|
||||
|
|
Loading…
Reference in New Issue