Author Topic: Nasm Speed  (Read 13877 times)

Offline sal55

  • Jr. Member
  • *
  • Posts: 18
Nasm Speed
« on: April 28, 2017, 07:42:09 PM »
I noticed recently that Nasm slows down considerably as input gets above a certain size.

It was only a problem on special test files, not on normal input. But now I have a real program and the time to assemble it is becoming a nuisance. So I'm reporting it as a problem.

Nasm is used to assemble the output of a C compiler. It takes the compiler about 0.1 seconds to turn 20K lines of C, into 80K lines of ASM. It has taken Nasm 40 or 25 seconds to process those lines (25 seconds using -O0 to minimise passes).

The latest version version takes 33/20 seconds. A welcome reduction, but still, IMO, far too long for the task, and still an annoyance. That test file is here:

https://github.com/bartg/langs/blob/master/test.asm

(click in View Raw to see the text then perhaps copy and paste. It's 80,000 lines and 1.3MB).

I ran Nasm on an Intel 3.2GHz 64-bit machine with 4GB, using:

  nasm -fwin64 test.asm

Nasm does the job but it just takes a magnitude or two longer than you might expect!

Offline akasei

  • Jr. Member
  • *
  • Posts: 8
Re: Nasm Speed
« Reply #1 on: May 03, 2017, 09:10:23 PM »
Not to much, but all code written by myself. Once i had about 20k lines, and always it was in less than 1s. AMD Phenom X4 965, nasm

Code: [Select]
bash-4.3# for i in `find . | grep asm`; do cat $i; done | wc -l
6594
bash-4.3# time make
nasm -f bin kernel.asm  -o build/kernel

real    0m0.096s
user    0m0.085s
sys     0m0.010s
bash-4.3# nasm -v
NASM version 2.12.01 compiled on Apr  5 2016

Offline sal55

  • Jr. Member
  • *
  • Posts: 18
Re: Nasm Speed
« Reply #2 on: May 07, 2017, 12:54:38 PM »
Not to much, but all code written by myself. Once i had about 20k lines, and always it was in less than 1s. AMD Phenom X4 965, nasm

I run Nasm on Windows; would that be an unintentionally crippled version compared to Linux?

If create test files of the same few lines repeated thousands of times, then I can also get timings of 0.5 seconds for 20K lines, or 2 seconds for 80K lines. (Not particulary fast compared to my own tools, but usable.) But, 80K lines' of real code was much slower (at least 20 seconds with -O0). Maybe something is triggering the problem (symbol table issues? I've no idea how Nasm works internally), but I don't have time to investigate.

So for now, I'm avoiding using it; I'm going to try and generate my own native code directly, and only use Nasm when a regular object or executable file is needed.

Offline alexfru

  • Jr. Member
  • *
  • Posts: 17
Re: Nasm Speed
« Reply #3 on: August 12, 2017, 08:40:02 AM »
I noticed recently that Nasm slows down considerably as input gets above a certain size.

It was only a problem on special test files, not on normal input. But now I have a real program and the time to assemble it is becoming a nuisance. So I'm reporting it as a problem.

Nasm is used to assemble the output of a C compiler. It takes the compiler about 0.1 seconds to turn 20K lines of C, into 80K lines of ASM. It has taken Nasm 40 or 25 seconds to process those lines (25 seconds using -O0 to minimise passes).

The latest version version takes 33/20 seconds. A welcome reduction, but still, IMO, far too long for the task, and still an annoyance. That test file is here:

https://github.com/bartg/langs/blob/master/test.asm

(click in View Raw to see the text then perhaps copy and paste. It's 80,000 lines and 1.3MB).

I ran Nasm on an Intel 3.2GHz 64-bit machine with 4GB, using:

  nasm -fwin64 test.asm

Nasm does the job but it just takes a magnitude or two longer than you might expect!

My guess is that NASM is slow at optimizing jumps (choosing the shortest optiion) when there are a bit too many of them.
Try YASM. It's faster.