Recent

Author Topic: Speeding up compilation  (Read 19672 times)

Arbiter

  • Guest
Speeding up compilation
« on: April 12, 2005, 03:34:01 pm »
Yo all,
i want to speed up the compilation time. I think that linking is the step that slow compilation. I'm on windows os and i've compared times needed by delphi and lazarus + freepascal.

Application with a button and a form:
Lazarus ~ 5.5 secs
Delphi ~ 1 sec

Machine is Athlon XP 2600+, 512 Megs of Ram, 40 Gb of HD space. Is there a system to reduce compilation time? (As said before, i think thats only a ptoblem by the linker)

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Speeding up compilation
« Reply #1 on: April 13, 2005, 09:44:55 am »
No. There is no such thing yet.

Compilation speed would be increased by using an internal linker instead of calling the external linker ld. Writing an internal linker is not a small thing, but it is one the features the fpc team wants to add in the future. Especially on windows ld is very slow.

dotniet

  • New Member
  • *
  • Posts: 46
Re: Speeding up compilation
« Reply #2 on: October 14, 2009, 03:50:53 pm »
2009 and Lazarus is still taking few seconds to compile and run a simple GUI application.
Any news/updates about how to improve the speed of compilation.
Can I desable/enable stuff in 'Compiler options' to make it more productive?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8262
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Speeding up compilation
« Reply #3 on: October 14, 2009, 04:04:59 pm »
On first run, it may be a little slow because of unit loading (an empty form uses quite a lot of). But subsequent calls should execute no more than a second (well, at least for a form with a button).

It also depends on your computer spec, a quite recent one (one-two years behind) should behave as I state above.
Quote
Can I desable/enable stuff in 'Compiler options' to make it more productive?
I don't think so. It will even run slower (but still toleratable) if you enable smartlinking and optimizations (in this case, FPC is much more advanced than Delphi).

BlueIcaro

  • Hero Member
  • *****
  • Posts: 594
Re: Speeding up compilation
« Reply #4 on: October 14, 2009, 08:41:06 pm »
Hello, Lazarus it's a very little slow than Delphi. But It's not very slow. I made a test in Lazarus. I put a button on a empty form. The first time it's take a few seconds as Lellodumbo said. But after first compile, lazarus compile very fast. I put on click buttons' event the following:
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  close;
end; 
After that I compiled, and it's takes less 1 second.

So, for me the time that lazarus needs the first time it's not important. In other way I use lazarus for programing at home, as hobbie. For me it's neat, beacuse I can make my own programs very easy.

/BlueIcaro
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

dotniet

  • New Member
  • *
  • Posts: 46
Re: Speeding up compilation
« Reply #5 on: October 16, 2009, 10:49:31 am »
The program that I try to compile is the TProcess example from Lazarus web site.
It has something like 10-12 controls and about 30 lines of code. I still consider this a pretty much empty project. But it takes MINIMUM over five seconds every time I push the F9 button (and the program is to be recompiled because I changed some code).

PS: I disabled that function that says something like "force build (even if nothing was changed)". But zero improvments.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8262
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Speeding up compilation
« Reply #6 on: October 19, 2009, 07:46:49 am »
I've tested that project here and it compiles in a second. What's your computer spec?

dotniet

  • New Member
  • *
  • Posts: 46
Re: Speeding up compilation
« Reply #7 on: October 21, 2009, 04:30:06 pm »
I am working via a SunRay box on a server of 16 AMD Opteron processors.
Each CPU is 2.2GHz and has 4 cores.
Total ammount of RAM is 64GB.

At this hour I should all server for myself - the rest of the people are gone home.
My project grew at about 150 lines of code and a lot of controls it is terrible slow.

Which compiler option will slowdown the compiler most? I will check if I have that option disabled.

I really need some help with this.

----------------------------------------

