I thought I'd use roc for some january generative art hacking, but the hello world compile time is looking like it'll be prohibitive. I'm seeing ~4 seconds to run roc dev
, with nothing more than the basic "I'm a roc application" cli file from the tutorial. Is this expected? Do I have something wrong with my setup?
No, that doesn't sound normal at all. The compiler is so fast that sometimes I double check to see if it's showing me cached data, but it's not. Can you say more about your setup? Like is it a release or development build of the compiler itself?
@Brian Carroll
genuary on main ➜ ./roc version
roc nightly pre-release, built from commit faaa466 on Sat Dec 17 09:07:43 UTC 2022
are the nightlies a dev build or something?
Code Generation
53.487 ms Generate Assembly from Mono IR
Finished compilation and code gen in 87 ms
Produced a app.o file of size 4744
Finished linking in 3674 ms
wow lol what's up with linking
I'm on an intel MBP monterey fwiw
Jared said:
Brian Carroll
genuary on main ➜ ./roc version roc nightly pre-release, built from commit faaa466 on Sat Dec 17 09:07:43 UTC 2022
are the nightlies a dev build or something?
Nope! They're release builds.
Wow that link time is crazy. I'm not the best person to investigate but I'm sure someone will. Thanks for bringing it up!
For what it's worth linking is a bottleneck for some of the other languages that I explore.
Yes, that's true for us too, but this still seems well outside the normal range.
Can you share a gist of the exact code you are running? I can take a look. Though there is a chance I won't be able to repro if it depends on running on an Intel Mac.
Actually, I think I was able to repro. Though not to the same extent. On an M1 mac. linking takes about 1.6 seconds. Which is still super slow for a hello world app
Ok. So I think I know the root cause, but I am not sure how we will want to go about fixing it.
For ld
almost all of the time is spent in writing the output file: write output: 1.3 seconds ( 82.8%)
This is because the output file is about 32 megabytes.
The reason for this is 2 fold:
staticlib
, it seems to link everything even if it isn't used (I have not figured out a way to stop this).As such, the staticlib is about 32 megabytes. On the other hand, when directly linking an executable and cleaning up dead code, the total size is about 0.5 megabytes.
Possible fixes:
staticlib
seems to link in everything/how to fix that.I think switching to from reqwest
to ureq
will be the easiest short term solution.
though it only cuts from ~30MB to ~20MB...so not a big win actually....
hmmm
Oh, though it cuts link time from 1.6s to 0.6s for me. So that is a solid win.
how long is the link time on Linux with the surgical linker?
~0ms
That or the the timing is broken for the surgical linker. The timing seems to a be accurate, but I am not 100% convinced that includes dumping to file. That said, the entire process runs in ~200ms while compilation takes ~190ms. The last ~10ms would include loading the roc application itself and maybe dumping to file.
Yeah, on my Linux machine, the legacy linker takes ~4s. So that matches the slow macos timing pretty well. It is linking ~35MB. The surgical linker only has to link ~7MB. Though obviously is faster for other reasons as well.
nice! So presumably surgical linking the fix we really want on macOS :big_smile:
Yep
how far off is surgical for mac?
That's a hard question to answer. Theoretically the code is pretty close, but:
Last updated: Jul 06 2025 at 12:14 UTC