Async file IO?

202 views
Skip to first unread message

ggggg

unread,
May 16, 2016, 7:03:21 PM5/16/16
to julia-users
Hello All,

I think that Julia IO is built on libuv, and that libuv offers asynchronous IO to the filesystem. Is this exposed through the Julia API? I can't figure it out from the documentation. I did a simple test

julia> tic(); t = @async read(open("filename"),UInt8,2500000000); yield(); toc()

elapsed time: 9.094271773 seconds

and it seems that reading blocks without yielding.

Is there a way to do this where the reading task yields to other processes while it is getting the data from disk?



Andrei Zh

unread,
May 19, 2016, 5:24:38 PM5/19/16
to julia-users
Based on answers to my own question, I believe it's safe to assume that `read()` on file will switch to another task during IO operation.  

Yichao Yu

unread,
May 19, 2016, 5:44:15 PM5/19/16
to Julia Users
On Thu, May 19, 2016 at 5:24 PM, Andrei Zh <faithle...@gmail.com> wrote:
> Based on answers to my own question, I believe it's safe to assume that
> `read()` on file will switch to another task during IO operation.

I don't think this happens for normal file IO.

Isaiah Norton

unread,
May 19, 2016, 6:37:03 PM5/19/16
to julia...@googlegroups.com
I don't think this happens for normal file IO.

Right, good point. The stuff in the thread linked by Andrei applies to Libuv streams only.

I think that Julia IO is built on libuv

Julia IO is mostly built on libuv, but file IO uses the internal ios library that is part of flisp.

Isaiah Norton

unread,
May 19, 2016, 6:52:52 PM5/19/16
to julia...@googlegroups.com
Julia IO is mostly built on libuv, but file IO uses the internal ios library that is part of flisp.

(I guess file IO is kind of important so replace "mostly" with "partly"...)

To clarify: operations on the `IOStream` type use the "ios" library. Operations on `LibuvStream` (and its subtypes) use Libuv.



 

Andrei Zh

unread,
May 19, 2016, 7:20:34 PM5/19/16
to julia-users

To clarify: operations on the `IOStream` type use the "ios" library. Operations on `LibuvStream` (and its subtypes) use Libuv.

Huh,  didn't know that. Sorry for confusion in previous answer and thanks for valuable comment. 
Reply all
Reply to author
Forward
0 new messages