dweiss commented on a change in pull request #1917:
URL: https://github.com/apache/lucene-solr/pull/1917#discussion_r494314029



##########
File path: 
lucene/core/src/java/org/apache/lucene/store/ByteBuffersDataOutput.java
##########
@@ -400,8 +400,13 @@ public void writeSetOfStrings(Set<String> set) {
   public long ramBytesUsed() {
     // Return a rough estimation for allocated blocks. Note that we do not make
     // any special distinction for direct memory buffers.
-    return RamUsageEstimator.NUM_BYTES_OBJECT_REF * blocks.size() + 
-           blocks.stream().mapToLong(buf -> buf.capacity()).sum();
+    ByteBuffer first = blocks.peek();
+    if (first == null) {
+      return 0L;
+    } else {
+      // All blocks have the same capacity.

Review comment:
       I'm not sure I like this assumption (that all blocks are equal). Maybe 
we could maintain a separate ram usage on block addition/ removal and thus make 
the sum-time constant but also accurate?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to