io_uring_prep_splice using registered files
#1391
-
|
Greetings! apologies upfront, I am just a simple Java guy trying to wrap libUring into Java using FFM -- and I have basically no idea what I am doing. Though I got a basic C sample running copying a file using Pipes and Splice. Everything works fine until I try to register the files and the pipe and provide This works: io_uring_prep_splice(sqe1, src_fd, offset, pipefd[1], -1, to_copy, SPLICE_F_MOVE);
io_uring_prep_splice(sqe2, pipefd[0], -1, dst_fd, offset, to_copy, SPLICE_F_MOVE);
submit_count+=2;This does not work: int fds[4] = {src_fd, dst_fd, pipefd[0], pipefd[1]};
io_uring_register_files(&ring, fds, 4);
io_uring_prep_splice(sqe1, 0, offset, 3, -1, to_copy, SPLICE_F_FD_IN_FIXED | SPLICE_F_MOVE);
io_uring_prep_splice(sqe2, 2, -1, 1, offset, to_copy, SPLICE_F_MOVE);
sqe2->flags |= IOSQE_FIXED_FILE;(Calling Would you like to point out please, what I am doing wrong here? Thanks a lot in advance, best and cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Never mind, I eventually figured it out (brute forcing my way through all possible combinations :-) ). This works: int fds[4] = {src_fd, dst_fd, pipefd[0], pipefd[1]};
io_uring_prep_splice(sqe1, 0, offset, 3, -1, to_copy, SPLICE_F_FD_IN_FIXED);
sqe1->flags |= IOSQE_FIXED_FILE;
sqe1->flags |= IOSQE_IO_LINK; // Link to next
io_uring_prep_splice(sqe2, 2, -1, 1, offset, to_copy, SPLICE_F_FD_IN_FIXED);
sqe2->flags |= IOSQE_FIXED_FILE;And it seems to be reliably faster than using FileDescriptors and on par with CoreUtils |
Beta Was this translation helpful? Give feedback.
-
|
In case anyone is interested: I got Zero Copy File transfer with Pipes and Fixed FileDescriptors working in Java: https://github.com/manticore-projects/JUring/blob/8ce605afbd45b3a2caf15f012ddba96f89b7e2f8/src/test/java/com/davidvlijmincx/lio/api/JUringTest.java#L289 My ultimate goal was to write a libUring backed Java File Channel that can be plugged into Java H2 Database for faster IO. |
Beta Was this translation helpful? Give feedback.
-
|
We have managed to get on par with Java's Zero-Copy NIO Filechannel copy:
Though I wonder, why Fixed File Splice is slower (contrary to what the C reference implementation has shown). Does anyone have an idea or an hint please? |
Beta Was this translation helpful? Give feedback.
Never mind, I eventually figured it out (brute forcing my way through all possible combinations :-) ).
This works:
And it seems to be reliably faster than using FileDescriptors and on par with CoreUtils
cp: