Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounds the transferLimit in OffheapVectorTransfer #2070

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

shatejas
Copy link
Collaborator

@shatejas shatejas commented Sep 7, 2024

The array list buffer was unnecessarily allocated a large memory irrespective of the number of vectors to transfer. This change considers total vectors

Description

Attached below is the heap usage for the duration of BinaryIndexIT.testFaissHnswBinary_when1000Data_thenCreateIngestQueryWorks test

transferLimitNotCapped.log: This is the current code in main. The max heap usage is 1.8 gb
transferLimitCapped.log: This is code with the current PR. The max heap usage is 1.2 gb
NoPreallocation.log: This is without allocating the transferLimit as a size for arraylist. The max heap usage is comparable to the code in PR which 1.1 gb

Capping the transfer limit is chosen as a solution over not preallocating to avoid fragmentation due to constant resizing of arraylist

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

The array list buffer was unnecessarily allocated a large memory
irrespective of the vectors to transfer. This change considers
total vectors

Signed-off-by: Tejas Shah <shatejas@amazon.com>
Comment on lines +42 to +45
private int computeTransferLimit(int bytesPerVector, int totalVectorsToTransfer) {
int limit = (int) Math.max(1, KNNSettings.getVectorStreamingMemoryLimit().getBytes() / bytesPerVector);
return Math.min(limit, totalVectorsToTransfer);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Not a blocker for this PR to be merged]
lets have some java doc on this explaining this logic.

@naveentatikonda naveentatikonda merged commit 0492fb3 into opensearch-project:main Sep 9, 2024
37 of 52 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 9, 2024
The array list buffer was unnecessarily allocated a large memory
irrespective of the vectors to transfer. This change considers
total vectors

Signed-off-by: Tejas Shah <shatejas@amazon.com>
(cherry picked from commit 0492fb3)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 9, 2024
The array list buffer was unnecessarily allocated a large memory
irrespective of the vectors to transfer. This change considers
total vectors

Signed-off-by: Tejas Shah <shatejas@amazon.com>
(cherry picked from commit 0492fb3)
navneet1v pushed a commit that referenced this pull request Sep 9, 2024
The array list buffer was unnecessarily allocated a large memory
irrespective of the vectors to transfer. This change considers
total vectors

Signed-off-by: Tejas Shah <shatejas@amazon.com>
(cherry picked from commit 0492fb3)

Co-authored-by: Tejas Shah <shatejas@amazon.com>
navneet1v pushed a commit that referenced this pull request Sep 9, 2024
The array list buffer was unnecessarily allocated a large memory
irrespective of the vectors to transfer. This change considers
total vectors

Signed-off-by: Tejas Shah <shatejas@amazon.com>
(cherry picked from commit 0492fb3)

Co-authored-by: Tejas Shah <shatejas@amazon.com>
@shatejas shatejas deleted the mem-fix branch September 9, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants