0
$\begingroup$

Is the speed of compiling software very dependent on the CPU? I know this question is a bit broad, but I'm to find an answer to the case described below.

If I download a software project that makes use of Node.js, TypeScript, and JavaScript and compile it running yarn it takes a certain duration on machine A and another duration on machine B. In my test case machine A is equipped with an Intel i5-4570 and machine B is equipped with an AMD Ryzen 5 1600x. Both have 16 GB RAM and both also have similar SSD drives in use.

Now, if I run the software compilation on both machines, machine A takes about 1:30min and machine B takes about 1:20min. Hence, machine B is not significantly faster, even though the CPUs are quite different in capability and get different scores according to CpuBenchmark:

The single core rating of both CPUs is quite similar at around 2000 Points, but when I run compilation all cores move up to 100% according to system power statistics.

I also checked the network usage, but doesn't move over 10kB/s and is therefore negligible. The RAM use fluctuates within about 1GB in both systems between 9GB and 10GB.

Now, as the expected results differ quite intensly to the reality, I obviously am missing a point. So, an experienced input of some of you guys would very much help.

Is there anything else I could measure? Is there anything I missed or maybe don't know and therefore should further test? I basically want to find out, why the Ryzen is not significantly faster than the Intel mentioned above.

$\endgroup$
  • 2
    $\begingroup$ Much compilation is lexical analysis (shuffling characters around, much branching), and then futzing around with large linked data structures (much data shuffling between CPU and memory or even disk). The "computation" part is rather limited. System performance just can't be summarized in some magical score, it is inherently multidimensional. And each type of task stresses different dimensions. $\endgroup$ – vonbrand Jul 11 '18 at 13:20
  • 1
    $\begingroup$ @vonbrand: Especially in this case, where there is no code generation and only a limited amount of optimization. TypeScript is so semantically close to its target language ECMAScript, that compilation is essentially just type checking and then erasing all types. "Minification" is just parsing, ɑ-renaming, and unparsing. There are no expensive whole-program optimizations with massive flow-graphs here. It's mostly text processing. $\endgroup$ – Jörg W Mittag Jul 12 '18 at 23:44
2
$\begingroup$

Things you are missing is

  • RAM performance: Intel CPUs has lower memory latency, and compilation speed significantly depends on memory latencies
  • Amount of cores/threads: each Ryzen core is slightly slower than Intel core, but it has 1.5x more cores, and each core can run 2 threads. This makes it 1.5x faster for ideal multi-threaded tasks (like benchmarks), but real programs may be not ideally scale from 4 to 12 threads
  • SSD speed, in particular 4K IOPS (i.e. speed of reading many small files)

F.e. first test on this page compares C++ compile times on various Intel/AMD CPUs:

  • 8700K: Intel 6-core
  • 7820X: Intel 8-core with slower memory controller
  • 2700X: AMD 8-core
  • 2600X: AMD 6-core

As you can see, Intel 6 cores outperformed AMD 8 cores and even Intel's own 8 cores coupled with slower memory controller.

And this page discusses a lot memory/cache latencies.

$\endgroup$
  • $\begingroup$ Thanks for your input. Do you know any good software for testing RAM latency? Preferably for Linux. Otherwise I'd just build a Java app that adds and removes entries to a List object and measures the time spent. Same for SSD speed check. Basically make the difference in one big file (i.e. +10GB) vs. many (i.e. 10.000.000) small files (i.e. 1KB), right? $\endgroup$ – Socrates Jul 11 '18 at 12:52
  • 1
    $\begingroup$ @Socrates Home-grown approaches for benchmarking hardware are scary. You can read some overviews of CPUs and SSDs which usually include benchmarks, f.e. on Anandtech site. For benchmarking software, I know more about Windows ones - CPU-Z and AS SSD. I heard about FIO for Linux, but afair it's quite complex. You better ask Linux gurus. $\endgroup$ – Bulat Jul 11 '18 at 12:57
  • 1
    $\begingroup$ @Socrates Sorry, it's AIDA64 rather than CPU-Z. AIDA64 shows screens like that: aida64.com/sites/default/files/shot6_cachemem_ryzen_0.png . I also added more info to the answer, see above. $\endgroup$ – Bulat Jul 11 '18 at 13:20
  • 1
    $\begingroup$ @Socrates measure compilation speed for a collection of programs of different characteristics if that is what you are interested in. General benchmarks try to approximate some real-world uses, microbenchmarks measure a specific dimension that you'd have to combine with others to come up with a meaningful number. $\endgroup$ – vonbrand Jul 11 '18 at 13:52
0
$\begingroup$

A major factor is how many threads the build system can use. Some code that I fortunately don't have to build too often uses a single threaded build system - so you could have a machine with sixteen cores of which 15 are doing nothing.

One effect I had once was using a machine with not enough RAM. Eight threads tried to compile simultaneously, running out of RAM and thrashing virtual memory. Restricting the compiler to four threads ran faster.

What makes much more difference than the CPU is making sure you use the compiler at its best. I have seen using pre-compiled header files reduce compile time to a quarter.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.