Making compilation faster&

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Making compilation faster&

Post by piranha »

I had an idea.
If you have a lot of code files, then why not start each 'gcc' command as a new process (by appending & to the end of the command)?
This may only work on a fast computer.
Problems:

1) The code files all need to be there when linking
Solution: When all commands are started, right before linking add a 'sleep 0.5' command which pauses for 1/2 second while the commands finish.

For me:
All my code files compiled in 4 seconds when doing one-at-a-time processing.
When each is a new process: 1.6 seconds. Thats a factor of 2.5! Much faster.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

C8H10N4O2 | #446691 | Trust the nodes.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

I'm officially stunned.. as is Alboin.

Are you serious? :roll:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
babernat
Member
Member
Posts: 42
Joined: Tue Jul 03, 2007 6:53 am
Location: Colorado USA

Post by babernat »

Wow...depending on the language this may or may not be possible. The most I've seen is a compiler starting up multiple threads for use only in the lexical and syntax analysis portion. The slowest part of compilation generally revolves around file i/o.
Thanks for all the fish.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

I'm officially stunned.. as is Alboin.

Are you serious? Rolling Eyes
What do you mean?

It works on my computer, and I like to not waste time.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

you could use a makefile with the -j option.

http://unixhelp.ed.ac.uk/CGI/man-cgi?make
-j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously. If
there is more than one -j option, the last one is effective. If
the -j option is given without an argument, make will not limit
the number of jobs that can run simultaneously.
The cake is a lie | rackbits.com
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

Well, then can you control what links when?

...And I had some fun with the make file for 5 min.

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
ucosty
Member
Member
Posts: 271
Joined: Tue Aug 08, 2006 7:43 am
Location: Sydney, Australia

Post by ucosty »

The dependencies system should take care of that.
The cake is a lie | rackbits.com
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post by piranha »

whatever, I was bored.
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
elfenix
Member
Member
Posts: 50
Joined: Sun Dec 02, 2007 1:24 pm
Libera.chat IRC: elfenix
Location: United States
Contact:

Post by elfenix »

Errr.....

Wondering why you aren't using make files... Or Visual Studio Projects.... Or Sconscripts....

See - 'make -j', "Enable Parallel Builds", 'scons -j'

:)

Edit: guess you were.... go back to your original Makefile and use,

make -j 4 (target) - if you have dual core or on single core

make -j 8 (target) - if you have more...

Further edit: not my day, I see this was already mentioned...
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Then depending on how hard core (tm) you are, you can use distcc and ccache to distribute builds across multiple machines (we dispatch 12 files at a time :) ) and cache the object files.
Post Reply