From 6ac311068feffefbf588db5b49b3db774610854b Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 28 Sep 2021 09:38:03 -0400 Subject: [PATCH] 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. --- .../core/src/java/org/apache/lucene/util/SparseFixedBitSet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java b/lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java index 1155800b050..8dfb95bb127 100644 --- a/lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java +++ b/lucene/core/src/java/org/apache/lucene/util/SparseFixedBitSet.java @@ -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); }