LUCENE-10128: avoid costly reflection in SparseFixedBitSet ctor

Seems that VectorFormat merge creates A LOT of these bitsets. We don't
need to do any fancy reflection here via shallowSizeOf(Object), when we
can call sizeOf(long[]) which is fast.

We may want to revisit this RAMUsageEstimator api in the future to
prevent traps like this.
This commit is contained in:
Robert Muir 2021-09-28 09:38:03 -04:00
parent 7357bdc272
commit 6ac311068f
No known key found for this signature in database
GPG Key ID: 817AE1DD322D7ECA
1 changed files with 1 additions and 1 deletions

View File

@ -69,7 +69,7 @@ public class SparseFixedBitSet extends BitSet {
bits = new long[blockCount][];
ramBytesUsed =
BASE_RAM_BYTES_USED
+ RamUsageEstimator.shallowSizeOf(indices)
+ RamUsageEstimator.sizeOf(indices)
+ RamUsageEstimator.shallowSizeOf(bits);
}