Hello,
2009/7/13 luvspython:
I have a fairly large application using WxPython. It includes a
CustomTreeCtrl object. The tree's root node has about 300 children.
Each child of the root node has 1 (but occasionally 2 or 3) children,
and each of those has 4 children. All together there are slightly
over 3000 nodes in the tree.
The application reads, digests, and manipulates data from two .75GB
databases, creates a FlatNotebook ctrl with 8 pages, each with a
fairly complex display, a portion of 1 of which has a CustomTreeCtrl
object. All that setup takes about 20 cpu-seconds. Then a single
ExpandAll of the tree ctrl consumes over 7 MINUTES of cpu time !!
FWIW, a simple Expand or Collapse of the root node is relatively
fast. But iterating through nodes using Expand or Collapse is
horribly slow. That's why I came to do the test of a single
ExpandAll.
Below is Python profiler data. The data represents all the
initialization and setup done once by my application, and then a
SINGLE ExpandAll of the CustomTreeCtrl. Scroll down in the profiler
information to get to the data for CustomTreeCtrl. Note that some of
the routines internal to CustomTreeCtrl are called millions of times.
It would be very helpful if this can be resolved.
OS Platform, wxPython version and small runnable sample app which
reproduces the problem, please, as indicated here:
http://wiki.wxpython.org/MakingSampleApps
Other than that, it may either be that CustomTreeCtrl is inherently
slow with many children (which doesn't happen with my applications,
anyway): if this is the case, then don't use CustomTreeCtrl but a
simple wx.TreeCtrl. Or it may be that your design is flawed.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
Hi,
2009/7/13 luvspython:
Andrea,
Yes, I know all that about creating small sample apps and that's
generally what I do. But in this case it would be a huge nuisance,
and it was my hope the profiler info would clearly persuade you that
there is a problem. It showed exactly 1 call to ExpandAll, which
consumed over 7 minutes of cpu time, so it's very hard to see how that
could be my design problem -- especially since I created the tree by
calls to its methods.
"MakingSampleApps" is more than a webpage filled with good
suggestions: it is a philosophy, It doesn't always mean "strip down
your app until you can reproduce the problem in a sample you can send
to the list". Those who understand this philosophy would say:
1) I think there is a problem with the ExpandAll method in CustomTreeCtrl;
2) So, I will make a simple app with a frame, a CustomTreeCtrl with
3000 items in it and nothing else;
3) I will call ExpandAll() somewhere in my code and report the results
to the list.
4) If my gut feeling is correct, I would have saved 10 minutes of
Andrea's life (or Robin's or others' lives) by providing a sample that
can be ready hacked and can lead to a quick solution.
<rant>
Those who don't follow this philosophy. either do not care about the
time we (and especially Robin) have put/put in the project or simply
do not see the point/do not have time/do not have the will to create a
sample.Reporting that "there is a problem somewhere in ExpandAll in
CustomTreeCtrl" is like going to the garage mechanic and say: "my car
is broken: fix it".
</rant>
Now, it took me exactly 10 minutes to create the attached sample,
which demonstrates the problem (although it takes 2 minutes on my PC,
it's still waaaay too slow). It turns out that ExpandAll calls
Expand() on every children, which in turn sends out a
wx.EV_TREE_ITEM_EXPANDING/ED event and recalculates all items
positions. This is not good. I have implemented a simple workaround
and it will be in SVN tomorrow, which reduces the computation time
from 2 minutes to 0.07 seconds on my laptop.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
CTTest.py (1.42 KB)
1 Like
Hi Andrea,
Now, it took me exactly 10 minutes to create the attached sample,
which demonstrates the problem (although it takes 2 minutes on my PC,
it's still waaaay too slow). It turns out that ExpandAll calls
Expand() on every children, which in turn sends out a
wx.EV_TREE_ITEM_EXPANDING/ED event and recalculates all items
positions. This is not good. I have implemented a simple workaround
and it will be in SVN tomorrow, which reduces the computation time
from 2 minutes to 0.07 seconds on my laptop.
On a sort of related note, I had a similar issue with
CustomerTreeCtrl/HyperTreeCtrl. Both controls lack a SelectAll method.
I implemented that myself my iterating over all the items and
selecting them one by one. But that creates the same issue as
described above, the sending of a lot of events. I managed to work
around it by ignoring events while doing my SelectAll, but it would be
nice to have a proper SelectAll method.
Cheers, Frank
ยทยทยท
2009/7/13 Andrea Gavana <andrea.gavana@gmail.com>:
Hello Andrea:
I agree with this philosophy completely. Whenever I have a problem
which I think may be a bug in wx or one of its libs, I am reluctant to
waste the developer's time on it until I have a sample app that
removes all possible extraneous causes, and is a quick, hackable test
bed for the developer. Thanks for all your valuable contributions to
the community.
ยทยทยท
On Mon, Jul 13, 2009 at 4:55 PM, Andrea Gavana<andrea.gavana@gmail.com> wrote:
"MakingSampleApps" is more than a webpage filled with good
suggestions: it is a philosophy, It doesn't always mean "strip down
your app until you can reproduce the problem in a sample you can send
to the list". Those who understand this philosophy would say:
1) I think there is a problem with the ExpandAll method in CustomTreeCtrl;
2) So, I will make a simple app with a frame, a CustomTreeCtrl with
3000 items in it and nothing else;
3) I will call ExpandAll() somewhere in my code and report the results
to the list.
4) If my gut feeling is correct, I would have saved 10 minutes of
Andrea's life (or Robin's or others' lives) by providing a sample that
can be ready hacked and can lead to a quick solution.
--
Best Regards,
Michael Moriarity
Hi,
2009/7/13 Andrea Gavana:
Hi,
2009/7/13 luvspython:
Andrea,
Yes, I know all that about creating small sample apps and that's
generally what I do. But in this case it would be a huge nuisance,
and it was my hope the profiler info would clearly persuade you that
there is a problem. It showed exactly 1 call to ExpandAll, which
consumed over 7 minutes of cpu time, so it's very hard to see how that
could be my design problem -- especially since I created the tree by
calls to its methods.
"MakingSampleApps" is more than a webpage filled with good
suggestions: it is a philosophy, It doesn't always mean "strip down
your app until you can reproduce the problem in a sample you can send
to the list". Those who understand this philosophy would say:
1) I think there is a problem with the ExpandAll method in CustomTreeCtrl;
2) So, I will make a simple app with a frame, a CustomTreeCtrl with
3000 items in it and nothing else;
3) I will call ExpandAll() somewhere in my code and report the results
to the list.
4) If my gut feeling is correct, I would have saved 10 minutes of
Andrea's life (or Robin's or others' lives) by providing a sample that
can be ready hacked and can lead to a quick solution.
<rant>
Those who don't follow this philosophy. either do not care about the
time we (and especially Robin) have put/put in the project or simply
do not see the point/do not have time/do not have the will to create a
sample.Reporting that "there is a problem somewhere in ExpandAll in
CustomTreeCtrl" is like going to the garage mechanic and say: "my car
is broken: fix it".
</rant>
Now, it took me exactly 10 minutes to create the attached sample,
which demonstrates the problem (although it takes 2 minutes on my PC,
it's still waaaay too slow). It turns out that ExpandAll calls
Expand() on every children, which in turn sends out a
wx.EV_TREE_ITEM_EXPANDING/ED event and recalculates all items
positions. This is not good. I have implemented a simple workaround
and it will be in SVN tomorrow, which reduces the computation time
from 2 minutes to 0.07 seconds on my laptop.
A new version of CustomTreeCtrl is now available in SVN with the fix
proposed above.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
Hi Frank,
2009/7/13 Frank Niessink:
Hi Andrea,
Now, it took me exactly 10 minutes to create the attached sample,
which demonstrates the problem (although it takes 2 minutes on my PC,
it's still waaaay too slow). It turns out that ExpandAll calls
Expand() on every children, which in turn sends out a
wx.EV_TREE_ITEM_EXPANDING/ED event and recalculates all items
positions. This is not good. I have implemented a simple workaround
and it will be in SVN tomorrow, which reduces the computation time
from 2 minutes to 0.07 seconds on my laptop.
On a sort of related note, I had a similar issue with
CustomerTreeCtrl/HyperTreeCtrl. Both controls lack a SelectAll method.
I implemented that myself my iterating over all the items and
selecting them one by one. But that creates the same issue as
described above, the sending of a lot of events. I managed to work
around it by ignoring events while doing my SelectAll, but it would be
nice to have a proper SelectAll method.
I have implemented it in the SVN version, would you mind to check if
it works correctly? It should be working for CustomTreeCtrl and
HyperTreeList.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
ยทยทยท
2009/7/13 Andrea Gavana <andrea.gavana@gmail.com>:
I dropped the latest version of CustomTreeCtrl and HyperTreeList into
Task Coach:
- SelectAll is much faster now, thanks.
- All unittests pass, great.
One glitch:
- Column headers disappeared. I had to add an explicit "&
~hypertreelist.TR_NO_HEADERS" to the style to get them back, even
though I'm including wx.TR_DEFAULT_STYLE in the styles.
Cheers, Frank
ยทยทยท
2009/7/14 Andrea Gavana <andrea.gavana@gmail.com>:
I have implemented it in the SVN version, would you mind to check if
it works correctly? It should be working for CustomTreeCtrl and
HyperTreeList.
While I'm testing: I see a CustomTreeCtrl.GetItemType, but no
corresponding SetItemType?
Cheers, Frank
ยทยทยท
2009/7/14 Frank Niessink <frank@niessink.com>:
2009/7/14 Andrea Gavana <andrea.gavana@gmail.com>:
I have implemented it in the SVN version, would you mind to check if
it works correctly? It should be working for CustomTreeCtrl and
HyperTreeList.
I dropped the latest version of CustomTreeCtrl and HyperTreeList into
Task Coach:
- SelectAll is much faster now, thanks.
- All unittests pass, great.
One glitch:
- Column headers disappeared. I had to add an explicit "&
~hypertreelist.TR_NO_HEADERS" to the style to get them back, even
though I'm including wx.TR_DEFAULT_STYLE in the styles.