Opened 3 years ago

Last modified 4 months ago

#11394 new task

Base should use native Win32 IO on Windows

Reported by: bgamari Owned by: Phyx-
Priority: normal Milestone: 8.8.1
Component: Core Libraries Version: 7.10.3
Keywords: Cc: ekmett, Phyx-
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking: #806, #2189, #2408, #4471, #7353, #7593, #10542, #12873, #14530
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by Phyx-)

There are a variety of issues caused by the impedance mismatch between GHC's use of Posix I/O interfaces on Windows (particularly with respect to console I/O),

  • #10542: Incorrect Unicode input on Windows Console
  • #7593: Unable to print exceptions of unicode identifiers
  • #4471: Incorrect Unicode output on Windows Console
  • #2189: hSetBuffering stdin NoBuffering doesn't work on Windows

As pointed on in ticket:2189#comment:12 the ultimate solution to this would be to move all of GHC's IO to use the respective Win32 interfaces.

Also relevant

  • #7353: Windows lacks support in the I/O manager
  • #806: hGetBufNonBlocking doesn't work on Windows
  • #3081: Double output after Ctrl+C on Windows
  • #13440: putStr has different behaviour on Windows
  • #4942: GHC.ConsoleHandler does not call back application when Close button is pressed.

Change History (23)

comment:1 Changed 3 years ago by bgamari

Operating System: Unknown/MultipleWindows

comment:2 Changed 3 years ago by Phyx-

I think Joey's IOCP based manager from #7353 could be a good start for this.

We should see how easy it is to bring his old code up to date on GHC now and how much of it can be re-used https://github.com/joeyadams/haskell-iocp

Might also want to consider support for Registered I/O which would significantly up the throughput for Windows Based server programs. It's a recent addition to Windows 8+, but might be worth a look at https://technet.microsoft.com/en-us/library/hh997032.aspx.

Last edited 3 years ago by Phyx- (previous) (diff)

comment:3 Changed 3 years ago by Phyx-

Cc: Phyx- added

comment:4 Changed 2 years ago by Phyx-

Milestone: 8.4.1

comment:5 Changed 21 months ago by simonpj

Description: modified (diff)

comment:6 Changed 21 months ago by Phyx-

I'm currently working on this and a few other things for my 8.4 contributions. But I'll refrain from mass assigning all these issues to me until I know for sure I can get it done. Currently it looks viable though.

comment:7 Changed 11 months ago by bgamari

Milestone: 8.4.18.6.1

This ticket won't be resolved in 8.4; remilestoning for 8.6. Do holler if you are affected by this or would otherwise like to work on it.

comment:8 Changed 7 months ago by Phyx-

Console part is implemented, file I/O is a bit more challenging to integrate as MIO isn't set up for asynchronous read/writes. It's taking a bit of time to iron out the correct interactions. Particularly when seeks are involved.

Last edited 7 months ago by Phyx- (previous) (diff)

comment:9 Changed 7 months ago by Phyx-

Owner: set to Phyx-

comment:10 Changed 6 months ago by bgamari

Milestone: 8.6.18.8.1

These won't be fixed for 8.6, bumping to 8.8.

comment:11 Changed 5 months ago by Phyx-

All these are now handled correctly under the new I/O manager. Open tasks are tracking down a deadlock and implementing the non-threaded implementation.

comment:12 Changed 4 months ago by Phyx-

deadlock fixed (turns out to be how the scheduler saves and restores errors in TLS when the haskell threads are scheduled) and timer manager integrated into I/O manager, working on fixing signal handlers and seeing if I can get it to work correctly in cygwin hosts like mintty which have unfortunately become standard.

Do still have an issue to fix where there seems to be an outstanding I/O request which never finishes.. I think this might be the LockFile request. Need to investigate.

Also working on how to implement the non-threaded version. Now that I'm unstuck on the deadlock can make some decent progress again.

comment:13 Changed 4 months ago by Phyx-

For the console I/O part I have implemented an alternative interface which is able to handle un-buffered reads. SO that works now as well on Windows. In un-buffered mode with processed inputs turned off, signal handlers won't work, as they'll be placed in the input stream one character at a time.

I think this is an acceptable limitation so I won't spend the time to support this for now.

comment:14 Changed 4 months ago by Phyx-

Blocking: 806 added

comment:15 Changed 4 months ago by Phyx-

Blocking: 2189 added

comment:16 Changed 4 months ago by Phyx-

Blocking: 2408 added

comment:17 Changed 4 months ago by Phyx-

Blocking: 4471 added

comment:18 Changed 4 months ago by Phyx-

Blocking: 7353 added

comment:19 Changed 4 months ago by Phyx-

Blocking: 7593 added

comment:20 Changed 4 months ago by Phyx-

Blocking: 10542 added

comment:21 Changed 4 months ago by Phyx-

Blocking: 12873 added

comment:22 Changed 4 months ago by Phyx-

Blocking: 14530 added

comment:23 Changed 4 months ago by Phyx-

Description: modified (diff)

Started designing the last piece of the puzzle which is non-threaded RTS. The non-threaded I/O manager seems to have a completely different interface on Windows, going so far as to having 3 Windows only prim-ops. Trying to understand why...

With the threaded RTS I still have to track down a race condition somewhere. I think it has to do with the foreign pointer's finalizers... Wonder if I can turn off GC completely.

Note: See TracTickets for help on using tickets.