FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compiler Optimization

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
Xerpher



Joined: 09 May 2004
Posts: 13

PostPosted: Sun May 09, 2004 9:49 pm    Post subject: Compiler Optimization Reply with quote

I'm using the DMD compiler but am used to the Visual Studio easy-bake-oven. I made an extremely tiny test program that compiled to 64kb.

I know I have to tell the compiler to optimize or remopve certain things, etc, but I have no clue what.

Any and all help is much appreciated.
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sun May 09, 2004 10:54 pm    Post subject: Executable size Reply with quote

Actually, it sounds like you could be doing everything right. DMD doesn't create executables quite as small as C compilers can. If you want some compile-line option to play around with you could try "-release" (compile release version), "-O" (optimize), and "-inline" (do function inlining). All of the options are revealed by typing "dmd" in the console window.

Walter says, "In general, a D executable will be the same size as a C++ one plus about 40k for the garbage collector code. However, as Ilya pointed out, D code should grow slower than C++ code." (There's been a whole long thread on executable size in the digitalmars.D newsgroup.)

Ideas have been tossed around at trying to remove a few KB's, but I don't know that the executable size really creates any problems for anyone. I don't like bloat, but we're only talking about a few KB's, not a 10 MB framework.
Back to top
View user's profile Send private message AIM Address
Xerpher



Joined: 09 May 2004
Posts: 13

PostPosted: Mon May 10, 2004 2:49 pm    Post subject: Re: Executable size Reply with quote

jcc7 wrote:
Ideas have been tossed around at trying to remove a few KB's, but I don't know that the executable size really creates any problems for anyone. I don't like bloat, but we're only talking about a few KB's, not a 10 MB framework.

Well I was just a tad concerned that four small lines of code took ~64kb.

jcc7 wrote:
Actually, it sounds like you could be doing everything right. DMD doesn't create executables quite as small as C compilers can. If you want some compile-line option to play around with you could try "-release" (compile release version), "-O" (optimize), and "-inline" (do function inlining). All of the options are revealed by typing "dmd" in the console window.

Thanks, I'll try those.

[edit]
Well I just tried both of those and it grew 3kb! Don't really see any other compiler options that might help either... oh well, that garbage collector sure takes alot =P

As for the garbage collector, I saw that you can disable and nable it on the fly, but is it possible to strip it out of the code altogether? (Not that I want to, just wondering)
[/edit]
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Mon May 10, 2004 5:07 pm    Post subject: Optimizations/Executable Size Reply with quote

Now that I think about it "-inline" is probably intended to be a runtime speed optimization rather than a size optimization...

As far as removing the garbage collector, people have suggested converting it to a .dll (I'm not sure that'd improve anything -- you'd still need to distribute the .dll) or creating a minimalist version of a GC that doesn't do anything (that should improve the executable size and startup speed).

If the GC is removed without making allowances, I think the executable would be unstable (random access violations would probably occur).
Back to top
View user's profile Send private message AIM Address
Xerpher



Joined: 09 May 2004
Posts: 13

PostPosted: Mon May 10, 2004 5:15 pm    Post subject: Re: Optimizations/Executable Size Reply with quote

jcc7 wrote:
Now that I think about it "-inline" is probably intended to be a runtime speed optimization rather than a size optimization...

Yea, I didn't use that one, just the other two Smile

jcc7 wrote:
If the GC is removed without making allowances, I think the executable would be unstable (random access violations would probably occur).

Alrighty. I really don't mind as long as its just adding that little chunk (~40kb), as long as D doesn't compile huge apps I'm fine Very Happy
Back to top
View user's profile Send private message
Hohums



Joined: 08 Apr 2004
Posts: 71
Location: Western Australia

PostPosted: Mon May 10, 2004 10:02 pm    Post subject: Re: Optimizations/Executable Size Reply with quote

Xerpher wrote:
jcc7 wrote:
Now that I think about it "-inline" is probably intended to be a runtime speed optimization rather than a size optimization...

Yea, I didn't use that one, just the other two Smile

jcc7 wrote:
If the GC is removed without making allowances, I think the executable would be unstable (random access violations would probably occur).

Alrighty. I really don't mind as long as its just adding that little chunk (~40kb), as long as D doesn't compile huge apps I'm fine Very Happy


Just thank your lucky stars that your not programming in VB.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Xerpher



Joined: 09 May 2004
Posts: 13

PostPosted: Tue May 11, 2004 9:29 am    Post subject: Re: Optimizations/Executable Size Reply with quote

Hohums wrote:
Xerpher wrote:
jcc7 wrote:
Now that I think about it "-inline" is probably intended to be a runtime speed optimization rather than a size optimization...

Yea, I didn't use that one, just the other two Smile

jcc7 wrote:
If the GC is removed without making allowances, I think the executable would be unstable (random access violations would probably occur).

Alrighty. I really don't mind as long as its just adding that little chunk (~40kb), as long as D doesn't compile huge apps I'm fine Very Happy


Just thank your lucky stars that your not programming in VB.


Haha, yea, that was the first language I started learning thanks to it being the only language available at my high-school. It's not horrible but it is when compared to any other language Razz
Back to top
View user's profile Send private message
kinghajj



Joined: 13 Jul 2004
Posts: 3

PostPosted: Tue Jul 13, 2004 8:54 pm    Post subject: Reply with quote

I use "strip" to take out the unneeded crap from the executables, then "upx" to compress them. I got a 120k program down to a nice 36k Very Happy
Back to top
View user's profile Send private message
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Wed Jul 14, 2004 12:36 am    Post subject: Re: Optimizations/Executable Size Reply with quote

jcc7 wrote:
As far as removing the garbage collector, people have suggested converting it to a .dll (I'm not sure that'd improve anything -- you'd still need to distribute the .dll) or creating a minimalist version of a GC that doesn't do anything (that should improve the executable size and startup speed).


Actually it would be really nice if modern operating systems had an integrated standard gc accessible from languages like d. That way d would not have to supply the gc; this would have the desired shrinking effect on all the d programs. The OS based gc would act much like a dll in that it would be a resource that all running applications could use. Disabling/enabling would be simple from the d programs perspective because it would just be deciding when it wanted to use the gc or not, rather than actually turning the gc off and on for the whole system.

That should be the future of OS development I think....
Back to top
View user's profile Send private message
Blandger



Joined: 21 May 2004
Posts: 50
Location: Ukraine, Kharkov

PostPosted: Wed Jul 14, 2004 1:28 am    Post subject: Re: Optimizations/Executable Size Reply with quote

JJR wrote:
Actually it would be really nice if modern operating systems had an integrated standard gc accessible from languages like d.

Sure!

Quote:
Disabling/enabling would be simple from the d programs perspective because it would just be deciding when it wanted to use the gc or not, rather than actually turning the gc off and on for the whole system.

Definitely it's a right way moving on further in the software development.

Quote:
That should be the future of OS development I think....

I hope using D. Smile
_________________
Regards, Yuriy
Back to top
View user's profile Send private message
Hohums



Joined: 08 Apr 2004
Posts: 71
Location: Western Australia

PostPosted: Wed Jul 14, 2004 6:35 am    Post subject: Re: Optimizations/Executable Size Reply with quote

JJR wrote:


Actually it would be really nice if modern operating systems had an integrated standard gc accessible from languages like d. That way d would not have to supply the gc; this would have the desired shrinking effect on all the d programs. The OS based gc would act much like a dll in that it would be a resource that all running applications could use. Disabling/enabling would be simple from the d programs perspective because it would just be deciding when it wanted to use the gc or not, rather than actually turning the gc off and on for the whole system.

That should be the future of OS development I think....


I think this is the line of thought used in net. Longbow is going managed (to some extent) so I'd have it a guess that the gc will be basicly part of the OS, although it may not be accessable from non-net apps.
_________________
http://badmama.com.au/~anderson/
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Wed Jul 14, 2004 12:20 pm    Post subject: Re: Optimizations/Executable Size Reply with quote

Hohums wrote:
I think this is the line of thought used in net. Longbow is going managed (to some extent) so I'd have it a guess that the gc will be basicly part of the OS, although it may not be accessable from non-net apps.


True, .net does offer the gc concept as part of the system, but that appears to be just one feature of it (ie you don't get the gc unless you adopt all of it). If I recall correctly, managed code doesn't allow the use of pointers nor does it appear to be condusive to small executables or high performance. While .net's features are probably useful for security and exception control, I'd still like to see an OS that offers a gc as a basic feature.
Back to top
View user's profile Send private message
Hohums



Joined: 08 Apr 2004
Posts: 71
Location: Western Australia

PostPosted: Thu Jul 15, 2004 6:42 am    Post subject: Re: Optimizations/Executable Size Reply with quote

JJR wrote:
If I recall correctly, managed code doesn't allow the use of pointers nor does it appear to be condusive to small executables or high performance.


Actually managed code can have pointers. There is a special pragma that you can call to enable *unsafe* code.


JJR wrote:
While .net's features are probably useful for security and exception control, I'd still like to see an OS that offers a gc as a basic feature.


Agreed.
_________________
http://badmama.com.au/~anderson/
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Zweistein



Joined: 21 Mar 2007
Posts: 19

PostPosted: Mon Dec 17, 2007 9:34 am    Post subject: Reply with quote

The filesize is important for Graphics demos per example:

Look at that:
http://www.pouet.net/download.php?which=30244

The whole Demo ist just ~170 kb. Amazing!

bye
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group