stefanvodita commented on code in PR #12844:
URL: https://github.com/apache/lucene/pull/12844#discussion_r1422523360


##########
lucene/core/src/test/org/apache/lucene/util/hnsw/HnswGraphTestCase.java:
##########
@@ -757,6 +757,30 @@ public void testRamUsageEstimate() throws IOException {
     long estimated = RamUsageEstimator.sizeOfObject(hnsw);
     long actual = ramUsed(hnsw);
 
+    // The estimation assumes neighbor arrays are always max size.
+    // When this is not true, the estimate can be much larger than the actual 
value.
+    // In these cases, we compute how much we overestimated the neighbors 
arrays.
+    if (estimated > actual) {
+      long neighborsError = 0;
+      int numLevels = hnsw.numLevels();
+      for (int level = 0; level < numLevels; ++level) {
+        NodesIterator nodesOnLevel = hnsw.getNodesOnLevel(level);
+        while (nodesOnLevel.hasNext()) {
+          int node = nodesOnLevel.nextInt();
+          NeighborArray neighbors = hnsw.getNeighbors(level, node);
+          long maxNeighborsSize;
+          if (level == 0) {

Review Comment:
   Sorry, this addition made sense with the changes to `OnHeapHnswGrap`. I 
forgot to remove it when I reverted those changes. Reverted 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