Bring non-threaded deadlock detection design into line with threaded

This (fairly long) series of patches changes the design of deadlock detection and idle GC used in the non-threaded RTS to make it the same as the design already used in the threaded RTS. The deadlock detection and idle GC features are intimately related (with deadlock detection relying on idle GC), which is why we end up fixing both together in one MR.

These changes brings a number of benefits:

  • idle GC in the non-threaded RTS now works (at all), fixes #27040
  • deadlock detection in the non-threaded RTS now works better, fixes #26408
  • fewer designs!
  • fewer differences between threaded and non-threaded RTS mode
  • easier to understand code
  • less CPP for THREADED_RTS or for mingw32
  • no mingling of signal handling code into the scheduler
  • it is now possible to detect partial deadlocks in the non-threaded RTS
  • also fixes #26403 and #26409, a couple WinIO issues
  • pre-requisite for getting in-RTS I/O managers to work in the threaded RTS (which is the ultimate motivation here)

The old and new designs of deadlock detection are now documented in a long Note [Deadlock detection]

A user visible change is that idle GC is now enabled by default on the non-threaded RTS. In particular this means that deadlocks are no longer detected promptly, but after an idle GC timeout (default 0.3s). This is the same as the threaded RTS behaviour. On the other hand, more deadlocks can now be detected.

The user guide is updated to document that idle GC behaviour and default parameters is not conditional on threaded/non-threaded. Also document in the user guide the fact that deadlock detection relies on idle GC, and thus turning off idle GC turns off deadlock detection.

The MR also relies upon on a number of refactorings and minor features:

  • further refactoring of I/O manager APIs (both this MR and also !16217 (closed))
  • extend I/O manager resource management hooks, per-cap free and re-init after fork (MR !16217 (closed)).
  • in-RTS I/O managers now support interruptIOManager (MR !16217 (closed))
  • the new FdWakeup module (added in MR !15781 (merged)), shared by posix I/O managers
  • making I/O managers responsible for signal handling, and removal of signal handling in scheduler
  • cleanup of the internal RTS signal handler API
  • cleanup of the scheduler code, to make it more comprehensible
  • a new test for deadlock detection
Edited by Duncan Coutts

Merge request reports

Loading