 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gabriel Corneanu Guest
|
Posted: Fri Oct 07, 2005 5:57 pm Post subject: FastObj (ex ObjPool) |
|
|
I finally got around CVS, but I also posted to .attachments.
I added several init strategies (ASM experts might try to make them better).
For the little test I included (simple loop "TestClass.Create.Free"), the
results are very very good.
Can anyone test using a more CPU intensive application?
All report are much appreciated.
Strange things:
Without FastMM, it makes things slower!! I tried, but didn't find any clue
about it.
I just calling GetMem (just like the original NewInstance does). Then the
init operations should be optimized (as seen when using FastMM).
Please tell me what's going on. The only idea would be MM alignment ?
To make things even stranger, if I create the test class once in
initialization section, then it's faster again! But not anymore if done
later (in FormCreate). There is some commented code in the test project.
Thanks,
Gabriel
|
|
| Back to top |
|
 |
Eric Grange Guest
|
Posted: Sat Oct 08, 2005 8:43 am Post subject: Re: FastObj (ex ObjPool) |
|
|
I would reckon the test isn't very signifiant because it is doubly
alignment bound: once because it's the same instance that gets allocated,
setup and freed all the time, and second because the object is large,
which makes the fill to zero critical (and the fill is alignment-dependent).
In that particular case of alloc/free sequence of exactly the same
block size, Borland MM (like FastMM) will return you the same block
of memory repeatedly (BorlandMM has shortcuts for that kind of
situation, so it's kind of a 'Best Case' situation).
For my test I allocate a whole lot of objects in a static array,
and the free them, this makes alignment issues for a particular
instance less likely (unless the instance size is a multiple of
the alignment size). Will try posting it sometime later today.
Eric
|
|
| Back to top |
|
 |
Gabriel Corneanu Guest
|
Posted: Sun Oct 09, 2005 11:56 am Post subject: Re: FastObj (ex ObjPool) |
|
|
I added a simple cleanup optimization as well, building a concatenated list
of dynamic fields to be finalized. Classes with a lot of parents (and with
dynamic fields on several levels) should benefit most, as well as classes
with parents but without any dynamic fields.
I agree, real tests are needed for this. But I hope there would really be
some performance gain.
The virtual tree example from Adem fails on my machine (D2005) if compiled
with optimization and assertions (without fastobj unit), and I had no time
to verify it.
See .attachments.
Gabriel
|
|
| Back to top |
|
 |
Charalabos Michael Guest
|
Posted: Sun Oct 09, 2005 9:37 pm Post subject: Re: FastObj (ex ObjPool) |
|
|
Hello Gabriel,
| Quote: | All report are much appreciated.
|
With FastMM4 it reports memory leaks when using your FastObj.
Like:
Stack trace of when this block was allocated (return addresses):
402EA4 [system.pas][System][@GetMem][2439]
435D7A
[FastObj.pas][FastObj][TObjectAccelerator.NewInstanceNotInterfacedLargeSize][400]
4047A2 [system.pas][System][@ClassCreate][9019]
5F8A18 [dbisamen][TDataLocale.Create]
5F811D [dbisamen][DataEngine]
5F9F59 [dbisamen][LocalesCallback]
7C837F9E [EnumSystemLocalesA]
7C837ED7 [EnumSystemLocalesA]
7C80A409 [CompareStringW]
--
Charalabos Michael - [Creation Power] - http://www.creationpower.com -
http://www.creationpower.gr
|
|
| Back to top |
|
 |
Gabriel gabrielcorneanuAT Guest
|
Posted: Mon Oct 10, 2005 7:23 am Post subject: Re: FastObj (ex ObjPool) |
|
|
Charalabos Michael <chmichael (AT) _-_no_-_creationpower_-_spam_-_ (DOT) com> wrote:
| Quote: |
Hello Gabriel,
All report are much appreciated.
With FastMM4 it reports memory leaks when using your FastObj.
Like:
Stack trace of when this block was allocated (return addresses):
402EA4 [system.pas][System][@GetMem][2439]
435D7A
[FastObj.pas][FastObj][TObjectAccelerator.NewInstanceNotInterfacedLargeSize][400]
4047A2 [system.pas][System][@ClassCreate][9019]
5F8A18 [dbisamen][TDataLocale.Create]
5F811D [dbisamen][DataEngine]
5F9F59 [dbisamen][LocalesCallback]
7C837F9E [EnumSystemLocalesA]
7C837ED7 [EnumSystemLocalesA]
7C80A409 [CompareStringW]
--
Charalabos Michael - [Creation Power] - http://www.creationpower.com -
http://www.creationpower.gr
|
Is there more than one leak?
Did you try the same without fastobj unit?
I don't know how could I test this, without having the specified unit. I will still try to search for any possibility.
Gabriel
|
|
| Back to top |
|
 |
Charalabos Michael Guest
|
Posted: Mon Oct 10, 2005 8:51 am Post subject: Re: FastObj (ex ObjPool) |
|
|
Hello Gabriel,
| Quote: | Is there more than one leak?
|
Yes
| Quote: | Did you try the same without fastobj unit?
|
Yes, no leaks detected
| Quote: | I don't know how could I test this, without having the
specified unit. I will still try to search for any possibility.
|
I'll try to see where the leak occur.
--
Charalabos Michael - [Creation Power] - http://www.creationpower.com -
http://www.creationpower.gr
|
|
| Back to top |
|
 |
Gabriel gabrielcorneanuAT Guest
|
Posted: Mon Oct 10, 2005 9:43 am Post subject: Re: FastObj (ex ObjPool) |
|
|
Charalabos Michael <chmichael (AT) _-_no_-_creationpower_-_spam_-_ (DOT) com> wrote:
| Quote: | Hello Gabriel,
Is there more than one leak?
Yes
Did you try the same without fastobj unit?
Yes, no leaks detected
I don't know how could I test this, without having the
specified unit. I will still try to search for any possibility.
I'll try to see where the leak occur.
--
Charalabos Michael - [Creation Power] - http://www.creationpower.com -
http://www.creationpower.gr
|
This looks like a side effect. Is it possible to trim down a small app that has this leak? I see it uses some external components.
If you say there are more leaks, maybe you find one in a standard unit.
Regards,
Gabriel
|
|
| Back to top |
|
 |
Adem Guest
|
Posted: Mon Oct 10, 2005 2:33 pm Post subject: Re: FastObj (ex ObjPool) |
|
|
Gabriel Corneanu wrote:
| Quote: | The virtual tree example from Adem fails on my machine (D2005)
if compiled with optimization and assertions (without fastobj
unit), and I had no time to verify it.
|
While that VT code is refactored to use objects, hence potentially
usable with D2005 and beyond, I haven't tested it in anything other
than D7.
Could you try to see if it works in D7? [I am still without a working
system to do that myself]
Cheers,
Adem
|
|
| Back to top |
|
 |
Gabriel Corneanu Guest
|
Posted: Mon Oct 10, 2005 5:00 pm Post subject: Re: FastObj (ex ObjPool) |
|
|
"Adem" <adembaba (AT) excite (DOT) com> wrote
| Quote: | Gabriel Corneanu wrote:
The virtual tree example from Adem fails on my machine (D2005)
if compiled with optimization and assertions (without fastobj
unit), and I had no time to verify it.
While that VT code is refactored to use objects, hence potentially
usable with D2005 and beyond, I haven't tested it in anything other
than D7.
Could you try to see if it works in D7? [I am still without a working
system to do that myself]
|
I do not have a D7 installed right now.
There is a runtime error if you go on the first demo. I don't remember very
well, but if compiled without optimizations it worked.
Gabriel
|
|
| Back to top |
|
 |
Gabriel Corneanu Guest
|
Posted: Mon Oct 10, 2005 5:35 pm Post subject: Re: FastObj (ex ObjPool) |
|
|
"Adem" <adembaba (AT) excite (DOT) com> wrote
| Quote: | Gabriel Corneanu wrote:
The virtual tree example from Adem fails on my machine (D2005)
if compiled with optimization and assertions (without fastobj
unit), and I had no time to verify it.
While that VT code is refactored to use objects, hence potentially
usable with D2005 and beyond, I haven't tested it in anything other
than D7.
Could you try to see if it works in D7? [I am still without a working
system to do that myself]
Cheers,
Adem
|
I tried a little more. It happens when compiling with optimizations ON. If
using assertions, you'll also get the reason for the error (in
TVirtualNode.GetNextVisible, the first assert).
Looking at the stack at this point, it seems some messages coming when the
tree/form is not yet properly initialized. The interesting point is WMSize
in TBaseVirtualTree.
Visible is true on the form; it tries to show it after creating, before
setting the parent. I set visible to false, but it still comes a little
later.
Without optimizations, it just doesn't come to this point.
I hope it helps.
However, without optimizations fastmm does not report any memory leak.
Gabriel
|
|
| Back to top |
|
 |
