Skip to content

Commit

Permalink
reuse capacity calculation
Browse files Browse the repository at this point in the history
Signed-off-by: Kaituo Li <[email protected]>
  • Loading branch information
kaituo committed Apr 3, 2024
1 parent c272d9f commit 007a5b8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/org/opensearch/timeseries/MemoryTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ public long estimateTRCFModelSize(int dimension, int numberOfTrees, double bound
throw new IllegalArgumentException("out of range shingle size " + shingleSize);
}

int pointStoreCapacity = Math.max(sampleSize * numberOfTrees + 1, 2 * sampleSize);
int capacity = sampleSize * numberOfTrees;
int pointStoreCapacity = Math.max(capacity + 1, 2 * sampleSize);
int pointStoreTypeConstant = shingleSize * pointStoreCapacity >= Character.MAX_VALUE ? 4 : 2;
int boundingBoxExistsConstant = boundingBoxCacheFraction > 0 ? 1 : 0;

Expand All @@ -293,10 +294,9 @@ public long estimateTRCFModelSize(int dimension, int numberOfTrees, double bound
nodeStoreSize = 20 * sampleSize + 198;
}
// NodeStoreLarge
return (long) (152 * baseDimension + 4 * dimension * pointStoreSizeConstant * sampleSize * numberOfTrees + 64 * dimension
+ pointStoreTypeConstant * sampleSize * numberOfTrees + 4 * shingleSize + sampleSize * numberOfTrees + numberOfTrees * (32
* boundingBoxExistsConstant + 8 * boundingBoxCacheFraction * dimension * sampleSize + 8 * boundingBoxCacheFraction
* sampleSize + nodeStoreSize + 8 * sampleSize + 352) + 3944);
return (long) (152 * baseDimension + 4 * dimension * pointStoreSizeConstant * capacity + 64 * dimension + pointStoreTypeConstant
* capacity + 4 * shingleSize + capacity + numberOfTrees * (32 * boundingBoxExistsConstant + 8 * boundingBoxCacheFraction
* dimension * sampleSize + 8 * boundingBoxCacheFraction * sampleSize + nodeStoreSize + 8 * sampleSize + 352) + 3944);
}

/**
Expand Down

0 comments on commit 007a5b8

Please sign in to comment.