Skip to content
Snippets Groups Projects
Commit 8d647450 authored by Tamar Christina's avatar Tamar Christina Committed by Ben Gamari
Browse files

Optimize linker by minimizing calls to tryGCC to avoid fork/exec overhead.

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
parent ec9ac20d
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment