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.
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?
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.
Computer graphics are also well suited to data-parallel hardware, which has several orders of magnitude better throughput than serial hardware.
There's been some work on compiling on gpus (eg onedrive.live.com/?authkey=%21AN3eH7D93Q8%2Dxzs&cid=0CFFDB1C3A2F95F6&id=CFFDB1C3A2F95F6%21702303&parId=CFFDB1C3A2F95F6%21184476&o=OneUp) but it's very basic.
A lot of basic tasks (eg representing changes to code during optimization) don't have good solutions yet.