Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Compiling generics - Delphi Berlin vs FreePascal



Permlink Replies: 22 - Last Post: Jun 30, 2016 3:17 AM Last Post By: Bruce McGee
Konstantine Pou...

Posts: 128
Registered: 11/3/06
Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 26, 2016 7:04 PM
Up until now I was avoiding using generics in my code. However recently I hit particular case where their use would offer real benefits. However before doing anything decided to do some research. First I got project from somebody that uses generics heavily. Compiling it for 64 bit windows target had me waif for 6 minutes. Totally unacceptable. So thinking I was doing something wrong I did some googling and discovered Marco's article about "compiler performance enhancements for generics in Delphi Berlin" - http://blog.marcocantu.com/blog/2016-may-faster-generics-compilation.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+marcocantublog+%28marcocantu.blog%29 .

The article also mentioned code to test performance on generics that can be downloaded from: https://quality.embarcadero.com/browse/RSP-11865

So I did download it, modified code a little bit so that along with Delphi I can also compile it in 64 bit Lazarus/FPC combo (latest official release). So the end results for full build:

Delphi - 64bit windows target - 105 s
Delphi - 32bit windows target - 15 s
Lazarus/FPC - 64bit windows target - 7 s - total win

Since 32 bit targets are of no interest to me the real difference in compile speed for generics between FPC/Delphi is huge.
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2016 9:56 AM   in response to: Konstantine Pou... in response to: Konstantine Pou...
Konstantine Poukhov wrote:

Up until now I was avoiding using generics in my code. However
recently I hit particular case where their use would offer real
benefits. However before doing anything decided to do some research.
First I got project from somebody that uses generics heavily.
Compiling it for 64 bit windows target had me waif for 6 minutes.
Totally unacceptable. So thinking I was doing something wrong I did
some googling and discovered Marco's article about "compiler
performance enhancements for generics in Delphi Berlin" -
http://blog.marcocantu.com/blog/2016-may-faster-generics-compilation.h
tml?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+marcoca
ntublog+%28marcocantu.blog%29 .

The article also mentioned code to test performance on generics that
can be downloaded from:
https://quality.embarcadero.com/browse/RSP-11865

So I did download it, modified code a little bit so that along with
Delphi I can also compile it in 64 bit Lazarus/FPC combo (latest
official release). So the end results for full build:

Delphi - 64bit windows target - 105 s
Delphi - 32bit windows target - 15 s
Lazarus/FPC - 64bit windows target - 7 s - total win

Since 32 bit targets are of no interest to me the real difference in
compile speed for generics between FPC/Delphi is huge.

Can we see the modified code somewhere? It would be interesting to see
if the modifications make any difference.

--
Rudy Velthuis http://www.rvelthuis.de

"I find that most men would rather have their bellies opened
for five hundred dollars than have a tooth pulled for five."
-- Martin H. Fischer
Konstantine Pou...

Posts: 128
Registered: 11/3/06
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2016 10:07 AM   in response to: Rudy Velthuis (... in response to: Rudy Velthuis (...
Can we see the modified code somewhere? It would be interesting to see
if the modifications make any difference.

Sure:
http://exsotron.com/exs_files/gen_test.zip
Clement Doss

Posts: 76
Registered: 3/26/00
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2016 11:54 AM   in response to: Konstantine Pou... in response to: Konstantine Pou...
Hi

Thanks for posting...


Here are my results:
Delphi 10 Seattle
Win32 : 20.30s
Win64 : 34.98s

Delphi 10 Berlin
Win32 : 11.59s
Win64 : 37.50s (1)
Win64 : 43.71s (2)
Win64 : 43.40s (3)

All of them are Built (not compiled) using Release.
Unbelievable. And when closing the projects (after building) the IDE hangs for a few seconds ( 10 - 12 s) showing a Not responding on its captions.

Clément
Ralf Stocker

Posts: 121
Registered: 12/24/04
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2016 4:47 PM   in response to: Clement Doss in response to: Clement Doss
I don't understand why there is a difference between 32 and 64 bit? Generics are front end stuff not backend.

Clement Doss wrote:
Hi

Thanks for posting...


Here are my results:
Delphi 10 Seattle
Win32 : 20.30s
Win64 : 34.98s

Delphi 10 Berlin
Win32 : 11.59s
Win64 : 37.50s (1)
Win64 : 43.71s (2)
Win64 : 43.40s (3)

All of them are Built (not compiled) using Release.
Unbelievable. And when closing the projects (after building) the IDE hangs for a few seconds ( 10 - 12 s) showing a Not responding on its captions.

Clément
Andreas Hausladen

Posts: 46
Registered: 6/5/00
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 30, 2016 3:35 AM   in response to: Ralf Stocker in response to: Ralf Stocker
Ralf Stocker wrote:

I don't understand why there is a difference between 32 and 64 bit?
Generics are front end stuff not backend.

The front-end produces a lot of AST entries for generics and the 64 bit
back-end is the part of the compiler that is really slow compared to
the Win32 back-end. The more code there is to generate the slower the
Win64 compiler becomes compares to the Win32 compiler.
Both Win32 and Win64 use the same front-end code. So almost every
performance loss you see is related to the back-end. AMD64 has more CPU
registers than x86, what seems to make the register allocator
exponentially slower, something IDE Fix Pack 6.0 tries to address by
using SSE instructions.

--
Andreas Hausladen
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Compiling generics - Delphi Berlin vs FreePascal [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2016 4:57 PM   in response to: Clement Doss in response to: Clement Doss
Clement Doss wrote:

Delphi 10 Berlin
Win32 : 11.59s
Win64 : 37.50s (1)
Win64 : 43.71s (2)
Win64 : 43.40s (3)

All of them are Built (not compiled) using Release.

For me:

Win64 : 32.00s (1)
Win64 : 38.43s (2)

Windows 10 VM with 4GB memory available to it, and my hard disk is an SSD. (2013 MacBook Pro)

Unbelievable. And when closing the projects (after building) the IDE hangs for a few seconds ( 10 - 12 s)
showing a Not responding on its captions.

I experienced a delay of a couple of seconds, but no "Not Responding" captions. Others MMV, of course. I noticed when
closing the project the memory usage reported by task manager went down by about 500MB.

--
Dave Nottage [TeamB]
Hint, tips and tricks at: http://www.delphiworlds.com/blog
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Compiling generics - Delphi Berlin vs FreePascal [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 29, 2016 4:23 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:


For me:

Win64 : 32.00s (1)
Win64 : 38.43s (2)

Windows 10 VM with 4GB memory available to it, and my hard disk is an SSD. (2013 MacBook Pro)

With IDEFixPack 6 beta 3:

http://andy.jgknet.de/blog/2016/05/ide-fix-pack-5-95-for-delphi-10-1-berlin/

(links are below 5.95)

Win64 : 21.66s (1)
Win64 : 24.98s (2)

--
Dave Nottage [TeamB]
Hint, tips and tricks at: http://www.delphiworlds.com/blog

Arnaud Bouchez

Posts: 137
Registered: 8/2/15
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 28, 2016 2:05 AM   in response to: Konstantine Pou... in response to: Konstantine Pou...

Thanks for sharing...

It is just 1000 classes definition, with no members (methods, fields) within.
If you do not use generics, e.g. with inheritance and a "class of" pattern, the Delphi compiler would handle those classes just fast as light...

When doing proper OOP programming, using SOLID principles, you could easily reach such number of classes.
"Single Responsibility" and "Interface Segregation" would lead to define a lot of uncoupled classes.
So 1000 classes does not sounds as a huge number to me.

I understand why some people are waiting for Andy's FixPack support of Berlin, which seems to solve a lot of issues, including generics...
Arnaud Bouchez

Posts: 137
Registered: 8/2/15
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 28, 2016 2:01 AM   in response to: Konstantine Pou... in response to: Konstantine Pou...
Konstantine Poukhov wrote:
Delphi - 64bit windows target - 105 s
Delphi - 32bit windows target - 15 s
Lazarus/FPC - 64bit windows target - 7 s - total win

This is the difference between marketing power, and code power.
;)

Also the fact that both compilers did not implement at all the generics with the same way.
AFAIR FPC use a template-like approach, whereas Delphi used something more deeper integrated with the compiler AST.
Some experts may prefer one approach or another...
But this may explain the huge speed difference, since the FPC generics may have less complexity within the compiler.

What about the resulting executable size, BTW?
I was impressed by the FPC generated executables size, in respect to Delphi's.

The debugging experience is IMHO sometimes a PITA under FPC/Lazarus under Windows (gdb is not so stable here).
But, to be honest, debugging Win64 apps under Delphi is also a real PITA, especially is you have multiple threads involved.
So I usually debug using Win32 Delphi, then re-compile and run regression tests under FPC.
Note that debugging with Lazarus under Linux is a much better experience.

Both products have their strengths, and their own targets.
But it is amazing seeing an Open Source project like FPC/Lazarus doing so great, with so little founding.
Dimitrij Kowalski

Posts: 92
Registered: 1/6/05
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 29, 2016 10:33 PM   in response to: Arnaud Bouchez in response to: Arnaud Bouchez
Arnaud Bouchez wrote:

But it is amazing seeing an Open Source project like FPC/Lazarus doing so great, with so little founding.

Maybe the sad truth is that you don't need to try that hard to be better than Delphi ;)

BTW: Could you tell me what you think about this topic: https://forums.embarcadero.com/thread.jspa?threadID=213677&tstart=0

I probably shouldn't post in RTL section because not much people are browsing it...
Lars Fosdal


Posts: 156
Registered: 10/26/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 21, 2016 4:50 AM   in response to: Arnaud Bouchez in response to: Arnaud Bouchez
Arnaud Bouchez wrote:
This is the difference between marketing power, and code power.
[deletia]
Both products have their strengths, and their own targets.
But it is amazing seeing an Open Source project like FPC/Lazarus doing so great, with so little founding.

It also fails to mention that the FPC compiler can't compile all Delphi generics code, and that the FPC syntax is not compatible with Delphi.
You can kiss constraints and attributes goodbye. My code would simply not work without those.

--
http://plus.lars.fosdal.com
Delphi Developers Google+ Community: https://plus.google.com/communities/103113685381486591754 (7300+ members)
Bob Bobson

Posts: 23
Registered: 8/22/14
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 18, 2016 7:42 PM   in response to: Konstantine Pou... in response to: Konstantine Pou...
Konstantine Poukhov wrote:
Up until now I was avoiding using generics in my code. However recently I hit particular case where their use would offer real benefits. However before doing anything decided to do some research. First I got project from somebody that uses generics heavily. Compiling it for 64 bit windows target had me waif for 6 minutes. Totally unacceptable. So thinking I was doing something wrong I did some googling and discovered Marco's article about "compiler performance enhancements for generics in Delphi Berlin" - http://blog.marcocantu.com/blog/2016-may-faster-generics-compilation.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+marcocantublog+%28marcocantu.blog%29 .

The article also mentioned code to test performance on generics that can be downloaded from: https://quality.embarcadero.com/browse/RSP-11865

So I did download it, modified code a little bit so that along with Delphi I can also compile it in 64 bit Lazarus/FPC combo (latest official release). So the end results for full build:

Delphi - 64bit windows target - 105 s
Delphi - 32bit windows target - 15 s
Lazarus/FPC - 64bit windows target - 7 s - total win

Since 32 bit targets are of no interest to me the real difference in compile speed for generics between FPC/Delphi is huge.

FPC has been significantly faster than the Delphi compiler for a long time. I imagine it's largely a by-product of the extensive cross-platform compatibility work that's constantly done on FPC... (FPC natively supports more than 18 architectures!) That sort of thing is always likely to lead to significant low-level improvements. Also, FPC has INFINITELY more built-in, exposed optimization options (which again, are worked on and fine-tuned regularly) than Delphi. As in, it has MORE THAN ONE. I've found this frustrating in Delphi for years.. simply having the option to "Optimize Code", and nothing else, is NOT good enough. It's an embarrassing over-simplification. Not every Delphi programmer is a 55-year-old running Windows XP (at the latest!) maintaining some ugly horrible BDE-based database application in Delphi 7, without the slightest idea of what Haswell or AVX2 means. The stupid, outdated idea that Windows 32-bit is the only platform that exists anywhere forever, NEEDS to go.
Quentin Correll


Posts: 2,412
Registered: 12/1/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 19, 2016 10:55 AM   in response to: Bob Bobson in response to: Bob Bobson
Bob,

| Not every Delphi programmer is a 55-year-old running Windows XP

Yeah,... some of us are 81-year-olds running Windows 7-64 SP1. ;-)

--

Q -- XanaNews 1.19.1.372 - 2016-06-19 10:53:52
David Erbas-White

Posts: 202
Registered: 10/11/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 19, 2016 1:52 PM   in response to: Bob Bobson in response to: Bob Bobson
On 6/18/2016 7:42 PM, Bob Bobson wrote:

Not every Delphi programmer is a 55-year-old running Windows XP (at the latest!) maintaining some ugly horrible BDE-based database application in Delphi 7, without the slightest idea of what Haswell or AVX2 means.

...and your point is?!? <G>

David Erbas-White
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 20, 2016 7:01 AM   in response to: Bob Bobson in response to: Bob Bobson
Bob Bobson wrote:

FPC has been significantly faster than the Delphi compiler for a long
time.

Not IME. For me, it has certainly improved, but it is not faster. And I
tried on Windows, OS X and Ubuntu.

--
Rudy Velthuis http://www.rvelthuis.de

"If cats looked like frogs we'd realize what nasty, cruel little
bastards they are. Style. That's what people remember."
-- Terry Pratchett (Lords and Ladies)
Bruce McGee

Posts: 1,716
Registered: 9/30/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 29, 2016 5:00 AM   in response to: Rudy Velthuis (... in response to: Rudy Velthuis (...
Rudy Velthuis (TeamB) wrote:

Bob Bobson wrote:

FPC has been significantly faster than the Delphi compiler for a
long time.

Not IME. For me, it has certainly improved, but it is not faster. And
I tried on Windows, OS X and Ubuntu.

Well, the FPC compiler for Ubuntu is probably faster than the Linux
compiler currently available for Delphi. :)

--
Regards,
Bruce McGee
Glooscap Software
Arnaud BOUCHEZ

Posts: 143
Registered: 2/17/02
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 29, 2016 5:35 AM   in response to: Bruce McGee in response to: Bruce McGee
Bruce McGee wrote:
Well, the FPC compiler for Ubuntu is probably faster than the Linux
compiler currently available for Delphi. :)

Did you mean Kylix?
It still works (as command line cross-compiler with crosskylix), and produce small and fast executables, running on modern Ubuntu.
I use it for server applications under Linux with no problem.
And compilation time is as fast as Delphi for Win32...
Of course, it uses the Delphi 7 "dialect" so you won't be able to compile any generic with Kylix! ;)
Bruce McGee

Posts: 1,716
Registered: 9/30/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 29, 2016 7:24 AM   in response to: Arnaud BOUCHEZ in response to: Arnaud BOUCHEZ
Arnaud BOUCHEZ wrote:

Bruce McGee wrote:
Well, the FPC compiler for Ubuntu is probably faster than the Linux
compiler currently available for Delphi. :)

Did you mean Kylix?

No. I meant the not yet released Linux compiler for Delphi.

I was making a funny.

Though I'm glad to hear that people are still using Kylix.

--
Regards,
Bruce McGee
Glooscap Software
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 29, 2016 11:28 PM   in response to: Bruce McGee in response to: Bruce McGee
Bruce McGee wrote:

Not IME. For me, it has certainly improved, but it is not faster.
And I tried on Windows, OS X and Ubuntu.

Well, the FPC compiler for Ubuntu is probably faster than the Linux
compiler currently available for Delphi. :)

Ah, "available" seems to be the key word in that sentence.

--
Rudy Velthuis http://www.rvelthuis.de

"Gods prefer simple, vicious games, where you Do Not Achieve
Transcendence but Go Straight To Oblivion; a key to the
understanding of all religion is that a god's idea of amusement
is Snakes and Ladders with greased rungs."
-- Terry Pratchett (Wyrd Sisters)
Bruce McGee

Posts: 1,716
Registered: 9/30/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2016 3:17 AM   in response to: Rudy Velthuis (... in response to: Rudy Velthuis (...
Rudy Velthuis (TeamB) wrote:

Bruce McGee wrote:

Not IME. For me, it has certainly improved, but it is not faster.
And I tried on Windows, OS X and Ubuntu.

Well, the FPC compiler for Ubuntu is probably faster than the Linux
compiler currently available for Delphi. :)

Ah, "available" seems to be the key word in that sentence.

'zactly!

Looking forward to it being available, though.

--
Regards,
Bruce McGee
Glooscap Software
Gilbert Padilla

Posts: 315
Registered: 3/8/04
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 21, 2016 11:00 AM   in response to: Bob Bobson in response to: Bob Bobson
{off topic}

What Generics resembles C# Generics, FPC or Delphi?
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: Compiling generics - Delphi Berlin vs FreePascal
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 22, 2016 11:20 PM   in response to: Gilbert Padilla in response to: Gilbert Padilla
Gilbert Padilla wrote:

{off topic}

What Generics resembles C# Generics, FPC or Delphi?

Delphi, with its constraints, etc.

--
Rudy Velthuis http://www.rvelthuis.de

"If you pray for rain long enough, it eventually does fall. If
you pray for floodwaters to abate, they eventually do. The same
happens in the absence of prayers."
-- Steve Allen
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02