-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
getSubObjects/getSubObject interface is very slow #43
Comments
There is indeed some overhead in Part's getSubObject(). But shouldn't affect that much. Can you please post here the script you wrote? I'll take a look. |
The overhead is probably not in the APIs, but in the fact that python have to handle/check very large non-needed entries the API is returning. Here's a PR: Will appreciate your comments if I did something stupid there |
I'm still investigating that direction...
Test failed... Not it takes a bit more time than before :( |
I thought you've already solved problem by reading your comments in that issue page? What is the scope of your finding. Do you want to find certain type of objects in the whole document or from some parent object? |
My feature works, but it takes too long to complete as I wrote in the first post of that issue... |
WOW... |
[Path] Fix python style for initial message (now recognized by updatets.py script)
[Path] Final fix of Path - message during startup (#43)
I'm implementing a feature (in python) for Assembly4 that have to traverse over all the elements in the tree and set Visibility for some of the entries.
I have a not-so-big model, but found that passing all the entries takes lots of time.
Trying to debug and understand why:
Total number of getSubObjects calls was 4189
Total numbers of getSubObject(name, 1) calls was 1909
Total number of time Visibility feature was set was 763 (there are some links to the same part that I will try to recognize and improve the logic).
All that takes about 6.5 seconds on my computer.
I thought the fact that getSubObjects returns only names of the objects and for each there is a need to query the object itself with getSubObject function was a problem, so I've tried to add an API that will do that in C++ code and return the list of the objects with one call. Maybe I did something not that good, but the gain wasn't significant.
Next change was to check the object type before calling the getSubObjects, so the script will handle only App::Part containers.
That lead to the following numbers:
Total number of getSubObjects calls was 289
Total numbers of getSubObject(name, 1) calls was 1909
Total number of time Visibility feature was set was 763.
All that took about 5.5 seconds - a save one 1 second.
That lead me to the obvious conclusion that passing large lists via the API and processing all of them in Python is not efficient, especially when most of the entries are ignored.
How hard will it be to implement a filter in the getSubObjects, by passing a list of object types I would like to get back?
For some calls I need only App::Part, for others I need few types that are used for LCS representation ['PartDesign::CoordinateSystem', 'PartDesign::Plane', 'PartDesign::Line', 'PartDesign::Point'], for some calls I need the body elements...
Maybe there will be needs for other filtering options as well.
Right now for my current implementation I think the TypeId filter will improve the speed drastically.
Can you point me to the needed direction, so I could add such filter and test?
For a start, couldn't find how TypeId property is implemented.
Maybe you have other thoughts in that direction.
Thanks.
The text was updated successfully, but these errors were encountered: