www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Decrease DMD memory usage

reply Marek Janukowicz <marek janukowicz.net> writes:
How can I decrease DMD memory usage? My program does now use about 3.5GB 
during compilation, which is horrible, as even machines with 4GB RAM 
sometimes fail to compile successfully :(

-- 
Marek Janukowicz
Aug 28 2013
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 8/28/2013 11:53 PM, Marek Janukowicz wrote:
 How can I decrease DMD memory usage? My program does now use about 3.5GB
 during compilation, which is horrible, as even machines with 4GB RAM
 sometimes fail to compile successfully :(
1. Switch to separately compiling each module, rather than lumping them all on one command line to dmd. 2. Use the 64 bit dmd build. That won't use less memory, but it handles more memory better, if that makes sense.
Aug 29 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
Hi, Walter.

Where i can get 64 bit dmd for windows that produces 32 bit 
executables ?
Aug 29 2013
next sibling parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 29 August 2013 11:09, Temtaime <temtaime gmail.com> wrote:
 Hi, Walter.

 Where i can get 64 bit dmd for windows that produces 32 bit executables ?
The binaries distributed should already be capable of doing that. Just use the -m32 switch. Whether or not you have 32bit libraries installed to allow linking is another question.... :o) -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Aug 29 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
http://dlang.org/download.html

Here is only 32 bit DMD for windows.
Aug 29 2013
parent "Temtaime" <temtaime gmail.com> writes:
It can compile 64 bit apps, but compiler itself is 32 bit.
Aug 29 2013
prev sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Thursday, 29 August 2013 at 10:09:07 UTC, Temtaime wrote:
 Hi, Walter.

 Where i can get 64 bit dmd for windows that produces 32 bit 
 executables ?
You can compile one yourself, using Visual Studio (the Express editions are free) and the Visual Studio project/solution files included with the source code.
Aug 29 2013
next sibling parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 29.08.2013 16:10, schrieb Vladimir Panteleev:
 On Thursday, 29 August 2013 at 10:09:07 UTC, Temtaime wrote:
 Hi, Walter.

 Where i can get 64 bit dmd for windows that produces 32 bit executables ?
You can compile one yourself, using Visual Studio (the Express editions are free) and the Visual Studio project/solution files included with the source code.
Do you know since when this actually works? I tried this several times but always got tons of compile errors. The latest git revision compiles fine on 64 bit though. Kind Regards Benjamin Thaut
Aug 29 2013
parent "Brad Anderson" <eco gnuk.net> writes:
On Thursday, 29 August 2013 at 14:12:39 UTC, Benjamin Thaut wrote:
 Am 29.08.2013 16:10, schrieb Vladimir Panteleev:
 On Thursday, 29 August 2013 at 10:09:07 UTC, Temtaime wrote:
 Hi, Walter.

 Where i can get 64 bit dmd for windows that produces 32 bit 
 executables ?
You can compile one yourself, using Visual Studio (the Express editions are free) and the Visual Studio project/solution files included with the source code.
Do you know since when this actually works? I tried this several times but always got tons of compile errors. The latest git revision compiles fine on 64 bit though. Kind Regards Benjamin Thaut
The cycle is: it works, then it gets broken, then Rainers will make a pull request that fixes it again. Repeat that a couple times between releases.
Aug 29 2013
prev sibling parent reply "Temtaime" <temtaime gmail.com> writes:
Yes, i can. But why Walter cannot compile it and put to downloads?

If i compile 64-bit DMD, backend's license forbids me to 
distribute it?
Aug 29 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
I have ICC license and compiled DMD by it.

I've tried to compile some my projects with it.
Some stats:

Original DMD: 20 sec.
DMD compiled by ICC: 11 sec.
x64 DMD compiled by ICC: 14 sec.

DMD's memory usage during compilation is about 600 MB.

Here is links:
http://acomirei.ru/u/dmd.exe
http://acomirei.ru/u/dmd_64.exe

It is 2.063.2 DMD, so there is no need to compile druntime. Just 
replace original dmd.exe with it.

P.S. Please, remove this links if it forbids backend license.
Aug 29 2013
parent reply Richard Webb <richard.webb boldonjames.com> writes:
On 29/08/2013 23:35, Temtaime wrote:
 I have ICC license and compiled DMD by it.

 I've tried to compile some my projects with it.
 Some stats:

 Original DMD: 20 sec.
 DMD compiled by ICC: 11 sec.
 x64 DMD compiled by ICC: 14 sec.
It might be that a big chunk of that difference is down to memory handling, as it was for MSVC builds (I think ICC uses the MS C runtimes?). If that is the case, then the difference would be a lot smaller with all the latest bits. Might be interesting to see if the ICC build is any faster than the MSVC build?
Aug 30 2013
parent reply "Temtaime" <temtaime gmail.com> writes:
Yes, it uses msvc runtimes, but ICC can optimize much more than 
VC.

I've tried to combine DMD with tcmalloc which handles memory 
allocations better than built-in malloc.

My project building duration is 9 sec.
This is more than twice faster than DM's DMD without any compiler 
logic change!

http://acomirei.ru/u/dmd_1.exe

Okay, i'll try compile DMD with VC 2012 also.
Aug 30 2013
parent "Temtaime" <temtaime gmail.com> writes:
Here is VC build:
http://acomirei.ru/u/dmd_2.exe

It gives performance about ICC: 9-10 sec.
It seems that there is no places in DMD code that ICC can 
autovectorize.
Aug 30 2013
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Thursday, August 29, 2013 08:53:01 Marek Janukowicz wrote:
 How can I decrease DMD memory usage? My program does now use about 3.5GB
 during compilation, which is horrible, as even machines with 4GB RAM
 sometimes fail to compile successfully :(
CTFE and templates (especially CTFE) are currently a real killer for memory, so if you're doing a lot of those, you're going to need a lot of memory when compiling (this will be fixed in time, but that's the way it is right now). So, reducing how much of those you're doing can really help. Probably the simplest thing to do though is simply to not compile everything at once. - Jonathan M Davis
Aug 29 2013