Board index » kylix » Delphi 7 vs. Kylix3

Delphi 7 vs. Kylix3


2005-01-22 11:43:49 PM
kylix2
so...hm ....
CLX application , compiled with D6, D7 (XP Pro) and K3 on Linux (2.6.10
kernel, XOrg-6.8), using FastReport.
Fast Report is preparing 850 pages (text...no images) from SQL server.
Measurements :
WinXP Pro (D7) ->40 seconds
Kylix 3 ->4 minutes.
So my question is : What's up ?
OK...I don't use windows, just tried how it goes on with CLX on both
platforms, but why so big difference ???
OK...let's play on linux :
simple console application which allocate dynamic string array using
setlength(MyArray,20000000),
loop through each member (for i:=0 to length(MyArray)-1) and quit program.
Measurements :
1.FPC 1.96 ->16 seconds
2.GCC 3.4.2 ->19 seconds (C code)
3.Kylix ->2 minutes 35 seconds
?????
Anyone ?
 
 

Re:Delphi 7 vs. Kylix3

Very interesting.
What is the size of your exxecutable console apps?
I really wish Borland would spend some time on Kylix (Delphi version ) and
make it work better under Linux (new distros). They are going to miss the
boat if they wait much longer and something else will come along and be the
tool for writing gui business apps.
Perhaps it is time for me to divest my stock portfolio of Borland!
-Lou
"zeljko" < XXXX@XXXXX.COM >wrote in message
Quote
so...hm ....
CLX application , compiled with D6, D7 (XP Pro) and K3 on Linux (2.6.10
kernel, XOrg-6.8), using FastReport.
Fast Report is preparing 850 pages (text...no images) from SQL server.

Measurements :

WinXP Pro (D7) ->40 seconds
Kylix 3 ->4 minutes.

So my question is : What's up ?
OK...I don't use windows, just tried how it goes on with CLX on both
platforms, but why so big difference ???

OK...let's play on linux :

simple console application which allocate dynamic string array using
setlength(MyArray,20000000),
loop through each member (for i:=0 to length(MyArray)-1) and quit program.

Measurements :
1.FPC 1.96 ->16 seconds
2.GCC 3.4.2 ->19 seconds (C code)
3.Kylix ->2 minutes 35 seconds

?????

Anyone ?





 

Re:Delphi 7 vs. Kylix3

zeljko wrote:
Quote
WinXP Pro (D7) ->40 seconds
Kylix 3 ->4 minutes.
Try this unit:
andy.jgknet.de/FreeCLX/FastAnsiStrings.zip
It replaces the AnsiCompareText, AnsiUpperCase, AnsiLowerCase and the
WideXxx functions by a faster version. This is done by installing a
(Jump-)Hook into the RTL functions under Linux.
Kylix's AnsiCompareText compared with my faster version under 3 GHz:
AnsiCompareText: ca. 800ms
FastAnsiCompareText: 3ms
The problem with AnsiCompareText is that it first converts the Ansi
strings into a two WideStrings, the calls WideCompareText which calls
WideUpperCase for both strings and then calls WideCompareStr.
Quote
simple console application which allocate dynamic string array using
setlength(MyArray,20000000),
Do both machines have equal amount of RAM?
Quote
loop through each member (for i:=0 to length(MyArray)-1) and quit
What action has your code done in the for loop? A simple read MyArray[i]
or an assignment MyArray[i] := 'A'; ?
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - unofficial Kylix 3 patches)
(andy.jgknet.de/blog)
 

{smallsort}

Re:Delphi 7 vs. Kylix3

Lou Feliz wrote:
Quote
What is the size of your executable console apps?
A simple console application compiled with dcc is around 90 kB. With
Classes around 140 kB. gcc can use the glibc as RTL and so it doesn't need
to compile glibc statically which reduces executable size a lot.
Quote
I really wish Borland would spend some time on Kylix (Delphi version )
and make it work better under Linux (new distros).
The dcc compile works perfectly under newer distros, only the IDE which is
based on a very old WineLib (the problems origin) does not work.
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - unofficial Kylix 3 patches)
(andy.jgknet.de/blog)
 

Re:Delphi 7 vs. Kylix3

Andreas Hausladen wrote:
Quote
zeljko wrote:

>WinXP Pro (D7) ->40 seconds
>Kylix 3 ->4 minutes.

Try this unit:
andy.jgknet.de/FreeCLX/FastAnsiStrings.zip
I'll do it imeddiatelly ;) thanks for link.
Quote
It replaces the AnsiCompareText, AnsiUpperCase, AnsiLowerCase and the
WideXxx functions by a faster version. This is done by installing a
(Jump-)Hook into the RTL functions under Linux.

Kylix's AnsiCompareText compared with my faster version under 3 GHz:

AnsiCompareText: ca. 800ms
FastAnsiCompareText: 3ms

The problem with AnsiCompareText is that it first converts the Ansi
strings into a two WideStrings, the calls WideCompareText which calls
WideUpperCase for both strings and then calls WideCompareStr.


>simple console application which allocate dynamic string array using
>setlength(MyArray,20000000),

Do both machines have equal amount of RAM?
It's same machine , Toshiba Tecra S1, Intel M 1.5Ghz (1Mb cache), 512 Mb
RAM.
Second machine is P4 3Ghz (HT), bit lower times, but no different in
percents, fpc is a killer compiler ;)
Quote
>loop through each member (for i:=0 to length(MyArray)-1) and quit

What action has your code done in the for loop? A simple read MyArray[i]
or an assignment MyArray[i] := 'A'; ?
Yes, I'm using MyArray[i] := 'Here I''m '+IntToStr(i);
 

Re:Delphi 7 vs. Kylix3

zeljko wrote:
Quote
Yes, I'm using MyArray[i] := 'Here I''m '+IntToStr(i);
And how do your gcc code looks like?
The dcc code needs so much time because it uses thread and "shared object
unload" safe code for copying constant strings. But let's investigate some
more time in this issue.
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - unofficial Kylix 3 patches)
(andy.jgknet.de/blog)
 

Re:Delphi 7 vs. Kylix3

Quote
Try this unit:
andy.jgknet.de/FreeCLX/FastAnsiStrings.zip

It replaces the AnsiCompareText, AnsiUpperCase, AnsiLowerCase and the
WideXxx functions by a faster version. This is done by installing a
(Jump-)Hook into the RTL functions under Linux.

Kylix's AnsiCompareText compared with my faster version under 3 GHz:

AnsiCompareText: ca. 800ms
FastAnsiCompareText: 3ms

The problem with AnsiCompareText is that it first converts the Ansi
strings into a two WideStrings, the calls WideCompareText which calls
WideUpperCase for both strings and then calls WideCompareStr.
tnx Andreas, measured with FastAnsiStrings included :
### OLD TIMING ###
WinXP Pro (D7) ->40 seconds
Kylix 3 ->4 minutes.
#############
### NEW TIMING ###
WinXP Pro (D7) ->40 seconds
Kylix 3 ->1 minute 50 seconds.
HINT :
Same app running under CrossOver 4
1 minute 25 seconds
#############
can't believe in this !!
Emulator runs faster than native app ?!?!? ;)
 

Re:Delphi 7 vs. Kylix3

zeljko wrote:
Quote
WinXP Pro (D7) ->40 seconds
Kylix 3 ->1 minute 50 seconds.
There must be another bottle neck. Can you give me something so I can
profile the code down to the RTL (as I have done with the AnsiCompareText
for a DB app that was finished in 1 minute under Windows but needed 15
minutes under Linux)
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - unofficial Kylix 3 patches)
(andy.jgknet.de/blog)
 

Re:Delphi 7 vs. Kylix3

Andreas Hausladen wrote:
Quote
zeljko wrote:

>Yes, I'm using MyArray[i] := 'Here I''m '+IntToStr(i);

And how do your gcc code looks like?
It's on my laptop (at home), so I cannot send it at the moment but it
normal, stupid c code.
Quote
The dcc code needs so much time because it uses thread and "shared object
unload" safe code for copying constant strings. But let's investigate some
more time in this issue.
yes, but why fpc is so faster , it's not few seconds or few percents , well
must say why is kylix so slow it's few hundreds percents slower.
I've tested at the moment TList allocation (10 000 000) and TList.Free, also
fpc is cca 20% faster, TStringGrid with 1000000 rows etc, fpc is 20-30 %
faster than kylix (yes I know, Gtk 1 is faster a bit than Qt 2.3).
When I set RowCount to 10 000 000 (ten million), and tried to fill it , fpc
app finished in about 5 minutes, but kylix app died after 1 minute with
access violations.
 

Re:Delphi 7 vs. Kylix3

Andreas Hausladen wrote:
Quote
The dcc code needs so much time because it uses thread and "shared object
unload" safe code for copying constant strings. But let's investigate
some more time in this issue.
fpc seems to have also thread safe code in fpc_ansistr_decr_ref()
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - unofficial Kylix 3 patches)
(andy.jgknet.de/blog)
 

Re:Delphi 7 vs. Kylix3

Some issues that should be fixed:
* Kylix's _NewAnsiString must handle _NewWideString redirection.
Why not simple use the "Ansi"-Only version with length*2 size and set the
double #0 in the _NewWideString function. This does not need much time but
it is overhead an AnsiString must not have.
* Kylix's IntToStr requires a LStringFromString because the Str()
functions are only implemented for ShortStrings. A injected AnsiString
version for SysUtils.IntToStr should speed the things up (not only under
Linux)
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - unofficial Kylix 3 patches)
(andy.jgknet.de/blog)
 

Re:Delphi 7 vs. Kylix3

zeljko,
The various comments you've made in this thread make me think you are benchmarking using
visual output, and therefore simply are only measuring how slow CLX is.
From my experience I can tell you that Kylix compiled code is actually faster than Delphi one,
the main reason being the quite {*word*99}py Delphi memory manager (where Kylix simply calls malloc()).
Here is a very simple benchmark:
---------------------
program speedtest;
{$IFDEF fpc}
{$mode Delphi}
{$threading on}
{$ELSE}
{$APPTYPE Console}
{$ENDIF}
uses
SysUtils, Classes
{$IFDEF fpc}
{$IFDEF unix}
,linux,cthreads
{$ELSE}
,Windows
{$ENDIF}
{$ELSE}
{$IFDEF linux}
,Libc
{$ELSE}
,Windows
{$ENDIF}
{$ENDIF}
;
function getuptime: integer;
{$IFDEF LINUX}
var
si: TSysInfo;
{$ENDIF}
begin
{$IFNDEF LINUX}
result := gettickcount div 1000;
{$ELSE}
sysinfo(si);
result := si.uptime;
{$ENDIF}
end;
function dosomething(bla:integer):string;
begin
result:=inttostr(bla*3434*123*bla);
end;
var starttime:integer;
sl:TStringList;
i,j,k:integer;
t:string;
begin
ismultithread:=true;
starttime:=getuptime;
sl:=TStringList.Create;
for i:=0 to 100 do
begin
t:='';
sl.clear;
write('.');
for j:=0 to 100 do
begin
for k:=0 to 50 do
begin
t:=t+dosomething(k);
sl.add(t);
end;
end;
end;
writeln;
writeln(getuptime-starttime,' seconds');
end.
---------------------
This program will compile with:
- Delphi/Windows
- Kylix/Linux
- FPC/Windows
- FPC/Linux
I know it's a pretty sucky benchmark, as it will mostly measure the speed of the memory manager,
but oh well.
Compiled with Delphi/Kylix default release options, and with FPC switched to best optimizations,
here are my results:
Delphi/Windows: 47 seconds
FPC/Windows: 35 seconds
(Linux tests run on a different Box, so Linux<->Windows results aren't comparable. However the Windows box
is a 2.5GHz P4, where the Linux one is a 2Ghz P4)
Kylix/Linux: 29 seconds
FPC/Linux: 53 seconds.
Of course this benchmark is nowhere near a real-life scenario, but together with my experience I can
only say: If your application is hundreds of percents slower running under Linux, then there is something
really wrong with it.
Simon
 

Re:Delphi 7 vs. Kylix3

Quote
The various comments you've made in this thread make me think you are benchmarking using
visual output, and therefore simply are only measuring how slow CLX is.
That was meant to be "how slow *QT* is", of course.
Simon
 

Re:Delphi 7 vs. Kylix3

Simon Kissel wrote:
Quote
I know it's a pretty sucky benchmark, as it will mostly measure the
speed of the memory manager, but oh well.
Last week I have ported Delphi's memory manager to Linux
(malloc=LocalAlloc, free=LocalFree,mmap=VirtualAlloc,munmap=VirtualFree)
and the DB app was around 200 ms faster. So it looks like that Linux's
mmap is faster than Windows VirtualAlloc.
But these 200 ms are not worth the problems we get with an own memory
manager (Delphi MM vs. DLLs).
Quote
If your application is hundreds of percents slower running
under Linux, then there is something really wrong with it.
Or you use a RTL function that is implemented different as under Windows.
For example: AnsiCompareText.
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - unofficial Kylix 3 patches)
(andy.jgknet.de/blog)
 

Re:Delphi 7 vs. Kylix3

Quote
>I know it's a pretty sucky benchmark, as it will mostly measure the
>speed of the memory manager, but oh well.

Last week I have ported Delphi's memory manager to Linux
(malloc=LocalAlloc, free=LocalFree,mmap=VirtualAlloc,munmap=VirtualFree)
and the DB app was around 200 ms faster. So it looks like that Linux's
mmap is faster than Windows VirtualAlloc.

But these 200 ms are not worth the problems we get with an own memory
manager (Delphi MM vs. DLLs).
Yes, this is what I experienced too. The libc heapmanager seems to be much
better than Borlands Delphi one, and the OS-level memory manager also seems
to be much better under Linux than under Windows.
Btw, I'm VERY interested in your port. This would mean that it might become possible
to use of the specialized memory managers available for Delphi with Kylix.
Quote
>If your application is hundreds of percents slower running
>under Linux, then there is something really wrong with it.

Or you use a RTL function that is implemented different as under Windows.
For example: AnsiCompareText.
At least he probably has a huge bottleneck somewhere. Time to profile.
At least the generic assumption that Kylix applications are slower than Delphi
ones is false.
Simon