Skip to content
  • Tamar Christina's avatar
    Optimize linker by minimizing calls to tryGCC to avoid fork/exec overhead. · 8d647450
    Tamar Christina authored and Ben Gamari's avatar Ben Gamari committed
    On Windows process creations are fairly expensive. As such calling them in
    what's essentially a hot loop is also fairly expensive.
    
    Each time we make a call to `tryGCC` the following fork/exec/wait happen
    
    ```
    gcc -> realgcc -> cc1
    ```
    
    This is very problematic, because according to the profiler about 20% of the
    time is spent on just process creation and spin time.
    
    The goal of the patch is to mitigate this by asking GCC once for it's search
    directories, caching these (because it's very hard to change these at all
    after the process started since GCC's base dirs don't change unless with
    extra supplied `-B` flags.).
    
    We also do the same for the `findSysDll` function, since this computes
    the search path every time by registery accesses etc.
    
    These changes and D3909 drop GHC on Windows startup time from 2-3s to 0.5s.
    
    The remaining issue is a 1.5s wait lock on `CONIN$` which can be addressed
    with the new I/O manager code. But this makes GHCi as responsive on Windows as
    GHC 7.8 was.
    
    Test Plan: ./validate
    
    Reviewers: austin, hvr, bgamari, erikd
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3910
    8d647450