Remix.run Logo
jstimpfle 3 days ago

That may be true for extremely simple source code, but it's almost too good to be true. Your number sounded so impressive that I tried with gcc (12.2) on my Linux VM. With -O0, it takes around 27s, with -O2 it's 1m07s.

With -E (only preprocess) we are at around 0.320s for the 260K lines of sqlite3.c. Which makes sense, 1M lines/s for the preprocessor and maybe also the AST should be doable (that may be where you got your 60MB/s number from). But compiling is something else.

MSVC may be faster here or not, I haven't tested it.

A more modern machine (mine is a i5-7600K from 2018) may be 2x or more faster, and running on multiple threads will speed up the build as well.

CyberDildonics 3 days ago | parent | next [-]

(that may be where you got your 60MB/s number from)

It's not that. I think I messed up and the 0.1 seconds was tcc and msvc was 1 or 2 seconds. Nothing was 27 seconds. Try tcc, even though you are in a VM it should be very fast as a baseline for what's possible.

The point is that some people talk about single header files being slow are really saying "what if". C is incredibly fast to compile and the slow parts are the overhead from each compilation unit and the optimizers.

287 KB of source code added to a compilation unit is nothing in the modern era. Not only that, but you can just choose to put a lot of them in the same compilation unit and not touch it again.

Every time I've used single file header libraries it makes things simple and fast. I'm not going to change them so dumping them all into a single compilation unit is fine.

mandarax8 3 days ago | parent | prev [-]

What exactly did you try to compile and how?

  $ time gcc -x c  -c RGFW.h -D RGFW_IMPLEMENTATION -fPIC -D RGFW_EXPORT
  0.42s user 0.03s system 93% cpu 0.485 total
jstimpfle 3 days ago | parent [-]

sqlite3, if you read carefully again.