Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up`stack ghc` painfully slow #1671
Comments
benhillis
added
the
backlog
label
Feb 6, 2017
This comment has been minimized.
This comment has been minimized.
This is on our backlog but is unlikely to make the Creators Update. I know we're planning on looking at this soon though. For some context, I've looked at what causes this slowdown. For some reason stack has mapped an mind-bogglingly huge region of memory (I'm talking dozens of terabytes). When we fork we walk the entire address range to set up the new process's state. We have a design that should vastly speed this up, but we're approaching "pencils down" date for Creators Update. |
This comment has been minimized.
This comment has been minimized.
Gotcha, thanks for the context! |
This comment has been minimized.
This comment has been minimized.
Terabytes. That's awesome. Can't wait to see it in Resource Monitor. |
This comment has been minimized.
This comment has been minimized.
I assume they're doing it to manage their own heap. It's a big "MAP_NORESERVE" region which Linux seems to intelligently handle since "allocate all the things" seems to be a common paradigm. |
This comment has been minimized.
This comment has been minimized.
This seems to be the related discussion over at ghc ticket 9706 here, for what it is worth. Quoth:
So by my math that's 100×1012×104 = 1018 ≅ 260, which gets you in just under the wire. Or something. |
This comment has been minimized.
This comment has been minimized.
Adding @stehufntdev because he's been looking into this as well. |
This comment has been minimized.
This comment has been minimized.
mckennapsean
commented
Feb 18, 2017
I have encountered a similar bug with plain I found this slowdown by installing ghc v.8.0.2 (anything v.7.10 and below was fast) or by installing pandoc v.1.18 & above. See directions to install ghc or install pandoc for testing. If needed, I can provide a simple set of commands to reproduce. They both run similarly slow/delayed for me on both systems, but I have not seen reports from other *nix users seeing similar slowdowns, so I am guessing this is WSL related. |
mckennapsean
referenced this issue
Feb 18, 2017
Closed
massive delay to call pandoc using the Windows Subsystem for Linux (WSL) or Bash for Windows #3448
therealkenc
referenced this issue
Feb 20, 2017
Closed
Haskell compiler 8.0.x is slow when run from inside Stack on Windows 10 Ubuntu subsystem #1713
This comment has been minimized.
This comment has been minimized.
sukhmel
commented
Feb 20, 2017
•
This does not require Stack to replicate, GHC compiler alone is enough. I'm experiencing the same dreadfully slow compiler work. Besides, programs compiled with 8.0.x are slow too.
|
This comment has been minimized.
This comment has been minimized.
RyanGlScott
commented
Feb 20, 2017
@benhillis: I believe you've bumped into GHC 8.0's new block-structured heap for 64-bit platforms. From the GHC 8.0.1 release notes:
|
This comment has been minimized.
This comment has been minimized.
@RyanGlScott - I suspect you are right. We need to modify the way our memory manager keeps track of uncommitted pages. I'd be very curious to see some performance measurements on how much better their allocator performs versus raw mmap / munmap calls. |
This comment has been minimized.
This comment has been minimized.
I was going to quip that curiosity too, but stuck with "awesome" instead. So you benchmark 8.0 and find out it is some percent faster than 7.0. Or just as fast, but simpler. But you end up demonstrating not much in the exercise. The Haskell guys seem okay with a hello world app asking for a terabyte of virtual memory. The Chakra guys seem okay with asking for 32GB to print hello, and if you are going to do that, [expletive], why not ask for a TB. I am still academically interested in how they arrived at 32GB. Why not 64GB or 128GB? Certainly not because "that would be crazy". It's working code. Smart people thought it was a good idea. Shrug. What you gonna do except sigh and re-work the memory manager. |
This comment has been minimized.
This comment has been minimized.
RyanGlScott
commented
Feb 20, 2017
FWIW, Golang also does something similar by reserving a contiguous chunk of 512 GB of memory (see this comment). I'm certainly not qualified enough to say how they came up with that number, other than that it's a power of two and—to use their words—"512 GB (MaxMem) should be big enough for now". |
therealkenc
referenced this issue
Feb 27, 2017
Open
support legacy vsyscall - Segmentation Fault using a gcc cross compiler #1462
This comment has been minimized.
This comment has been minimized.
pechersky
commented
Apr 19, 2017
•
I have a workaround in the meantime, based on the discussion in https://ghc.haskell.org/trac/ghc/ticket/13304. It involves compiling your own GHC which does not utilize the large address space allocation, and then using that as the GHC for your stack builds. My workaround relies on then supplying that GHC as the common GHC for your projects. In my example, I will recompile GHC 8.0.2 using whatever ghc you already have on your system. I will also make sure that Cabal is installed using this GHC -- otherwise, installing other packages will fall under the same problem of slowness. I suggest cleaning your To fix, in the bash environment, I ran
Now you can do your You can monitor the VIRT usage with something like |
This comment has been minimized.
This comment has been minimized.
sgraf812
commented
Apr 21, 2017
Don't you also have to recompile |
This comment has been minimized.
This comment has been minimized.
pechersky
commented
Apr 21, 2017
@sgraf812 In my use cases, I have not had to recompile stack. If I understand correctly, stack itself never builds anything, just calls the appropriate ghc to do so, through the project-level or system-level ghc (ghci, ghc-through-cabal, etc). This issue only appears during builds, so as long as the ghc that stack uses is fine, stack itself should be fine. Monitoring the path of the |
This comment has been minimized.
This comment has been minimized.
TerrorJack
commented
Apr 21, 2017
@pechersky This issue affects not only GHC 8, but also anything compiled with it ( |
This comment has been minimized.
This comment has been minimized.
pechersky
commented
Apr 21, 2017
@TerrorJack Thank you for clarifying that for me. My work-around fixes the " |
This comment has been minimized.
This comment has been minimized.
TerrorJack
commented
Apr 21, 2017
@pechersky Also, the |
This comment has been minimized.
This comment has been minimized.
pechersky
commented
Apr 21, 2017
@TerrorJack The |
This comment has been minimized.
This comment has been minimized.
TerrorJack
commented
Apr 21, 2017
@pechersky |
This comment has been minimized.
This comment has been minimized.
pechersky
commented
Apr 21, 2017
I have updated the code above to include your suggestion, @TerrorJack. According to https://docs.haskellstack.org/en/stable/faq/#what-is-the-relationship-between-stack-and-cabal, both the lib ( |
Apr 21, 2017
This was referenced
bsdz
referenced this issue
Jul 23, 2017
Closed
bash won't start after hang during intensive compilation & zombie processes remain after reboots #2364
This comment has been minimized.
This comment has been minimized.
Roman2K
commented
Aug 1, 2017
•
On the latest stable non-insider as of 31/07/2017, I noticed untars and Antimalware only takes ~5% of the CPU so maybe the slow part is the transfer of contents from WSL to that process. But I don't have any idea of what I'm talking about So I tried the insider preview 16251 and immediately noticed a huge difference Here are
Sorry I don't have more to provide. I hope you will keep on improving WSL, that's excellent work on an fantastic concept. |
This comment has been minimized.
This comment has been minimized.
@Roman2K - Thanks for the information. I'm glad that it's much more usable for you, but we still do have a long way to go. We're looking into ways to improve base NTFS speed to help bring Windows filesystem performance more in line with Linux. |
This comment has been minimized.
This comment has been minimized.
I have anecdotally found the same problem with [edit] Another data point is |
NickSeagull
referenced this issue
Aug 22, 2017
Closed
Would an additional platform check GHC version for Windows Subsystem for Linux make sense? #28471
oscarvarto
referenced this issue
Aug 30, 2017
Open
Stack install failing on windows with `unknown symbol `ucnv_getMaxCharSize_58'` #56
PierreR
referenced this issue
Oct 26, 2017
Open
NixOS in Windows Store for Windows Subsystem for Linux (WSL) #30391
therealkenc
referenced this issue
Nov 2, 2017
Open
Files gets allocated instantly - Kills SSDs #2626
Nov 11, 2017
This was referenced
Wizek
referenced this issue
Nov 20, 2017
Closed
Is WSL (Windows Subsystem for Linux) supported? #177
kumarharsh
referenced this issue
Nov 21, 2017
Closed
Please implement a tabbed command line window #2393
This comment has been minimized.
This comment has been minimized.
We have improved mmap performance further in insider build 17063. I believe this makes stack ghc bearable to use now :). |
This comment has been minimized.
This comment has been minimized.
AaronFriel
commented
Dec 20, 2017
Thank you! I can attest to the significant improvement. |
therealkenc
referenced this issue
Jan 21, 2018
Closed
Performance issue when serving Python3.5 scripts through Apache + WSGI #2863
This comment has been minimized.
This comment has been minimized.
cemerick
commented
Jan 23, 2018
Another anecdote: I opted into 17074 hoping to get acceptable working conditions, but Sorry for the negative report; keep doing great work, you'll get there. |
This comment has been minimized.
This comment has been minimized.
hvr
commented
Feb 14, 2018
•
In the hopes this may be useful to somebody here: I've set up a GHC PPA optimised for WSL (i.e. built with https://launchpad.net/~hvr/+archive/ubuntu/ghc-wsl It should merely be a matter of
and then simply prepending |
therealkenc
added
fixedinfallcreatorsupdate
fixedininsiderbuilds
and removed
fixedininsiderbuilds
fixedinfallcreatorsupdate
labels
Mar 26, 2018
This comment has been minimized.
This comment has been minimized.
cboudereau
commented
Apr 12, 2018
I would like to use VSCode on Windows + WSL + Stack ghci but due to this problem, it is really slow. I will check if recompiling a custom ghc without large address space allocation is better or not. Thanks @pechersky ! |
This comment has been minimized.
This comment has been minimized.
nb: GHC is "still slow" (as it were) but this was deemed fixedininsiderbuilds back in July 2017, and finally made its way into the April Update. |
ezrosent commentedFeb 5, 2017
A brief description
Managing haskell projects with the
stack
tool is unusable due to how slow it is.Expected results
(from a laptop running ubuntu 16.04)
On desktop running WSL
15025
After installation, need stack to pull in a version of GHC. This should do the trick.
Generating the strace output (attached) inludes a few long (multi-second) waits on FUTEX_WAIT, as well as one for mmap.
Install stack with the standard instructions
stack_ghc_strace.txt