Re: How does the IO manager handle reading regular files?

2018-05-14 Thread Niklas Hambüchen
Also funny but perhaps not too surprising: If in my code, you replace `forkIO` by e.g. `forkOn 2`, then nondeterministically, sometimes the program hangs and sometimes it works with +RTS -N2. The higher you set -N, the more likely it is to work. If you put both the putStrLn loop and the

Re: How does the IO manager handle reading regular files?

2018-05-14 Thread Ben Gamari
Niklas Hambüchen writes: ... > > So GHC is trying to use `O_NONBLOCK` on regular files, which cannot > work and will block when used through unsafe foreign calls like that. > Yikes! > Is this a known problem? > Doesn't sound familiar to me. Sounds like a ticket is in order. Thanks

Re: How does the IO manager handle reading regular files?

2018-05-14 Thread Niklas Hambüchen
Hey Ben, thanks for your quick reply. I think there's a problem. On 14/05/2018 15.36, Ben Gamari wrote: > 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

Re: How does the IO manager handle reading regular files?

2018-05-14 Thread Ben Gamari
Niklas Hambüchen 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

How does the IO manager handle reading regular files?

2018-05-13 Thread Niklas Hambüchen
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