haskell / ghcup-hs

https://www.haskell.org/ghcup/
GNU Lesser General Public License v3.0
288 stars 89 forks source link

runghc is slow #1128

Open brayandiazssjd opened 1 month ago

brayandiazssjd commented 1 month ago

Computer information OS: Windows 10 22H2 Architecture: x64

Hello, I have installed Haskell in Windows throw the Powershell command provided by the official website. I have installed it in a existing msys2 installation. The issue I have is that when executing 'runghc' command in msys2 prompt, it takes about 8 seconds. I do not know if it is normal in Windows, but in Linux it takes less than 1 second with the same source code (a hello world print). I also have to mention that when verifying version of runghc it has a good time response (less than a second).

I made a trace command and I noticed that the part that takes the longer is just before the print of the hello world in the line "--- Process 10944 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libwinpthread-1.dll at 00007ffc72f20000". I would appreciate help or information about this "problem". Thank you very much.

Here is complete output of the strace command:

--- Process 8828 created
--- Process 8828 loaded C:\Windows\System32\ntdll.dll at 00007ffcd6b70000
--- Process 8828 loaded C:\Windows\SysWOW64\ntdll.dll at 00000000779b0000
--- Process 8828 loaded C:\Windows\System32\wow64.dll at 00007ffcd68d0000
--- Process 8828 loaded C:\Windows\System32\wow64win.dll at 00007ffcd4bc0000
--- Process 8828 loaded C:\Windows\System32\wow64cpu.dll at 00000000779a0000
--- Process 8828 loaded C:\Windows\SysWOW64\kernel32.dll at 0000000076500000
--- Process 8828 loaded C:\Windows\SysWOW64\KernelBase.dll at 0000000075d20000
--- Process 8828 loaded C:\Windows\SysWOW64\shell32.dll at 0000000077360000
--- Process 8828 loaded C:\Windows\SysWOW64\msvcp_win.dll at 0000000076f90000
--- Process 8828 loaded C:\Windows\SysWOW64\ucrtbase.dll at 0000000076c80000
--- Process 8828 thread 10948 created
--- Process 8828 thread 7592 created
--- Process 8828 loaded C:\Windows\SysWOW64\user32.dll at 00000000761c0000
--- Process 8828 loaded C:\Windows\SysWOW64\win32u.dll at 0000000076da0000
--- Process 8828 loaded C:\Windows\SysWOW64\gdi32.dll at 0000000077270000
--- Process 8828 loaded C:\Windows\SysWOW64\gdi32full.dll at 00000000760d0000
--- Process 8828 thread 10892 created
--- Process 8828, exception 4000001f at 0000000077a61b72
--- Process 8828 loaded C:\Windows\SysWOW64\imm32.dll at 00000000771e0000
--- Process 8828 loaded C:\Windows\SysWOW64\sechost.dll at 0000000076a00000
--- Process 8828 loaded C:\Windows\SysWOW64\rpcrt4.dll at 0000000076370000
--- Process 8828 loaded C:\Windows\SysWOW64\bcrypt.dll at 00000000765f0000
--- Process 8704 created
--- Process 8704 loaded C:\Windows\System32\ntdll.dll at 00007ffcd6b70000
--- Process 8704 loaded C:\Windows\System32\kernel32.dll at 00007ffcd5b10000
--- Process 8704 loaded C:\Windows\System32\KernelBase.dll at 00007ffcd4570000
--- Process 8704 loaded C:\Windows\System32\user32.dll at 00007ffcd6190000
--- Process 8704 loaded C:\Windows\System32\win32u.dll at 00007ffcd43e0000
--- Process 8704 loaded C:\Windows\System32\gdi32.dll at 00007ffcd5fd0000
--- Process 8704 loaded C:\Windows\System32\gdi32full.dll at 00007ffcd4870000
--- Process 8704 loaded C:\Windows\System32\msvcp_win.dll at 00007ffcd44d0000
--- Process 8704 loaded C:\Windows\System32\ucrtbase.dll at 00007ffcd42e0000
--- Process 8704 thread 2440 created
--- Process 8704 thread 2132 created
--- Process 8704 thread 2140 created
--- Process 8704 loaded C:\Windows\System32\shell32.dll at 00007ffcd4cf0000
--- Process 8704 loaded C:\Windows\System32\ole32.dll at 00007ffcd6930000
--- Process 8704 loaded C:\Windows\System32\rpcrt4.dll at 00007ffcd5460000
--- Process 8704 loaded C:\Windows\System32\winmm.dll at 00007ffcb7690000
--- Process 8704 loaded C:\Windows\System32\dbghelp.dll at 00007ffccf6c0000
--- Process 8704 loaded C:\Windows\System32\combase.dll at 00007ffcd5630000
--- Process 8704 loaded C:\Windows\System32\msvcrt.dll at 00007ffcd4c50000
--- Process 8704 loaded C:\Windows\System32\wsock32.dll at 00007ffcc3550000
--- Process 8704 loaded C:\Windows\System32\ws2_32.dll at 00007ffcd6ac0000
--- Process 8704 loaded C:\Windows\System32\ws2_32.dll at 0000019caf7b0000
--- Process 8704 unloaded DLL at 0000019caf7b0000
--- Process 8704 loaded C:\Windows\System32\imm32.dll at 00007ffcd5a10000
--- Process 8704 loaded C:\Windows\System32\sechost.dll at 00007ffcd5590000
--- Process 8704 loaded C:\Windows\System32\bcrypt.dll at 00007ffcd4220000
--- Process 2216 created
--- Process 2216 loaded C:\Windows\System32\ntdll.dll at 00007ffcd6b70000
--- Process 2216 loaded C:\Windows\System32\kernel32.dll at 00007ffcd5b10000
--- Process 2216 loaded C:\Windows\System32\KernelBase.dll at 00007ffcd4570000
--- Process 2216 loaded C:\Windows\System32\ucrtbase.dll at 00007ffcd42e0000
--- Process 2216 thread 2152 created
--- Process 2216 loaded C:\Windows\System32\shell32.dll at 00007ffcd4cf0000
--- Process 2216 loaded C:\Windows\System32\msvcp_win.dll at 00007ffcd44d0000
--- Process 2216 loaded C:\Windows\System32\user32.dll at 00007ffcd6190000
--- Process 2216 loaded C:\Windows\System32\win32u.dll at 00007ffcd43e0000
--- Process 2216 loaded C:\Windows\System32\gdi32.dll at 00007ffcd5fd0000
--- Process 2216 loaded C:\Windows\System32\gdi32full.dll at 00007ffcd4870000
--- Process 2216 thread 2124 created
--- Process 2216 thread 2172 created
--- Process 2216 loaded C:\Windows\System32\advapi32.dll at 00007ffcd6000000
--- Process 2216 loaded C:\Windows\System32\msvcrt.dll at 00007ffcd4c50000
--- Process 2216 loaded C:\Windows\System32\sechost.dll at 00007ffcd5590000
--- Process 2216 loaded C:\Windows\System32\rpcrt4.dll at 00007ffcd5460000
--- Process 2216 loaded C:\Windows\System32\bcrypt.dll at 00007ffcd4220000
--- Process 2216 loaded C:\Windows\System32\ole32.dll at 00007ffcd6930000
--- Process 2216 loaded C:\Windows\System32\combase.dll at 00007ffcd5630000
--- Process 2216 loaded C:\Windows\System32\ws2_32.dll at 00007ffcd6ac0000
--- Process 2216 loaded C:\Windows\System32\wsock32.dll at 00007ffcc3550000
--- Process 2216 loaded C:\Windows\System32\winmm.dll at 00007ffcb7690000
--- Process 2216 loaded C:\Windows\System32\dbghelp.dll at 00007ffccf6c0000
--- Process 2216 loaded C:\Windows\System32\dbgcore.dll at 00007ffcb2200000
--- Process 2216 loaded C:\Windows\System32\imm32.dll at 00007ffcd5a10000
--- Process 2216 loaded C:\Windows\System32\SHCore.dll at 00007ffcd5e10000
--- Process 2216 thread 2504 created
--- Process 2424 created
--- Process 2424 loaded C:\Windows\System32\ntdll.dll at 00007ffcd6b70000
--- Process 2424 loaded C:\Windows\System32\kernel32.dll at 00007ffcd5b10000
--- Process 2424 loaded C:\Windows\System32\KernelBase.dll at 00007ffcd4570000
--- Process 2424 loaded C:\Windows\System32\user32.dll at 00007ffcd6190000
--- Process 2424 loaded C:\Windows\System32\win32u.dll at 00007ffcd43e0000
--- Process 2424 loaded C:\Windows\System32\gdi32.dll at 00007ffcd5fd0000
--- Process 2424 loaded C:\Windows\System32\gdi32full.dll at 00007ffcd4870000
--- Process 2424 loaded C:\Windows\System32\msvcp_win.dll at 00007ffcd44d0000
--- Process 2424 loaded C:\Windows\System32\ucrtbase.dll at 00007ffcd42e0000
--- Process 2424 thread 2244 created
--- Process 2424 thread 2100 created
--- Process 2424 thread 10300 created
--- Process 2424 loaded C:\Windows\System32\shell32.dll at 00007ffcd4cf0000
--- Process 2424 loaded C:\Windows\System32\ole32.dll at 00007ffcd6930000
--- Process 2424 loaded C:\Windows\System32\rpcrt4.dll at 00007ffcd5460000
--- Process 2424 loaded C:\Windows\System32\winmm.dll at 00007ffcb7690000
--- Process 2424 loaded C:\Windows\System32\dbghelp.dll at 00007ffccf6c0000
--- Process 2424 loaded C:\Windows\System32\combase.dll at 00007ffcd5630000
--- Process 2424 loaded C:\Windows\System32\msvcrt.dll at 00007ffcd4c50000
--- Process 2424 loaded C:\Windows\System32\wsock32.dll at 00007ffcc3550000
--- Process 2424 loaded C:\Windows\System32\ws2_32.dll at 00007ffcd6ac0000
--- Process 2424 loaded C:\Windows\System32\ws2_32.dll at 000001a2299a0000
--- Process 2424 unloaded DLL at 000001a2299a0000
--- Process 2424 loaded C:\Windows\System32\imm32.dll at 00007ffcd5a10000
--- Process 2424 loaded C:\Windows\System32\sechost.dll at 00007ffcd5590000
--- Process 2424 loaded C:\Windows\System32\bcrypt.dll at 00007ffcd4220000
--- Process 10944 created
--- Process 10944 loaded C:\Windows\System32\ntdll.dll at 00007ffcd6b70000
--- Process 10944 loaded C:\Windows\System32\kernel32.dll at 00007ffcd5b10000
--- Process 10944 loaded C:\Windows\System32\KernelBase.dll at 00007ffcd4570000
--- Process 10944 loaded C:\Windows\System32\ucrtbase.dll at 00007ffcd42e0000
--- Process 10944 thread 10928 created
--- Process 10944 loaded C:\Windows\System32\shell32.dll at 00007ffcd4cf0000
--- Process 10944 loaded C:\Windows\System32\msvcp_win.dll at 00007ffcd44d0000
--- Process 10944 loaded C:\Windows\System32\user32.dll at 00007ffcd6190000
--- Process 10944 loaded C:\Windows\System32\win32u.dll at 00007ffcd43e0000
--- Process 10944 loaded C:\Windows\System32\gdi32.dll at 00007ffcd5fd0000
--- Process 10944 loaded C:\Windows\System32\gdi32full.dll at 00007ffcd4870000
--- Process 10944 thread 2136 created
--- Process 10944 thread 7284 created
--- Process 10944 loaded C:\Windows\System32\advapi32.dll at 00007ffcd6000000
--- Process 10944 loaded C:\Windows\System32\msvcrt.dll at 00007ffcd4c50000
--- Process 10944 loaded C:\Windows\System32\sechost.dll at 00007ffcd5590000
--- Process 10944 loaded C:\Windows\System32\rpcrt4.dll at 00007ffcd5460000
--- Process 10944 loaded C:\Windows\System32\bcrypt.dll at 00007ffcd4220000
--- Process 10944 loaded C:\Windows\System32\ole32.dll at 00007ffcd6930000
--- Process 10944 loaded C:\Windows\System32\combase.dll at 00007ffcd5630000
--- Process 10944 loaded C:\Windows\System32\shlwapi.dll at 00007ffcd5990000
--- Process 10944 loaded C:\Windows\System32\wsock32.dll at 00007ffcc3550000
--- Process 10944 loaded C:\Windows\System32\ws2_32.dll at 00007ffcd6ac0000
--- Process 10944 loaded C:\Windows\System32\winmm.dll at 00007ffcb7690000
--- Process 10944 loaded C:\Windows\System32\dbghelp.dll at 00007ffccf6c0000
--- Process 10944 loaded C:\Windows\System32\dbgcore.dll at 00007ffcb2200000
--- Process 10944 loaded C:\Windows\System32\imm32.dll at 00007ffcd5a10000
--- Process 10944 loaded C:\Windows\System32\SHCore.dll at 00007ffcd5e10000
--- Process 10944 thread 8572 created
--- Process 10944 thread 6696 created
--- Process 10944 thread 10296 created
--- Process 10944 loaded C:\Windows\System32\windows.storage.dll at 00007ffccef10000
--- Process 10944 loaded C:\Windows\System32\wldp.dll at 00007ffcd3b80000
--- Process 10944 loaded C:\Windows\System32\oleaut32.dll at 00007ffcd5a40000
--- Process 10944 loaded C:\Windows\System32\profapi.dll at 00007ffcd4150000
--- Process 8732 created
--- Process 10944 thread 8940 created
--- Process 8732 loaded C:\Windows\System32\ntdll.dll at 00007ffcd6b70000
--- Process 8732 loaded C:\Windows\System32\kernel32.dll at 00007ffcd5b10000
--- Process 8732 loaded C:\Windows\System32\KernelBase.dll at 00007ffcd4570000
--- Process 8732 thread 10524 created
--- Process 8732 thread 11084 created
--- Process 8732 loaded C:\Windows\System32\ucrtbase.dll at 00007ffcd42e0000
--- Process 8732 thread 6264 created
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libc++.dll at 00007ffc79170000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libunwind.dll at 00007ffcc3540000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libclang-cpp.dll at 00007ffc76210000
--- Process 8732 loaded C:\Windows\System32\advapi32.dll at 00007ffcd6000000
--- Process 8732 loaded C:\Windows\System32\version.dll at 00007ffcc9920000
--- Process 8732 loaded C:\Windows\System32\msvcrt.dll at 00007ffcd4c50000
--- Process 8732 loaded C:\Windows\System32\sechost.dll at 00007ffcd5590000
--- Process 8732 loaded C:\Windows\System32\rpcrt4.dll at 00007ffcd5460000
--- Process 8732 loaded C:\Windows\System32\bcrypt.dll at 00007ffcd4220000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libLLVM-14.dll at 00007ffc71d90000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libLLVM-14.dll at 000001df29800000
--- Process 8732 unloaded DLL at 000001df29800000
--- Process 8732 loaded C:\Windows\System32\shell32.dll at 00007ffcd4cf0000
--- Process 8732 loaded C:\Windows\System32\msvcp_win.dll at 00007ffcd44d0000
--- Process 8732 loaded C:\Windows\System32\user32.dll at 00007ffcd6190000
--- Process 8732 loaded C:\Windows\System32\win32u.dll at 00007ffcd43e0000
--- Process 8732 loaded C:\Windows\System32\gdi32.dll at 00007ffcd5fd0000
--- Process 8732 loaded C:\Windows\System32\gdi32full.dll at 00007ffcd4870000
--- Process 8732 loaded C:\Windows\System32\ole32.dll at 00007ffcd6930000
--- Process 8732 loaded C:\Windows\System32\combase.dll at 00007ffcd5630000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libffi-7.dll at 00007ffcb9170000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\zlib1.dll at 00007ffc9c1b0000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libxml2-2.dll at 00007ffc71c30000
--- Process 8732 loaded C:\Windows\System32\ws2_32.dll at 00007ffcd6ac0000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libiconv-2.dll at 00007ffc71b10000
--- Process 8732 loaded C:\ghcup\ghc\9.4.8\mingw\bin\liblzma-5.dll at 00007ffc9a580000
--- Process 8732 loaded C:\Windows\System32\imm32.dll at 00007ffcd5a10000
--- Process 8732 loaded C:\Windows\System32\cryptbase.dll at 00007ffcd3ad0000
--- Process 8732 loaded C:\Windows\System32\bcryptprimitives.dll at 00007ffcd4250000
--- Process 8732 loaded C:\Windows\System32\dbghelp.dll at 00007ffccf6c0000
--- Process 8732 loaded C:\Windows\System32\dbgcore.dll at 00007ffcb2200000
--- Process 8732 loaded C:\Windows\System32\kernel.appcore.dll at 00007ffcd2a30000
--- Process 8732 thread 11084 exited with status 0x0
--- Process 8732 thread 6264 exited with status 0x0
--- Process 8732 thread 10524 exited with status 0x0
--- Process 8732 exited with status 0x0
--- Process 10944 loaded C:\ghcup\ghc\9.4.8\mingw\bin\libwinpthread-1.dll at 00007ffc72f20000
Hello, World!
--- Process 10944 thread 6696 exited with status 0x0
--- Process 10944 thread 10296 exited with status 0x0
--- Process 10944 thread 8940 exited with status 0x0
--- Process 10944 loaded C:\Windows\System32\kernel.appcore.dll at 00007ffcd2a30000
--- Process 10944 thread 2136 exited with status 0x0
--- Process 10944 thread 7284 exited with status 0x0
--- Process 10944 thread 8572 exited with status 0x0
--- Process 10944 thread 10928 exited with status 0x0
--- Process 10944 exited with status 0x0
--- Process 2424 loaded C:\Windows\System32\kernel.appcore.dll at 00007ffcd2a30000
--- Process 2424 thread 10300 exited with status 0x0
--- Process 2424 thread 2100 exited with status 0x0
--- Process 2424 thread 2244 exited with status 0x0
--- Process 2424 exited with status 0x0
--- Process 2216 loaded C:\Windows\System32\kernel.appcore.dll at 00007ffcd2a30000
--- Process 2216 thread 2504 exited with status 0x0
--- Process 2216 thread 2124 exited with status 0x0
--- Process 2216 thread 2172 exited with status 0x0
--- Process 2216 thread 2152 exited with status 0x0
--- Process 2216 exited with status 0x0
--- Process 8704 loaded C:\Windows\System32\kernel.appcore.dll at 00007ffcd2a30000
--- Process 8704 thread 2140 exited with status 0x0
--- Process 8704 thread 2132 exited with status 0x0
--- Process 8704 thread 2440 exited with status 0x0
--- Process 8704 exited with status 0x0
--- Process 8828 loaded C:\Windows\SysWOW64\kernel.appcore.dll at 0000000075150000
--- Process 8828 loaded C:\Windows\SysWOW64\msvcrt.dll at 00000000770a0000
--- Process 8828 thread 7592 exited with status 0x0
--- Process 8828 thread 10892 exited with status 0x0
--- Process 8828 thread 10948 exited with status 0x0
--- Process 8828 exited with status 0x0
dfordivam commented 1 month ago

@brayandiazssjd runghc both compiles and runs the program, and the slowdown could be in compilation stage. You can probably try compilation with ghc and then run the compiled program to see where slowdown is happening. In either case it would be better to open the issue in ghc issue tracker for a solution to this kind of a problem https://gitlab.haskell.org/ghc/ghc/-/issues

brayandiazssjd commented 1 month ago

Hi, @dfordivam I measured the time for compilation and it only takes about two seconds, and the execution of the .exe file takes less than a second. I guess ghc is not the problem, do you still recommend me to open the issue in ghc's gitlab? Thanks for your time!

hasufell commented 1 month ago

It is theoretically possible though that the problem is with our shim exe... so to truly know which is the case you'd have to execute the ghc that's in /c/ghcup/ghc/9.4.8/ somewhere