Recent

Author Topic: slow compilation, now and then  (Read 2434 times)

hakelm

  • Full Member
  • ***
  • Posts: 153
slow compilation, now and then
« on: February 19, 2019, 04:41:48 pm »
Sometimes I experience very slow compilation with FPC or Lazarus. Testing with a little hello world-program

program Project1;
begin
  writeln('hello');
end.

I may get compilation times 10 seconds or more, see below.
This behaviour disappears if I restart the system and compilation takes more reasonable 0.04 s.
What can be the reason for this and how can I avoid it without rebooting?
My system is Ubuntu 16.04 running on an Intel® Core™ i7-4790 CPU @ 3.60GHz × 8 with 16 GB of ram.
Håkan

Before reboot:

root@nilx:~/tmp# time fpc project1.lpr
Free Pascal Compiler version 3.0.4 [2017/10/03] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling project1.lpr
Linking project1
/usr/bin/ld: varning: link.res innehåller utdatasektioner; glömde du -T?
7 lines compiled, 10.0 sec

real   0m10.038s
user   0m0.028s
sys   0m0.004s
root@nilx:~/tmp#

After reboot:

root@nilx:~/tmp# time fpc project1.lpr
Free Pascal Compiler version 3.0.4 [2017/10/03] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling project1.lpr
Linking project1
/usr/bin/ld: varning: link.res innehåller utdatasektioner; glömde du -T?
5 lines compiled, 0.0 sec

real   0m0.037s
user   0m0.036s
sys   0m0.000s



Thaddy

  • Hero Member
  • *****
  • Posts: 14214
  • Probably until I exterminate Putin.
Re: slow compilation, now and then
« Reply #1 on: February 19, 2019, 05:06:00 pm »
It seems that the first run came from a swap file or partition. So you seem to have memory pressure (from other running applications?).
Specialize a type, not a var.

hakelm

  • Full Member
  • ***
  • Posts: 153
Re: slow compilation, now and then
« Reply #2 on: February 19, 2019, 05:44:56 pm »
Thanks.
You are probably right but I don't know. All "visible" applications where closed when I did the test. Next time it happens, I will check system status and be back with a report.
H

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: slow compilation, now and then
« Reply #3 on: February 19, 2019, 07:21:25 pm »
At which stage is the time spent? If you watch the output, before or after "Linking project1"?

Watch the processes in top too. Who is eating cpu? ppc..., ld, some other? Or is the cpu usage low? (then it may be memory, but it could also be other I/O ops)


hakelm

  • Full Member
  • ***
  • Posts: 153
Re: slow compilation, now and then
« Reply #4 on: February 19, 2019, 08:18:14 pm »
In both cases all output comes in one fast go.
H

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: slow compilation, now and then
« Reply #5 on: February 19, 2019, 08:22:49 pm »
Are you compiling on, or, having the starting compiler on a FUSE filesystem like NTFS?

hakelm

  • Full Member
  • ***
  • Posts: 153
Re: slow compilation, now and then
« Reply #6 on: February 19, 2019, 08:33:10 pm »
The source at /root/tmp/project1.lpr sits on an ext4, the same as the /usr/bin/ppcx64.
H

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: slow compilation, now and then
« Reply #7 on: February 19, 2019, 10:46:28 pm »
In both cases all output comes in one fast go.

That is odd.

Afaik the "Free Pascal Compiler version 3.0.4 [2017/10/03] for x86_64 / Copyright (c) 1993-2017 by Florian Klaempfl and others" gets printed even before compilation starts.

This would either mean, that your OS takes 10 seconds to load the compiler, or that the output is buffered somewhere (if so, what kind of terminal?). You should know the difference by watching top, and seeing which programs are running at which time.

Also - but I am not sure about that interpretation - in the 10 sec version, both user and sys time are low. So my understanding is, that nothing used the cpu, and there indeed is some other hold up.

hakelm

  • Full Member
  • ***
  • Posts: 153
Re: slow compilation, now and then
« Reply #8 on: February 20, 2019, 10:39:50 am »
I am not certain about the header:

Free Pascal Compiler version 3.0.4 [2017/10/03] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others

It may very well be that it was shown promptly. The rest of the output, however, came in one go. Sorry about that.
This problem has plagued me on and off for some time, but now I know that rebooting helps.
I will be a bit more observant next time and report back then.
Thanks for your help.
H

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: slow compilation, now and then
« Reply #9 on: February 20, 2019, 10:51:39 am »
If it were Windows instead of Linux, I'd say overactive antivirus. But now? No idea whatsoever.

 

TinyPortal © 2005-2018