www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What is the size of a module?

reply Frank Benoit <keinfarbton googlemail.com> writes:
I want to get an understanding what can make DWT executables smaller and 
if the modules count is really relevant for it.

So the question... A given amount of classes/interfaces etc exist. Now a 
design decision should be made how this code shall be structured into 
modules and packages.

What exactly are the costs for moving code into a new module?
What does affect the resulting binary size?
  - length of typenames
  - count of import that the new module has
  - count of modules that import the new module
  - static this entry in the module
  - ?
May 18 2008
next sibling parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Frank Benoit wrote:
 I want to get an understanding what can make DWT executables smaller and 
 if the modules count is really relevant for it.
 
 So the question... A given amount of classes/interfaces etc exist. Now a 
 design decision should be made how this code shall be structured into 
 modules and packages.
 
 What exactly are the costs for moving code into a new module?
 What does affect the resulting binary size?
  - length of typenames
  - count of import that the new module has
  - count of modules that import the new module
  - static this entry in the module
  - ?
I would say trying to use the new -lib flag in DMD 1.030 is probably the first step now. Walter said it made smaller exes and improved linking times in his tests: """ This accelerates library builds by a whopping factor of 3! ... The library build option has another major coolness feature - [...] one source file can compile to multiple object files. This cuts down on executable bloat from pulling in object files with irrelevant stuff in them. """ But maybe bug 2067 prevents you from going forward with such tests right now? Also I'm not sure how much support will be needed from build tools. Sounds like "dsss build -lib" on dwt should do it, since dsss just passes through any unknown flags to dmd eventually. But maybe something more is needed. I guess you'll definitely need to have oneatatime=no in the dsss/rebuild configs for that to work. But I believe that is your standard practice anyway. --bb
May 18 2008
prev sibling parent reply Neal Alexander <WQEQWEUQY HOTMAIL.COM> writes:
Frank Benoit wrote:
 I want to get an understanding what can make DWT executables smaller and 
 if the modules count is really relevant for it.
 
 So the question... A given amount of classes/interfaces etc exist. Now a 
 design decision should be made how this code shall be structured into 
 modules and packages.
 
 What exactly are the costs for moving code into a new module?
 What does affect the resulting binary size?
  - length of typenames
  - count of import that the new module has
  - count of modules that import the new module
  - static this entry in the module
  - ?
 
An empty module is like 500 bytes IIRC. When porting large C headers to D, the biggest factor is the generation of default initializers for the structs i think.
May 18 2008
parent Tomas Lindquist Olsen <tomas famolsen.dk> writes:
Neal Alexander wrote:
 Frank Benoit wrote:
 I want to get an understanding what can make DWT executables smaller 
 and if the modules count is really relevant for it.

 So the question... A given amount of classes/interfaces etc exist. Now 
 a design decision should be made how this code shall be structured 
 into modules and packages.

 What exactly are the costs for moving code into a new module?
 What does affect the resulting binary size?
  - length of typenames
  - count of import that the new module has
  - count of modules that import the new module
  - static this entry in the module
  - ?
An empty module is like 500 bytes IIRC. When porting large C headers to D, the biggest factor is the generation of default initializers for the structs i think.
As well as their typeinfo.
May 26 2008