无需配置文件即可确定GHC内存消耗高的原因

时间:2019-04-11 22:01:33

标签: ghc

我听说GHC的每秒LOC速度很慢。所以我创建了这个Haskell程序:

module Main where
x1 = 1
x2 = 2
x3 = 3
...
x999998 = 999998
x999999 = 999999
x1000000 = 1000000
main = putStrLn "1M LOC!"

我什至无法编译它!至少我可以看到解析器每秒可以执行43行:

[1 of 1] Compiling Main             ( 1Mloc.hs, 1Mloc.o )
*** Parser [Main]:
Parser [Main]: alloc=22735369056 time=23683.420

据我所知,GHC RTS必须重新编译并启用分析,以开始挖掘原因。鉴于我还没有分析GHC,是否有机会弄清楚是什么原因造成的?我什至无法收集统计信息,因为它被杀死了……

Killed process 16609 (ghc) total-vm:1074093288kB, anon-rss:6804448kB ...

实际上,我也不能编译10K LOC。至少有1000 K LOC,我可以看到可怕的生产率数字。我意识到这是一个综合程序,但是有什么不好的呢?

Linking 1Kloc ...
   1,383,344,416 bytes allocated in the heap
     325,164,408 bytes copied during GC
      60,849,840 bytes maximum residency (9 sample(s))
         282,960 bytes maximum slop
              58 MB total memory in use (0 MB lost due to fragmentation)

                                     Tot time (elapsed)  Avg pause  Max pause
  Gen  0       233 colls,     0 par    0.227s   0.230s     0.0010s    0.0066s
  Gen  1         9 colls,     0 par    0.149s   0.174s     0.0193s    0.0588s

  TASKS: 4 (1 bound, 3 peak workers (3 total), using -N1)

  SPARKS: 0(0 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled)

  INIT    time    0.000s  (  0.000s elapsed)
  MUT     time    0.522s  (  1.047s elapsed)
  GC      time    0.376s  (  0.404s elapsed)
  EXIT    time    0.000s  (  0.008s elapsed)
  Total   time    0.899s  (  1.460s elapsed)

  Alloc rate    2,647,974,824 bytes per MUT second

  Productivity  58.1% of total user, 71.7% of total elapsed

0 个答案:

没有答案