[GPU] Handle segments too big for MSAI segment access#141872
[GPU] Handle segments too big for MSAI segment access#141872ldematte merged 10 commits intoelastic:mainfrom
Conversation
|
Hi @ldematte, I've created a changelog YAML for you. |
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
|
@mayya-sharipova @ChrisHegarty I added some unit tests, but I think it would be nice to have some IT tests as well. Do you think it's worth it? I'd need your help here, I don't know how I can add cases with a different max chunk size (I could do that manually maybe, but I don't think it's the right way). |
libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/DatasetUtilsImpl.java
Outdated
Show resolved
Hide resolved
| /** Returns a Dataset over an input slice */ | ||
| CuVSMatrix fromSlice(MemorySegmentAccessInput input, long pos, long len, int numVectors, int dims, CuVSMatrix.DataType dataType) | ||
| throws IOException; | ||
| CuVSMatrix fromInput(MemorySegment input, int numVectors, int dims, CuVSMatrix.DataType dataType); |
There was a problem hiding this comment.
May be not related to this PR, do we need DatasetUtils class at all? Looks like we only have a single DatasetUtilsImpl now.
libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/MemorySegmentUtils.java
Outdated
Show resolved
Hide resolved
libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/MemorySegmentUtils.java
Show resolved
Hide resolved
libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/MemorySegmentUtils.java
Show resolved
Hide resolved
libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/MemorySegmentUtils.java
Show resolved
Hide resolved
mayya-sharipova
left a comment
There was a problem hiding this comment.
@ldematte Thanks Lorenzo for fixing the bug.
I also like how you restructured the code.
I will think about the testing. I left some comments, and after addressing them, the PR is good to be merged.
💚 Backport successful
|
MSAI (MemorySegmentAccessInput) provides access to an index input via file memory mapping, returning a MemorySegment. However, MemorySegmentAccessInput may return null under some circumstances; in our usage, where we try to get a memory mapping for the whole file, it would fail if the file is too big (where "too big" is currently set at 16GB). This PR adds a fallback for this situation; if we fail to get a MemorySegment from MemorySegmentAccessInput, we assume the input as a whole is too big, and we fall back to using a temp file. Data is copied over to the temp file, and we use the FileChannel Java API directly to map the whole file. Using a temp file is necessary; if the input as a whole is too big (> 16G) we cannot reliably use directly on or off-heap memory, we need "something" to back that memory in case the OS needs to page it out (e.g. in the likely event we exceed the physical memory available). Closes elastic#141746
) MSAI (MemorySegmentAccessInput) provides access to an index input via file memory mapping, returning a MemorySegment. However, MemorySegmentAccessInput may return null under some circumstances; in our usage, where we try to get a memory mapping for the whole file, it would fail if the file is too big (where "too big" is currently set at 16GB). This PR adds a fallback for this situation; if we fail to get a MemorySegment from MemorySegmentAccessInput, we assume the input as a whole is too big, and we fall back to using a temp file. Data is copied over to the temp file, and we use the FileChannel Java API directly to map the whole file. Using a temp file is necessary; if the input as a whole is too big (> 16G) we cannot reliably use directly on or off-heap memory, we need "something" to back that memory in case the OS needs to page it out (e.g. in the likely event we exceed the physical memory available). Closes #141746
MSAI (
MemorySegmentAccessInput) provides access to an index input via file memory mapping, returning a MemorySegment.However,
MemorySegmentAccessInputmay return null under some circumstances; in our usage, where we try to get a memory mapping for the whole file, it would fail if the file is too big (where "too big" is currently set at 16GB).This PR adds a fallback for this situation; if we fail to get a MemorySegment from
MemorySegmentAccessInput, we assume the input as a whole is too big, and we fall back to using a temp file. Data is copied over to the temp file, and we use the FileChannel Java API directly to map the whole file.Using a temp file is necessary; if the input as a whole is too big (> 16G) we cannot reliably use directly on or off-heap memory, we need "something" to back that memory in case the OS needs to page it out (e.g. in the likely event we exceed the physical memory available).
Closes #141746