You are viewing archived messages.
Go here to search the history.

Dany 2024-08-10 07:25:05

So I have this c/c++ codebase, around 116,000 lines of code. A full release compilation takes 6:25 minutes. Not too bad to work on.

If I break this down, a single line of c/c++ code takes 0.0033s (3.3 miliseconds). For comparison, a game that runs at 60 fps, draws a new frame in under 16 miliseconds. So while a game simulates and renders a frame, a c/c++ compiler compiles 5 lines of code. That is usually not even a single function.

My cpu avarages at around 10 instructions per clock cycle. At 3.6Ghz it can do 3.6 * 10 * 1,000,000,000 instructions on each core, per second. That's 36,000,000 per milisecond, on 8 cores.. but let's add some cache misses, any instructions can either go full speed 1x or go to main memory around 200x slower.

We are looking at around 5 million instructions per milisecond.

If we print out (9pt font) all instructions executed to compile a single line of c/c++ code, we'd end up with over 6 kilometer long paper.

Leonard Pauli 2024-08-10 16:29:12

I'm curious about gpu based compiling; eg. 100k lines at avg 80char/line = 8MB ≈ one 4k frame at single channel u8. Tokenizing this and astifying this may require a few passes, but still think this theoretically could be done multiple orders of magnitude faster... 400s to sub 400ms?

Jamie Brandon 2024-08-10 19:20:57

Gcc and clang are really not tuned for compile latency. Compare to eg home.in.tum.de/~engelke/pubs/2403-cgo.pdf or arxiv.org/pdf/2305.13241.

screenshot_2024-08-10_12-16-02.png

screenshot_2024-08-10_12-18-12.png

Jamie Brandon 2024-08-10 19:23:35

Computer graphics are also well suited to data-parallel hardware, which has several orders of magnitude better throughput than serial hardware.

Jamie Brandon 2024-08-10 19:30:18

A lot of basic tasks (eg representing changes to code during optimization) don't have good solutions yet.