Adem Guest
|
Posted: Mon Oct 10, 2005 10:28 pm Post subject: Re: FastObj (ex ObjPool) |
|
|
Gabriel Corneanu wrote:
| Quote: | I tried a little more.
|
[...]
Yes, it did. You have unearthed a subtle bug.
Thanks.
I have now corrected that bug.
From my tests, the previous version, without FastObj took
46 ms to create 10,000 items. Now, with FastObj, it takes
only 16 ms. A three fold improvement.
When freeing those nodes, the old version takes 219 ms whereas
the FastObj version takes 156 ms.
This is of course an improvement, but not quite as much as
what we gained in creating the nodes.
I'll leave you to comment, or improve further on that.
BTW, the files are being uploaded to attachments.
Cheers,
Adem
|
|
| Back to top |
|
 |
Adem Guest
|
Posted: Mon Oct 10, 2005 11:03 pm Post subject: Re: FastObj (ex ObjPool) |
|
|
I think I should elaborate a little on the figures below:
| Quote: | Now, with FastObj, it takes only 16 ms. A three fold improvement.
|
This is as good as Mike's original version which used pointers
instead of objects.
| Quote: | When freeing those nodes, the FastObj version takes 156 ms.
|
This is way too long.
Mike's original version takes only a *quarter* of that or less.
i.e upto 46 ms. While the minimum I have seen is 31 ms.
Could you guys look into the part of FastObj code that handles
the freeing.
Cheers,
Adem
|
|
| Back to top |
|
 |
