Home > Software design >  LuaJIT and GCC: number of cores
LuaJIT and GCC: number of cores

Time:12-09

BACKGROUND: I read several articles about performance benchmarks between LuaJIT and C-language. There were different conclusions, so I tried to compare the speed of LuaJIT and C for my own use-case.

The function I tested used a large array of numerical values, and several mathematical formulas. It is a calculation-intensive part of a CAD-module that I'm making. Just loops and formulas.

I found that (in my test) LuaJIT indeed can outperform GCC (by 10 to 15%). (I used FFI-arrays, and -o3 optimization for gcc)

Which is a bit saddening... I liked the idea that for really fast programs, the old C-language was still the very best. It is a bit comforting that LuaJIT uses C-style arrays with FFI:-)

But it is also amazing... It was for many years 'common knowledge' that dynamic scripting languages would always be (much) slower than C. It is amazing that this astonishing LuaJIT-speed is not established by the power of a large corporation, but by the efforts of one man.

NUMBER OF CORES: During these benchmarking tests, I looked at the performance-tab in task-manager. Two cores showed high activity during the test, the two other cores remained at low activity. This was the case with LuaJIT, and also with GCC (with and without optimization) (I did the testing on a Win7 machine.)

THE QUESTION: Is it really so that the work is divided over two cores?

With LuaJIT, I could imagine that one process is working for the JITcompilation-part, and the other process for the actual calculations. Or maybe 'garbage collection' runs in a separate process? (I have no knowledge of garbage-collection)

But I see the same activity-profile when the C-program is running... Also without gcc-optimization there are two cores active. (But the program runs 3 times slower.)

Could it be that Windows is dividing the work over two cores?? I'm not looking for an in-dept technical explanation. I also have no interest in trying to get even more speed out of LuaJIT or C. The program is already more than fast enough.

I'm just curious if there are really two cores 'at work'. I prefer an answer in layman's-terms, if possible.

CodePudding user response:

It is amazing that this astonishing LuaJIT-speed is not established by the power of a large corporation, but by the efforts of one man.

"Fantastic Programmers and Where to Find Them" :-)

Could it be that Windows is dividing the work over two cores?

Yes, Windows swaps cores to reduce temperature difference inside CPU: a job for a single core is shared equally between two cores, only one core is active at a time.

  • Related