Jump to page: 1 2
Thread overview
DM linker vs GCC linker?
Jan 18, 2012
Andrea Fontana
Jan 18, 2012
Trass3r
Jan 18, 2012
Andrea Fontana
Jan 18, 2012
Andrea Fontana
Jan 18, 2012
Trass3r
Jan 18, 2012
Andrea Fontana
Jan 18, 2012
Martin Nowak
Jan 18, 2012
Andrea Fontana
Jan 18, 2012
Jacob Carlborg
Jan 18, 2012
Andrea Fontana
Jan 19, 2012
Marco Leise
Jan 18, 2012
Jacob Carlborg
Jan 18, 2012
Martin Nowak
Jan 19, 2012
Andrea Fontana
January 18, 2012
I'm working on a complex project for my company.
It's a text-parser that handles complex/ambiguos word-based grammars. It
reads a set of xml files that define rules, build some structures
(trees, dictionaries, etc..) and then parses your phrases.  It works
fine.

I compile sources in this (simple) way:
dmd -c *.d   (three source files)

If i link objects with dmd execution of unit tests takes:

Parsing: 722 ms, 419 μs, and 3 hnsecs

real	5m10.199s
user	5m9.771s
sys	0m0.236s


using gcc as linker:

Parsing: 425 ms, 677 μs, and 8 hnsecs

real	0m13.919s
user	0m13.845s
sys	0m0.088s


unittest outputs are identical and execution time of test phrases has similar speed but dmd version takes a lot of time parsing xml and building trees and other structures.

I can't post company code, but i wonder if this is a known issue... If not i'll try to write some code to reproduce this problem...

Configuration:
Ubuntu 11.10 64bit
DMD64 D Compiler v2.056
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)



January 18, 2012
> Configuration:
> Ubuntu 11.10 64bit
> DMD64 D Compiler v2.056
> gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)

? dmd also uses ld to link.
January 18, 2012
I can't understand why it's 22 times slower...

Il giorno mer, 18/01/2012 alle 14.54 +0100, Trass3r ha scritto:

> > Configuration:
> > Ubuntu 11.10 64bit
> > DMD64 D Compiler v2.056
> > gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
> 
> ? dmd also uses ld to link.




January 18, 2012
Ok, here a test:

test.d :

import std.xml;
import std.stdio;
import std.conv;

int main(string[] args)
{
        if (args.length != 2)
        {
                writeln("Usage: ", args[0], " file.xml");
                return 0;
        }

        string content = to!string(std.file.read(args[1]));

        try{
                check(content);
        } catch (CheckException ex) { writeln("Exception: ", ex); }
        return 0;
}


dmd -c test.d && gcc test.o -lphobos2 -lrt -lpthread -o testgcc
vs
dmd -c test.d && dmd test.o -oftestd

try this code using a long xml file (tested here with a 2.0 mb list of
italian cities) ...

Il giorno mer, 18/01/2012 alle 15.27 +0100, Andrea Fontana ha scritto:

> I can't understand why it's 22 times slower...
> 
> Il giorno mer, 18/01/2012 alle 14.54 +0100, Trass3r ha scritto:
> 
> > > Configuration:
> > > Ubuntu 11.10 64bit
> > > DMD64 D Compiler v2.056
> > > gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
> > 
> > ? dmd also uses ld to link.
> 
> 




January 18, 2012
> dmd -c test.d && gcc test.o -lphobos2 -lrt -lpthread -o testgcc
> vs
> dmd -c test.d && dmd test.o -oftestd

Well dmd test.d calls
gcc test.o -o test -m64 -Xlinker -L/dmd/linux/lib64 -Xlinker -L/dmd/linux/lib32 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lphobos2 -lpthread -lm -lrt
January 18, 2012
On 2012-01-18 15:37, Andrea Fontana wrote:
>
> Ok, here a test:
>
> test.d :
>
> import std.xml;
> import std.stdio;
> import std.conv;
>
> int main(string[] args)
> {
> if (args.length != 2)
> {
> writeln("Usage: ", args[0], " file.xml");
> return 0;
> }
>
> string content = to!string(std.file.read(args[1]));
>
> try{
> check(content);
> } catch (CheckException ex) { writeln("Exception: ", ex); }
> return 0;
> }
>
>
> dmd -c test.d && gcc test.o -lphobos2 -lrt -lpthread -o testgcc
> vs
> dmd -c test.d && dmd test.o -oftestd
>
> try this code using a long xml file (tested here with a 2.0 mb list of
> italian cities) ...

