How does the IO manager handle reading regular files?

Ben Gamari ben at well-typed.com
Mon May 14 13:36:58 UTC 2018


Niklas Hamb├╝chen <mail at nh2.me> writes:

> I just got reminded that epoll() has no effect on regular files on
> Linux by reading an nginx article [1] [2] and why that is [3] [4].
>
> By what means does the IO manager make reads (wraps around the read()
> syscall on Linux) non-blocking?
>
> Does it always use read() in `foreign import safe` (or
> `interruptible`) so that an OS thread is spawned?
>
> It would be great if somebody could point me to the code where that's
> done (not again: for *regular* files).
>
I believe the relevant implementation is the RawIO instance defined in
GHC.IO.FD. The read implementation in particular is
GHC.IO.FD.readRawBufferPtr. There is a useful Note directly above
this function.

Cheers,

- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20180514/a3866c97/attachment.sig>


More information about the ghc-devs mailing list