Gabriel gabrielcorneanuAT Guest
|
Posted: Tue Oct 11, 2005 9:03 am Post subject: Re: FastObj (ex ObjPool) |
|
|
"Adem" <adembaba (AT) excite (DOT) com> wrote:
| Quote: |
I think I should elaborate a little on the figures below:
Now, with FastObj, it takes only 16 ms. A three fold improvement.
This is as good as Mike's original version which used pointers
instead of objects.
When freeing those nodes, the FastObj version takes 156 ms.
This is way too long.
Mike's original version takes only a *quarter* of that or less.
i.e upto 46 ms. While the minimum I have seen is 31 ms.
Could you guys look into the part of FastObj code that handles
the freeing.
Cheers,
Adem
|
Hi,
There was a small (but with big impact) bug in your delete code. I think the commented line should be moved inside the if statement.
The new fastobj optimization should (in your case) consist of a very simple freemem call.
BTW: the old bug is still there. I can only run with optimizations OFF.
I think there are some notifications coming in a slightly different order; you'll probably find them only on D9.
Regards,
Gabriel
procedure TVirtualNode.DeleteChildren;
.......................
if FTree.FUpdateCount = 0 then begin
......................
FTree.StructureChange(Self, crChildDeleted);
end;
//FTree.StructureChange(Self, crChildDeleted);
|
|
| Back to top |
|
 |
Adem Guest
|
Posted: Tue Oct 11, 2005 11:31 am Post subject: Re: FastObj (ex ObjPool) |
|
|
Hi Gabriel,
| Quote: | There was a small (but with big impact) bug in your delete code. I
think the commented line should be moved inside the if statement.
The new fastobj optimization should (in your case) consist of a
very simple freemem call.
|
Thanks. Having done that, freeing times were halved. I wonder whereelse
will we find similar blunders :-)
| Quote: | BTW: the old bug is still there. I can only run with optimizations OFF.
I think there are some notifications coming in a slightly different order;
you'll probably find them only on D9.
|
OK. I have (grudgingly ) started D9.
When I compile this stuff I don't get anything unusual, but, whem I try
to install it, I receive this:
[Error] VirtualTreesD9D.dpk(32): E2399 Namespace conflicts with unit name
'VTHeaderPopup'
[Fatal Error] VirtualTreesD9.dpk(35): F2084 Internal Error: P514
It appears there is something odd in VirtualTreesD9. Namely, in
VTHeaderPopup.pas unit.
Do you know what it is?
I need to get this out of the way before I can run the project to
see what other bugs are in there.
Cheers,
Adem
|
|
| Back to top |
|
 |
Gabriel gabrielcorneanuAT Guest
|
Posted: Tue Oct 11, 2005 11:52 am Post subject: Re: FastObj (ex ObjPool) |
|
|
"Adem" <adembaba (AT) excite (DOT) com> wrote:
| Quote: |
Thanks. Having done that, freeing times were halved. I wonder whereelse
will we find similar blunders
|
Only half? On my system it goes much faster, but I still have optimizations OFF.
| Quote: | OK. I have (grudgingly ) started D9.
When I compile this stuff I don't get anything unusual, but, whem I try
to install it, I receive this:
[Error] VirtualTreesD9D.dpk(32): E2399 Namespace conflicts with unit name
'VTHeaderPopup'
[Fatal Error] VirtualTreesD9.dpk(35): F2084 Internal Error: P514
It appears there is something odd in VirtualTreesD9. Namely, in
VTHeaderPopup.pas unit.
Do you know what it is?
|
I did not install the package. I just unpacked everything in one folder and compiled. If you don't open a form containing the component it should work; you can still open a form unit but not the form designer (click cancel when asked).
Gabriel
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|