Skip to content

Instantly share code, notes, and snippets.



Last active Feb 25, 2019
What would you like to do?

We were having a discussion about compilation and linking performance on Twitter and I decided to do some measurements of the current Ion compiler, which is written in C. It's built via a main.c file that #includes everything else. The codebase contained 8,840 lines of code when I measured this. It only has a handful of external includes for the C standard library.

Here I'm doing a full rebuild with fast-debug flags, using the /Bt flag to give a timing breakdown between frontend, backend and link:

OptRef: Total time = 0.000s
OptIcf: Total time = 0.015s
Pass 1: Interval #1, time = 0.062s
Pass 2: Interval #2, time = 0.016s
Final: Total time = 0.078s
Command took 0:0:0.32 (0.32s total)

That's 78 ms for the compile and 105 ms for the link. You'll see this doesn't add up to the total measured time from my timeit utility. I assume that's primarily because the compiler has a startup cost that isn't included in their breakdown. That would suggest that part of the cost is fixed and won't scale with larger codebases, although I haven't done experiments to validate this hypothesis.

For comparison, I tried building it with tcc on Windows, which has an integrated linker. The total compile and link time to produce the final executable on disk is 70 ms as measured by timeit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment