-
Notifications
You must be signed in to change notification settings - Fork 131
[Java] Tidy up MemorySegment
s lifecycle
#1069
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
[Java] Tidy up MemorySegment
s lifecycle
#1069
Conversation
java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java
Outdated
Show resolved
Hide resolved
java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java
Outdated
Show resolved
Hide resolved
java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java
Outdated
Show resolved
Hide resolved
java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java
Outdated
Show resolved
Hide resolved
java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java
Outdated
Show resolved
Hide resolved
java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good change. We should certainly be using more local arenas where possible, and cleaning up more eagerly. 👍
var returnValue = cuvsRMMAlloc(resourceHandle, datasetMemorySegment, datasetBytes); | ||
checkCuVSError(returnValue, "cuvsRMMAlloc"); | ||
|
||
return datasetMemorySegment.get(C_POINTER, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…-memorysegment-scope
…-memorysegment-scope # Conflicts: # java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/BruteForceIndexImpl.java # java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java # java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/HnswIndexImpl.java
FYI, https://termbin.com/ac7k3 here's a patch on top of this branch. It adds a synchronized() block around the search() call, and the test from #1082 (added in this patch) passes. |
For the record: we discussed this on slack and decided to keep the 2 separate, as they address different problems |
MemorySegment
s lifecycleMemorySegment
s lifecycle
/ok to test 250ca15 |
java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Waiting on CI now.
MemorySegment
s lifecycleMemorySegment
s lifecycle
…-memorysegment-scope
@mythrocks is anything blocking this from getting merged? Should I do something? |
/ok to test 9010448 |
Nothing. CI hadn't passed at the time. I'll check this in, once it does. |
The CI builds should be fixed once #1114 is resolved. |
/ok to test 109b481 |
Will prioritize #1034 first, to address the test failures. |
/ok to test 3ebc564 |
/ok to test d7badfd |
/merge |
This has been merged. Thank you for this contribution, @ldematte . |
Thank you for assisting through the process, @mythrocks! |
This PR tidies up the lifecycle of `MemorySegment`s by using specific confined `Arena`s where possible, and specific index-bound `Arena`s where the lifetime needs to be bound to the lifetime of an index. It addresses all remaining usages of `CuVSResources#arena` after rapidsai#1024 and rapidsai#1045; as such, we can remove `CuVSResources#arena` completely, and force native memory usages to be tracked and dealt with specifically. This would towards the goal of rapidsai#1037 Authors: - Lorenzo Dematté (https://github.com/ldematte) - MithunR (https://github.com/mythrocks) - Ben Frederickson (https://github.com/benfred) Approvers: - Chris Hegarty (https://github.com/ChrisHegarty) - MithunR (https://github.com/mythrocks) URL: rapidsai#1069
This PR tidies up the lifecycle of
MemorySegment
s by using specific confinedArena
s where possible, and specific index-boundArena
s where the lifetime needs to be bound to the lifetime of an index.It addresses all remaining usages of
CuVSResources#arena
after #1024 and #1045; as such, we can removeCuVSResources#arena
completely, and force native memory usages to be tracked and dealt with specifically.This would towards the goal of #1037