View previous topic :: View next topic |
Author |
Message |
Xerpher
Joined: 09 May 2004 Posts: 13
|
Posted: Sun May 09, 2004 9:49 pm Post subject: Compiler Optimization |
|
|
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 |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Sun May 09, 2004 10:54 pm Post subject: Executable size |
|
|
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 |
|
|
Xerpher
Joined: 09 May 2004 Posts: 13
|
Posted: Mon May 10, 2004 2:49 pm Post subject: Re: Executable size |
|
|
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 |
|
|
jcc7
Joined: 22 Feb 2004 Posts: 657 Location: Muskogee, OK, USA
|
Posted: Mon May 10, 2004 5:07 pm Post subject: Optimizations/Executable Size |
|
|
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 |
|
|
Xerpher
Joined: 09 May 2004 Posts: 13
|
Posted: Mon May 10, 2004 5:15 pm Post subject: Re: Optimizations/Executable Size |
|
|
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
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 |
|
Back to top |
|
|
Hohums
Joined: 08 Apr 2004 Posts: 71 Location: Western Australia
|
Posted: Mon May 10, 2004 10:02 pm Post subject: Re: Optimizations/Executable Size |
|
|
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
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 |
Just thank your lucky stars that your not programming in VB. |
|
Back to top |
|
|
Xerpher
Joined: 09 May 2004 Posts: 13
|
Posted: Tue May 11, 2004 9:29 am Post subject: Re: Optimizations/Executable Size |
|
|
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
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 |
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 |
|
Back to top |
|
|
kinghajj
Joined: 13 Jul 2004 Posts: 3
|
Posted: Tue Jul 13, 2004 8:54 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Wed Jul 14, 2004 12:36 am Post subject: Re: Optimizations/Executable Size |
|
|
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 |
|
|
Blandger
Joined: 21 May 2004 Posts: 50 Location: Ukraine, Kharkov
|
Posted: Wed Jul 14, 2004 1:28 am Post subject: Re: Optimizations/Executable Size |
|
|
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. _________________ Regards, Yuriy |
|
Back to top |
|
|
Hohums
Joined: 08 Apr 2004 Posts: 71 Location: Western Australia
|
Posted: Wed Jul 14, 2004 6:35 am Post subject: Re: Optimizations/Executable Size |
|
|
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 |
|
|
JJR
Joined: 22 Feb 2004 Posts: 1104
|
Posted: Wed Jul 14, 2004 12:20 pm Post subject: Re: Optimizations/Executable Size |
|
|
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 |
|
|
Hohums
Joined: 08 Apr 2004 Posts: 71 Location: Western Australia
|
Posted: Thu Jul 15, 2004 6:42 am Post subject: Re: Optimizations/Executable Size |
|
|
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 |
|
|
Zweistein
Joined: 21 Mar 2007 Posts: 19
|
|
Back to top |
|
|
|