Have you tried compiling and linking in one step with dmd? Just like this:

dmd test.d

BTW, you can pass "-v2 to dmd to see which flags it uses when invoking gcc.


-- 
/Jacob Carlborg
January 18, 2012
This param:
--Xlinker --export-dynamic

slows down the entire app (check() std.xml function) by 29x on test.

Is it useful to add it on default config? Probably if you use external dl, you should add it...

andrea@ububox:~/src/xml-test$ dmd -c test.d && gcc test.o -o testgcc2
-m64 -Xlinker --export-dynamic -Xlinker --no-warn-search-mismatch
-lphobos2 -lpthread -lm -lrt
andrea@ububox:~/src/xml-test$ time ./testgcc2 cities.xml

real	3m23.426s
user	3m22.901s
sys	0m0.276s

andrea@ububox:~/src/xml-test$ dmd -c test.d && gcc test.o -o testgcc2 -m64 -Xlinker --no-warn-search-mismatch -lphobos2 -lpthread -lm -lrt andrea@ububox:~/src/xml-test$ time ./testgcc2 cities.xml

real	0m7.433s
user	0m7.316s
sys	0m0.112s

Il giorno mer, 18/01/2012 alle 15.43 +0100, Trass3r ha scritto:

> > dmd -c test.d && gcc test.o -lphobos2 -lrt -lpthread -o testgcc
> > vs
> > dmd -c test.d && dmd test.o -oftestd
> 
> Well dmd test.d calls
> gcc test.o -o test -m64 -Xlinker -L/dmd/linux/lib64 -Xlinker
> -L/dmd/linux/lib32 -Xlinker --no-warn-search-mismatch -Xlinker
> --export-dynamic -lphobos2 -lpthread -lm -lrt




January 18, 2012
On Wed, 18 Jan 2012 16:00:05 +0100, Andrea Fontana <advmail@katamail.com> wrote:

