简体   繁体   English

基准GHC编译时间

[英]Benchmarking GHC compilation times

My Haskell program takes too long to compile. 我的Haskell程序编译时间太长。

By that, I mean: It's been over a year since I've been able to compile with -O1. 我的意思是:自从我可以使用-O1进行编译以来已有一年多了。 Last time I tried, I set up a 64gb server just to compile my program, and let it run overnight. 上次尝试时,我设置了一个64gb服务器来编译程序,并使其运行一整夜。 It ran out of memory. 它内存不足。

I'm about to embark on some big re-engineering changes which I hope will speed up compilation times, but first I need to know what's taking so long, and get some good measurements so I can track progress. 我将着手进行一些重大的重新设计更改,以期加快编译时间,但是首先,我需要知道花费了这么长时间,并获得了一些不错的度量值,以便我可以跟踪进度。

I currently have two ideas for how to do this: 我目前对如何执行此操作有两个想法:

  1. Cover my program in flags so I can try compiling different pieces and timing them. 用标记覆盖我的程序,以便我可以尝试编译不同的片段并为它们计时。
  2. Writing a wrapper program for stack build that looks for lines like "[75 of 83] Compiling ," and times how long between them. 编写用于stack build的包装程序,以查找“ [75 of 83] Compiling”之类的行,并计算它们之间的间隔时间。

(1) sounds really ugly, and I don't expect (2) to give good numbers because of imprecision and because of cross-module compilation. (1)听起来确实很丑陋,而且我不希望(2)由于不精确和跨模块编译而给出好的数字。 Anyone have better ideas? 有人有更好的主意吗?

Better and easier than watching text output, I realized I could simply look at the timestamps on files in the build folder. 比观看文本输出更好和更容易,我意识到我可以简单地查看build文件夹中文件的时间戳。

This command gives me a nice list of build files sorted by timestamp, so I can roughly tell how long it spent on each: 该命令为我提供了一个按时间戳排序的构建文件列表,因此我可以粗略地了解每个文件花费了多长时间:

ls -l -c -T -R .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/<source folder> | grep "rw" | grep "\." | awk '{print $8,$10}' | sort

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM