Board index » delphi » Re: A Tale of Two Memory Managers (long)

Re: A Tale of Two Memory Managers (long)


2004-06-08 09:15:52 PM
delphi194
Quote

Modern heap managers have evolved beyond the linked list of Delphi's
:)
Yes, anything is better than Delphi's default memory manager ;-). And
this was one of the points I was trying to make. While a linked list
approach might have been ok with 640 kb (and probably faster than any
other thing there), when we move into more and more memory, it has to
be re-evaluated.
GC is a solution to this, of course not the only one, and it has its
good things and its drawbacks (as the other solutions probably have,
too). But what I wanted to say is that in fact GC is a *solution* to a
performance problem, not a safety net for bad programmers that trades
performance for safety. In fact, as a safety net is quite bad, as it
has holes (disposable resources and not null references) and might give
a false sense of security.
Methods that worked ok with 1 mb might not be ok with a million mb, and
you have to look at it different. If you have a glass of water, the
best approach might be to take a drop, use it and returnt it back. Now,
if you have an ocean, it might be better to take all the water you
need, use it, and return it all togeter.
Quote
There is another issue with the GC allocation scheme: it isn't cache
friendly, and uncached memory is about 10 times slower to access than
cached memory. By allocating linearly with little reuse, you
effectively maximize cache misses, which is why MS had to try and
implement a complex multilayered GC for .Net, but the issue can still
pop up if you stress it enough.
Hadn't thought about cache misses, thanks for the point. I am sure you
are much more informed on this than me :-). And in fact, thanks a lot
for your work on the memory manager, I think it is a great thing for
all the delphi community.
Best regards,
Adrian.
 
 

Re: A Tale of Two Memory Managers (long)

Quote
If you have a glass of water, the best approach might be to take a drop,
use it and returnt it back. Now, if you have an ocean, it might be better
to take all the water you need, use it, and return it all togeter.
Well, a GC's approach is more like taking drops one after another,
and when the ocean is becoming empty, have a look at all the drops
it has taken to see if there wouldn't be some that aren't used anymore
and that could be replaced in the ocean... :)
GC performance is all based on a bet: that there will be free CPU time
so the drop checking can happen without hindering execution speed,
which is very common in single-user interactive (not real time) applications
or for servers under limited stress, and that is where it works well.
Of course, the higher your CPU load, the less chances it has to happen,
and so, the most complex the drop checking will be when finally the ocean
becomes empty.
Erci
 

Re: A Tale of Two Memory Managers (long)

Quote
GC performance is all based on a bet: that there will be free CPU time
so the drop checking can happen without hindering execution speed,
which is very common in single-user interactive (not real time)
applications or for servers under limited stress, and that is where it
works well. Of course, the higher your CPU load, the less chances it
has to happen, and so, the most complex the drop checking will be
when finally the ocean becomes empty.

Maybe this could a good point on GC, because I don't think processor
speed will continue to increase at the same rate it has.
Some background, 10 years ago I read a very interesting article that
explained why microprocessors would never get a 1ghz clock with
transistor technologies :-) Ok, they might have not been completely
right, but I think they had a point. One of the arguments was that
light, on one nanosecond can only travel 30 cm!
So, we have 3 ghz pc now (10 cm), and even faster annouced... but...
there will be a physical speed limit, and it doesnt seem so far away.
And as we approach the limit, increasing processor speed will be more
and more expensive, and adding a farm of slower procesors will probably
be the better solution. And GC could fit quite nice there, because you
can dedicate one cpu or 2 just for doing the GC.
Of course this is all, as you perfectly said, a bet. Nobody knows what
the future will bring, but I think the gc bet isn't the worst.
Best regards,
Adrian.
Ps: for anyone reading this that want to verify the numbers, google
calculator is quite good for it :-) Just enter "c *(1 nanosecond)="
(without quotes) or "c /(1Ghz) =" on the search box...
 

Re: A Tale of Two Memory Managers (long)

Quote
Maybe this could a good point on GC, because I don't think processor
speed will continue to increase at the same rate it has.
Well, Intel pretty much announced that the era of increasing speeds
by increasing frequency is over by dropping their next generation
P4 and refocusing on multi-core variants or the PIII-M.
Quote
So, we have 3 ghz pc now (10 cm), and even faster annouced...
Apparently they have reached a current leak barrier that wasn't
expected to be so steep (the transistors leak more and more current,
thus generate more and more heat, which can locally fuse or burn
the chip).
Quote
but I think the gc bet isn't the worst.
I do think it has its place, and AMOF I use commonly String in Delphi
as "garbage collected" binary storage, but I see it strong only in
addition to classic memory management.
There is just no reason to have *everything* be garbage collected,
if many things benefit from GC, others don't.
Eric
 

Re: A Tale of Two Memory Managers (long)

"Dennis Landi" <none[at]none.com>skrev i en meddelelse
Quote
An interesting observation about all this is that I think we could have
had
.NET without a GC (Garbage Collector). In no way is a GC needed to
realize
the larger vision of .NET.
MS probably needed GC in order to make VB(Visual Basic) a .NET language....
--
Finn Tolderlund
 

Re: A Tale of Two Memory Managers (long)

Hi Dennis,
Quote

The question is if the "performance market" is big enough to have Borland
spend time on developing a native 64-bit Delphi compiler.

If you ask... every web-based application. Every every server-basend
application. Systems who run on the servern and "serve" several clients
are own to the "performance market"...
with best regards
Nils
--
*--------------------------------------------------------*
| Nils Boedeker VERLAG EUGEN ULMER |
| Bürgerwohlsweg 7 Datenbanken und IT-Entwicklung |
| D-28215 Bremen -------------------------------------|
| Germany Tel/Fax: +49 (0) 421 3795-020/-021 |
| Mobilfunk: +49 (0) 172 7468066 |
|--------------------------------------------------------|
| eMail:XXXX@XXXXX.COM | eMail:XXXX@XXXXX.COM |
|--------------------------------------------------------|
| www.ulmer.de | www.nbsoft.de |
|--------------------------------------------------------|
| Available by Yahoo Messenger, yahoo ID: nilsboedeker |
*--------------------------------------------------------*
 

Re: A Tale of Two Memory Managers (long)

"Finn Tolderlund" <XXXX@XXXXX.COM>writes
Quote

"Dennis Landi" <none[at]none.com>skrev i en meddelelse
news:40c56284$XXXX@XXXXX.COM...
>An interesting observation about all this is that I think we could have
had
>.NET without a GC (Garbage Collector). In no way is a GC needed to
realize
>the larger vision of .NET.

MS probably needed GC in order to make VB(Visual Basic) a .NET language....
--
And the only programmer population where .NET is an improvement across the
board is the VB(Visual Basic) crowd.
And actually this is a good thing for the entire industry. The sooner we
can train up this population on a real progamming environment, the better it
will be for all of us.
-d
 

Re: A Tale of Two Memory Managers (long)

On Tue, 08 Jun 2004 12:11:37 +0200, Eric Grange
<XXXX@XXXXX.COM>writes:
Quote
The other is to use objects,
but then, you lose the ability to assign (which becomes a copy of reference
instead of a copy of value), and also get added performance penalty from GC
allocation and management overhead. The JIT codegen for objects isn't
always as efficient as the one for ref structs (often adds a bunch of
unnecessary register shuffling).
Just as an example of how prominent this GC hit can be, in my
raytracer i create a L O T of Vector objects, which are in turn passed
as parameters ALL over. VERY often. So, i though, ok, obviously
passing them by having to copy 4 x doubles for each param aint good
for speed, lets try to use a class instead of record.
In the beginning the speed was a bit better, but after the raytracer
evolved and further layers entered the scene, I noticed that "time in
GC" exceeded 60% constantly, peaking often to 90+. Not good!
So, I tried to revert back to records (which wasnt trivial, as
copy-on-assign vs not had to be taken care of). That brought it down
to sub 30's. Obviously the app had more time for itself now :)
That's one of the few things where i truly find .net lacking. I can
understand their argument but...
- Asbjørn
 

Re: A Tale of Two Memory Managers (long)

"Dennis Landi" <none[at]none.com>skrev i en meddelelse
Quote
"Finn Tolderlund" <XXXX@XXXXX.COM>writes
news:40c5de87$XXXX@XXXXX.COM...
>
>"Dennis Landi" <none[at]none.com>skrev i en meddelelse
>news:40c56284$XXXX@XXXXX.COM...
>>An interesting observation about all this is that I think we could
have
>had
>>.NET without a GC (Garbage Collector). In no way is a GC needed to
>realize
>>the larger vision of .NET.
>
>MS probably needed GC in order to make VB(Visual Basic) a .NET language....
>--

And the only programmer population where .NET is an improvement across the
board is the VB(Visual Basic) crowd.
And the rest of us pays the price.
Quote
And actually this is a good thing for the entire industry. The sooner we
can train up this population on a real progamming environment, the better
it
will be for all of us.
I can not see how it is a good thing for the entire industri.
It's probably a good thing for the VB(Visual Basic) community, but only for them, not for
the rest of us.
--
Finn Tolderlund
 

Re: A Tale of Two Memory Managers (long)

"Finn Tolderlund" <XXXX@XXXXX.COM>writes
Quote

I can not see how it is a good thing for the entire industri.
It's probably a good thing for the VB(Visual Basic) community, but only for them, not
for
the rest of us.
Because this massive population has had a brain-damaging affect on our
potential customer base and market. There is nothing more disheartening
then trying to get Delphi into an organization and failing because its not
VB.
Meanwhile, {*word*99}py VB(Visual Basic) apps and behavioural patterns become entrenched in
whole sectors. Short of a flame-thrower, only education from the inside is
going to change things. This can happen by transforming the VB(Visual Basic) programmer
into a better class of programmer. To that end VB.NET is a very good thing
to happen to all of us. Todays VB.NET programmer is tomorrows C#
programmer, as he/she suddenly begins to catch on to the possibilities of
"components" etc...
-d
 

Re: A Tale of Two Memory Managers (long)

Dennis Landi writes:
Quote
And the only programmer population where .NET is an improvement across the
board is the VB(Visual Basic) crowd.
Good point. Of course, you could argue that it is a radical improvement
for the C# developers too. ;-)
 

Re: A Tale of Two Memory Managers (long)

You're full of it.
The fact is had there not been a VB, there would not have been a Delphi. So
if you've made any money from Delphi at all, thank Microsoft. Far from
damaging your market, VB(Visual Basic) created it.
Point two: You can write good software in VB(Visual Basic) Classic; you can write bad
software in Delphi. I have done both :-)
And third: Getting Delphi into an organization has little to do with VB(Visual Basic) and
much to do with too many people never having heard of it or Borland.
Finally: Why does Microsoft get blamed for other software companies'
missteps? It wasn't Microsoft Excel and Word that destroyed Lotus 1-2-3 and
Wordperfect; it was their respective owners. Access didn't destroy dBase,
Ashton-Tate and Borland did. And VB(Visual Basic) became popular because there was nothing
like it on the market before. Had Delphi been first (which it couldn't have
been), then things might be very different today.
"Dennis Landi" <none[at]none.com>writes
Quote
"Finn Tolderlund" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...

>
>I can not see how it is a good thing for the entire industri.
>It's probably a good thing for the VB(Visual Basic) community, but only for them, not
for
>the rest of us.

Because this massive population has had a brain-damaging affect on our
potential customer base and market. There is nothing more disheartening
then trying to get Delphi into an organization and failing because its not
VB.

 

Re: A Tale of Two Memory Managers (long)

"Alan Questell" <XXXX@XXXXX.COM>writes
Quote
You're full of it.

The fact is had there not been a VB, there would not have been a Delphi.
So? Who cares? The Model T was the first car.
Quote
So
if you've made any money from Delphi at all, thank Microsoft. Far from
damaging your market, VB(Visual Basic) created it.

VB is a brain-damaged product, that brain damages developers who use it too
long. They begin to think that if they can not do something in VB, it can be
done. No threads, services, sockets etc, leads to a very limited little
product with a very limited mentality using it...
Quote
Point two: You can write good software in VB(Visual Basic) Classic;
Multi-threaded services for instance? Efficient TCP-IP or XML Transports
for instance? Nope, not really. Dropping a couple of buttons and grid on a
form and hooking it up? <sigh>Yeah, you can do that.
Quote
you can write bad
software in Delphi. I have done both :-)

I will, of course, defer to your experience on this issue.
Quote
And third: Getting Delphi into an organization has little to do with VB
and
much to do with too many people never having heard of it or Borland.

Agreed. Since they've heard of MS, they'd rather go with a demonstrably
limited toolset, than one that is demonstrably superior before their very
eyes. We agree there. And that is pretty much what I meant.
But I have seen hundreds (maybe thousands) of dispirited end-users in mid
and large companies and gov't agencies who are in despair because their
applications just plain suck. (Their main complaint, of course, is about
PERFORMANCE... <g>. )
Much of the time, VB(Visual Basic) has a lock on that organization...
Anyway, sorry to let this thread drift off topic. The defense of VB(Visual Basic) should
probably go in its own thread....
-d
 

Re: A Tale of Two Memory Managers (long)

Quote
The fact is had there not been a VB, there would not have been a Delphi. So
if you've made any money from Delphi at all, thank Microsoft. Far from
damaging your market, VB(Visual Basic) created it.
_LOL_ (144pt size)
There was not any VB(Visual Basic) on the horizon and I did well as a programmer.
You are kidding, no doubt. We had Turbo/Borland Pascal, - that was superior IDE.
Long before VB(Visual Basic) Clarion presented its code/form paradigm (yet in DOS), and before
there was Informix' Smart.
Paul Lotus (yeah, that guy who got $10000USD per day in the late of 80's) wrote, that he tried
to write first incarnation of his Arahnophilia in VB, but understood, that the thing was not for serious programs.
Delphi (as environment) was just a BP IDE + Resource Workshop (by Borland again). What made it great
- language _and_ VCL. But yes, VB(Visual Basic) created something - army of rookies, who thought they were generals,
and mind illusion that programming was easy. And that army dropped significantly our salaries down.
So please, forget that "And VB(Visual Basic) became popular because there was nothing
like it on the market before", it is just untrue.
Quote
Had Delphi been first (which it couldn't have
been), then things might be very different today.
(in)famous marketing thing, you know ;) OS/2 Warp went into public half year before Win95, so..?
 

Re: A Tale of Two Memory Managers (long)

Turbo Pascal was a fine product for its time, but it was not RAD. VB(Visual Basic) began
the RAD revolution and Delphi followed in its footsteps. I am not arguing
that VB(Visual Basic) is superior to Delphi technically. Obviously it wasn't, or I
wouldn't be here. But to argue that you couldn't write serious software with
it is silly. At the first company I worked for, all our internally built
systems were built with VB(Visual Basic) and we ran a multi-billion dollar company with
them.
OS/2 Warp and Delphi are not analogous. There was already a good enough
operating system when OS/2 Warp came out. There was no RAD programming
system before VB, and it was a revolution waiting to happen. VB(Visual Basic) was first.
OS/2 Warp's great claim to fame was that it was "a better Windows than
Windows." While that may have been true, for most people, Windows was good
enough.
Had there been a Delphi before VB, and I am arguing that there couldn't have
been since it borrowed many ideas from VB, then Delphi would have been huge.
"Andrew Rybenkov" <XXXX@XXXXX.COM>writes
Quote
>The fact is had there not been a VB, there would not have been a Delphi.
So
>if you've made any money from Delphi at all, thank Microsoft. Far from
>damaging your market, VB(Visual Basic) created it.

_LOL_ (144pt size)
There was not any VB(Visual Basic) on the horizon and I did well as a programmer.
You are kidding, no doubt. We had Turbo/Borland Pascal, - that was
superior IDE.
Long before VB(Visual Basic) Clarion presented its code/form paradigm (yet in DOS), and
before
there was Informix' Smart.
Paul Lotus (yeah, that guy who got $10000USD per day in the late of 80's)
wrote, that he tried
to write first incarnation of his Arahnophilia in VB, but understood, that
the thing was not for serious programs.
Delphi (as environment) was just a BP IDE + Resource Workshop (by Borland
again). What made it great
- language _and_ VCL. But yes, VB(Visual Basic) created something - army of rookies, who
thought they were generals,
and mind illusion that programming was easy. And that army dropped
significantly our salaries down.

So please, forget that "And VB(Visual Basic) became popular because there was nothing
like it on the market before", it is just untrue.

>Had Delphi been first (which it couldn't have
>been), then things might be very different today.

(in)famous marketing thing, you know ;) OS/2 Warp went into public half
year before Win95, so..?