benwtrent commented on code in PR #14426:
URL: https://github.com/apache/lucene/pull/14426#discussion_r2022890436


##########
lucene/core/src/java/org/apache/lucene/util/OffHeapAccountable.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.util;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * An object whose off-heap memory requirements can be computed.
+ *
+ * @lucene.internal
+ */
+public interface OffHeapAccountable {

Review Comment:
   I wonder if we want to call this "OffHeapAccountable". 
   
   I am not sure, "OnHeap" has a "hard limit" on heap usage to prevent OOMs. 
   
   This "OffHeap" is a "soft limit" that relates to performance, not the system 
running. 
   
   So, its not a "requirements" type of thing.
   
   Maybe I am just stuck on the phrase "resource requirements". As I also see 
this being useful for other field types, besides HNSW knn, where holding 
everything in off-heap memory is critical. 



##########
lucene/core/src/java/org/apache/lucene/codecs/lucene102/Lucene102BinaryQuantizedVectorsReader.java:
##########
@@ -257,6 +257,15 @@ public long ramBytesUsed() {
     return size;
   }
 
+  @Override
+  public long offHeapBytes() {
+    long bytes = 0L;
+    for (var field : fields.values()) {
+      bytes += field.vectorDataLength();
+    }
+    return bytes;
+  }
+

Review Comment:
   Here is where we need to be careful with the API. Technically binary 
quantized vectors keeps the raw vectors (same with other quantized techniques).
   
   Technically, the add to the overall off-heap size, though they may not need 
to be loaded into off-heap memory for search to be fast.
   
   For example, if somebody is using `byte` type vectors, they aren't actually 
quantized, but its searchable. Meaning, they would all need to be in off-heap 
memory to be fast.



##########
lucene/core/src/java/org/apache/lucene/util/OffHeapAccountable.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.util;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * An object whose off-heap memory requirements can be computed.
+ *
+ * @lucene.internal

Review Comment:
   Is this really an "internal" API? Maybe I misunderstand its use, but it 
seems designed for folks to make decisions or provide feedback directly using 
this API.
   
   So, maybe we call it "experimental" if unsure of its usage/stability right 
now?



-- 
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.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to