Skip to content

Commit 0004893

Browse files
committed
repairing memory estimations for KNN after addition of instrumentation
1 parent f00c6b4 commit 0004893

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

algo/src/main/java/org/neo4j/gds/similarity/knn/KnnFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public MemoryEstimation memoryEstimation(CONFIG configuration) {
9797
sizeOfIntArray(sizeOfOpenHashContainer(sampledK)) * concurrency
9898
)
9999
)
100+
.add(MemoryEstimations.of("neighbour-consumers", MemoryRange.of(sizeOfInstance(NeighbourConsumers.class))))
100101
.build();
101102
}
102103
);

doc/asciidoc/algorithms/knn/knn.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ YIELD nodeCount, bytesMin, bytesMax, requiredMemory
464464
[opts="header", cols="1,1,1,1"]
465465
|===
466466
| nodeCount | bytesMin | bytesMax | requiredMemory
467-
| 5 | 2040 | 3096 | "[2040 Bytes \... 3096 Bytes]"
467+
| 5 | 2096 | 3152 | "[2096 Bytes \... 3152 Bytes]"
468468
|===
469469
--
470470

proc/machine-learning/src/test/java/org/neo4j/gds/ml/linkmodels/pipeline/predict/ApproximateLinkPredictionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void estimate() {
261261
.estimate(config)
262262
.estimate(GraphDimensions.of(100, 1000), config.concurrency());
263263

264-
assertThat(actualEstimate.memoryUsage().toString()).isEqualTo("[23 KiB ... 42 KiB]");
264+
assertThat(actualEstimate.memoryUsage().toString()).isEqualTo("[24 KiB ... 43 KiB]");
265265
}
266266

267267
static Comparator<PredictedLink> compareWithPrecision(double precision) {

proc/similarity/src/test/java/org/neo4j/gds/similarity/knn/KnnFactoryTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ private void assertEstimation(
110110
KnnSampler.SamplerType initialSampler,
111111
MemoryRange actual
112112
) {
113-
long knnAlgo = /* KNN */ 56;
113+
long knnAlgo = /* KNN */ 64;
114114

115-
long topKNeighborList = /* NL */ 24 + sizeOfLongArray(boundedK * 2);
115+
long topKNeighborList = /* NL */ 32 + sizeOfLongArray(boundedK * 2L);
116116
long topKNeighborsList = /* HOA */ sizeOfHugeArrayInstance + sizeOfHugeArray + nodeCount * topKNeighborList;
117117

118118
long tempNeighborsListMin = /* HOA */ sizeOfHugeArrayInstance + sizeOfHugeArray;
@@ -121,8 +121,10 @@ private void assertEstimation(
121121
var randomList = KnnFactory.initialSamplerMemoryEstimation(initialSampler, boundedK);
122122
long sampledList = sizeOfIntArray(sizeOfOpenHashContainer(sampledK));
123123

124-
long expectedMin = knnAlgo + topKNeighborsList + 4 * tempNeighborsListMin + randomList.min + sampledList;
125-
long expectedMax = knnAlgo + topKNeighborsList + 4 * tempNeighborsListMax + randomList.max + sampledList;
124+
long neighbourConsumers = 8;
125+
126+
long expectedMin = knnAlgo + topKNeighborsList + 4 * tempNeighborsListMin + randomList.min + sampledList + neighbourConsumers;
127+
long expectedMax = knnAlgo + topKNeighborsList + 4 * tempNeighborsListMax + randomList.max + sampledList + neighbourConsumers;
126128

127129
assertEquals(expectedMin, actual.min);
128130
assertEquals(expectedMax, actual.max);

0 commit comments

Comments
 (0)