> This param:
> --Xlinker --export-dynamic
>
> slows down the entire app (check() std.xml function) by 29x on test.
>
> Is it useful to add it on default config? Probably if you use external
> dl, you should add it...
>
> andrea@ububox:~/src/xml-test$ dmd -c test.d && gcc test.o -o testgcc2
> -m64 -Xlinker --export-dynamic -Xlinker --no-warn-search-mismatch
> -lphobos2 -lpthread -lm -lrt
> andrea@ububox:~/src/xml-test$ time ./testgcc2 cities.xml
>
> real	3m23.426s
> user	3m22.901s
> sys	0m0.276s
>
> andrea@ububox:~/src/xml-test$ dmd -c test.d && gcc test.o -o testgcc2
> -m64 -Xlinker --no-warn-search-mismatch -lphobos2 -lpthread -lm -lrt
> andrea@ububox:~/src/xml-test$ time ./testgcc2 cities.xml
>
> real	0m7.433s
> user	0m7.316s
> sys	0m0.112s
>
> Il giorno mer, 18/01/2012 alle 15.43 +0100, Trass3r ha scritto:
>
>> > dmd -c test.d && gcc test.o -lphobos2 -lrt -lpthread -o testgcc
>> > vs
>> > dmd -c test.d && dmd test.o -oftestd
>>
>> Well dmd test.d calls
>> gcc test.o -o test -m64 -Xlinker -L/dmd/linux/lib64 -Xlinker
>> -L/dmd/linux/lib32 -Xlinker --no-warn-search-mismatch -Xlinker
>> --export-dynamic -lphobos2 -lpthread -lm -lrt
>
>
Do you have a lot of exceptions being thrown in your code?
January 18, 2012
On 2012-01-18 16:00, Andrea Fontana wrote:
> This param:
> --Xlinker --export-dynamic
>
> slows down the entire app (check() std.xml function) by 29x on test.
>
> Is it useful to add it on default config? Probably if you use external
> dl, you should add it...
>
> andrea@ububox <mailto:andrea@ububox>:~/src/xml-test$ dmd -c test.d &&
> gcc test.o -o testgcc2 -m64 -Xlinker --export-dynamic -Xlinker
> --no-warn-search-mismatch -lphobos2 -lpthread -lm -lrt
> andrea@ububox <mailto:andrea@ububox>:~/src/xml-test$ time ./testgcc2
> cities.xml
>
> real 3m23.426s
> user 3m22.901s
> sys 0m0.276s
>
> andrea@ububox:~/src/xml-test$ dmd -c test.d && gcc test.o -o testgcc2
> -m64 -Xlinker --no-warn-search-mismatch -lphobos2 -lpthread -lm -lrt
> andrea@ububox <mailto:andrea@ububox>:~/src/xml-test$ time ./testgcc2
> cities.xml
>
> real 0m7.433s
> user 0m7.316s
> sys 0m0.112s
>
> Il giorno mer, 18/01/2012 alle 15.43 +0100, Trass3r ha scritto:
>> >  dmd -c test.d&&  gcc test.o -lphobos2 -lrt -lpthread -o testgcc
>> >  vs
>> >  dmd -c test.d&&  dmd test.o -oftestd
>>
>> Well dmd test.d calls
>> gcc test.o -o test -m64 -Xlinker -L/dmd/linux/lib64 -Xlinker
>> -L/dmd/linux/lib32 -Xlinker --no-warn-search-mismatch -Xlinker
>> --export-dynamic -lphobos2 -lpthread -lm -lrt
>

How about DMD passing --export-dynamic to GCC if -shared is passed to DMD?

-- 
/Jacob Carlborg
January 18, 2012
Not so much. Maybe inside check() of std.xml that check for xml correctness and throw exception. It's the function that slow down the entire app.

Il giorno mer, 18/01/2012 alle 16.26 +0100, Martin Nowak ha scritto:

> On Wed, 18 Jan 2012 16:00:05 +0100, Andrea Fontana <advmail@katamail.com> wrote:
> 
> > This param:
> > --Xlinker --export-dynamic
> >
> > slows down the entire app (check() std.xml function) by 29x on test.
> >
> > Is it useful to add it on default config? Probably if you use external dl, you should add it...
> >
> > andrea@ububox:~/src/xml-test$ dmd -c test.d && gcc test.o -o testgcc2
> > -m64 -Xlinker --export-dynamic -Xlinker --no-warn-search-mismatch
> > -lphobos2 -lpthread -lm -lrt
> > andrea@ububox:~/src/xml-test$ time ./testgcc2 cities.xml
> >
> > real	3m23.426s
> > user	3m22.901s
> > sys	0m0.276s
> >
> > andrea@ububox:~/src/xml-test$ dmd -c test.d && gcc test.o -o testgcc2 -m64 -Xlinker --no-warn-search-mismatch -lphobos2 -lpthread -lm -lrt andrea@ububox:~/src/xml-test$ time ./testgcc2 cities.xml
> >
> > real	0m7.433s
> > user	0m7.316s
> > sys	0m0.112s
> >
> > Il giorno mer, 18/01/2012 alle 15.43 +0100, Trass3r ha scritto:
> >
> >> > dmd -c test.d && gcc test.o -lphobos2 -lrt -lpthread -o testgcc
> >> > vs
> >> > dmd -c test.d && dmd test.o -oftestd
> >>
> >> Well dmd test.d calls
> >> gcc test.o -o test -m64 -Xlinker -L/dmd/linux/lib64 -Xlinker
> >> -L/dmd/linux/lib32 -Xlinker --no-warn-search-mismatch -Xlinker
> >> --export-dynamic -lphobos2 -lpthread -lm -lrt
> >
> >
> Do you have a lot of exceptions being thrown in your code?




« First   ‹ Prev
1 2