processor       : 15
vendor_id       : AuthenticAMD
cpu family      : 16
model           : 2
model name      : Quad-Core AMD Opteron(tm) Processor 8354
stepping        : 3
cpu MHz         : 2200.000
cache size      : 512 KB
physical id     : 4
siblings        : 4
core id         : 3
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov                        pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp                        lm 3dnowext 3dnow constant_tsc rep_good pni cx16 popcnt lahf_lm cmp_legacy svm                        extapic cr8_legacy altmovcr8 abm sse4a misalignsse 3dnowprefetch osvw
bogomips        : 4420.80
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 48 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2512
Re: Speeding up compilation
« Reply #8 on: October 21, 2009, 04:37:47 pm »
The compiler uses only one thread, so having multiple CPUs don't speed up compilation. Besides it's probably not the compiler, but the linker or the debugger. And thats one process too.
Further, depending on the OS, spawing an external process like the compiler ot the debugger takes time too.
So if it takes 5sec after pressing F9, you have the compiler time (less than a second), the linker time (1-2secs) and the debugger (3-4 secs) loading time.
Loading of all LCL symbols (always present even if you have a one button app) takes probably the most time.
« Last Edit: October 21, 2009, 04:41:49 pm by Marc »
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

dotniet

  • New Member
  • *
  • Posts: 46
Re: Speeding up compilation
« Reply #9 on: October 21, 2009, 07:11:46 pm »
After pressing F9 it says 'Compiling...' for about 9 seconds then the form instantly appears on the screen (the application is running). I have no debugger defined.

Anyway, on Windows the compilation is really really fast.
« Last Edit: October 21, 2009, 07:16:19 pm by dotniet »

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Speeding up compilation
« Reply #10 on: October 21, 2009, 09:16:40 pm »
disable generating debug info (so, no -gl either).

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6591
    • wiki
Re: Speeding up compilation
« Reply #11 on: October 21, 2009, 10:14:39 pm »
Maybe also disable "link smart" / "smart linkable"

I remember I has a case (of a rather large app) where smartlinking on some systems would take really long (time for more than one coffee)

probably just need to switch off -XX (Link smart)
I don't think that -CX (Smart Linkable) will matter match

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: Speeding up compilation
« Reply #12 on: October 21, 2009, 10:17:49 pm »
I think it matters, if you enable -CX, .a are generated.

dotniet

  • New Member
  • *
  • Posts: 46
Re: Speeding up compilation
« Reply #13 on: October 22, 2009, 09:37:30 am »
Smart linkable - on/off is about the same. The results are not very consistent but are in the range of 6-8 seconds. Sometimes when this option is ON takes longer than other times when the option is OFF, and the other way arround.

Strip symbols from exe - also doesnt improove the speed

Generate debugging info - was already disabled.

Link smart - this was the only one that dropped the compilation time with about 1-1.5 seconds

So the compile time is now 5+ seconds.

Inspecting the code (9 very simple procedures) is slow. It needs one second before displaying any messages at all (hints) in the Messages box.
After that, the Messages box shows that most of the time is spent in linking - about 2.5-3 seconds.
I still need to cut down 2-3 seconds.
.
« Last Edit: October 22, 2009, 10:41:35 am by dotniet »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8262
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Speeding up compilation
« Reply #14 on: October 22, 2009, 01:55:24 pm »
OK, so you're on Linux (you should've mention it earlier). On platforms other than Windows, FPC relies on GNU linker for linking (I don't know how's the progress of ELF internal linker).

Smartlinking is indeed time and memory consuming on these platforms because when enabled, FPC creates a small assembly for for EACH variables and routines, which is zipped in a .a file. This is done because GNU linker can only remove unused files, while the term smartlinking in FPC means remove everything that's not used.

Create smartlinkable units (-CX): only affect compiling process, so the difference won't be big.

Link smart (-XX): Heavy step, GNU linker might need to load hundreds to thousands or even more object files to memory. This what's make the difference big.

Quote
I still need to cut down 2-3 seconds
Disable both -CX and -XX, recompile LCL (and RTL + FCL) if you've built them with smartlinking on.

 

TinyPortal © 2005-2018