kvikio icon indicating copy to clipboard operation
kvikio copied to clipboard

Adding multiline/IOV APIs

Open jakirkham opened this issue 3 years ago • 5 comments

In some cases a user needs to write a list of binary data (like using writelines). It would be useful to have an API like this when working with multiple frames.

Similarly it might be handy to have some kind of API for reading in data to multiple buffers. There is not exactly an analogous API in Python. Though socket.recvmsg_into is close (so might be a starting point).

This can be particularly helpful if the GIL is released in the background as there can be one API call that releases the GIL as opposed to a couple in rapid succession.

jakirkham avatar Jun 02 '22 02:06 jakirkham

@madsbk do you know whether something like this is possible today?

jakirkham avatar Jun 26 '23 18:06 jakirkham

I think this is possible using the non-blocking API, pread and pwrite. At least, we do release the GIL when calling IOFuture.get(): https://github.com/rapidsai/kvikio/blob/branch-23.08/python/kvikio/_lib/libkvikio.pyx#L23

madsbk avatar Jun 27 '23 06:06 madsbk

Interesting was thinking more of things like preadv & pwritev

This way one could give a list of Array-like objects to KvikIO, which could in turn covert them into an iovec-like object under-the-hood

jakirkham avatar Jun 28 '23 02:06 jakirkham

I think that is a good idea but I would suggest that preadv and pwritev just returns a list of futures. Then we can have a waitall functions that waits on all futures in a list.

madsbk avatar Jun 28 '23 06:06 madsbk

The preadv / pwritev option is a good idea we should consider

Another suggestion the GDS team made to us is potentially using the cuFile batched API. As Mads mentioned offline, we have a C++ implementation in KvikIO ( https://github.com/rapidsai/kvikio/pull/220 ). Though currently this is not exposed in Python

jakirkham avatar May 01 '24 19:05 jakirkham

Let's continue this in https://github.com/rapidsai/kvikio/issues/204

madsbk avatar Jun 26 '24 13:06 madsbk