DiscussionsIssue archiveOCCT:Visualization

Archived issue #0026139

AIS_InteractiveContext::Display performance regression

CommunityOCCT:Visualizationclosed25 public notes

Search issues

Description

Displaying AIS_IO now requires more time than earlier. AIS_InteractiveContext::Display spends 95% of time to add AIS_IO to selection manager, 75% of which is spent to find element in NCollection_BaseSequence [see attachments]. NCollection_BaseSequence usage seems to be ineffective to store objects and indexes in SelectMgr_SensitiveEntitySet, because it has a lot of access operations.

Steps to reproduce

test bugs vis bug26139

Additional information

Public activity

25 archived notes

Participants are labeled by their role within this record.

01Author
Replacing NCollection_BaseSequence with std::deque the hotspot has gone and AIS_InteractiveContext::Display has sped up by 2.5x.
02Commenter 3
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Sergey Solomin
Date: Fri Apr 24 23:18:06 2015 +0300

    0026139: AIS_InteractiveContext::Display performance regression
    
    Replacing NCollection_BaseSequence with std::deque

03Author
I've published my changes which give 2.5x speed-up displaying my model.
04Commenter 4
I believe the class SelectMgr_SensitiveSet and around must be refactored:

- there is no sense in maintaining myEntityIdxs sequence, it does not bring anything apart of extra indirection. To sort the objects, you can instead swap them directly in their own container, so that index is always direct.

- vector can be used instead of sequence or deque. When removing element from the set, for efficiency it can be first swapped with the last one, then the last removed

- in Swap(), use std::swap()

- class BVH_Set lacks documentation: at a minimum, it must be indicated whether the index is assumed to be 0- or 1-based. Then, I suppose it should be clearly indicated that its entities are going to be re-sorted regularly (this would be a hint to use data structures with fast random access rather than sequences in implementation of descendants). Even description of template arguments T and N is very vague. If I get it right, T is data type to be used for each coordinate (either double or float), and N is dimension of the space (must be either 2 or 3). The same applies to most of the classes in BVH.

05Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: vpa
Date: Tue Apr 28 01:56:35 2015 +0300

    Refactoring of SelectMgr_SensitiveEntitySet
06Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: vpa
Date: Wed May 6 20:49:42 2015 +0300

    Fixed warnings

07Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: vpa
Date: Wed May 6 21:18:43 2015 +0300

    Test case for issue #0026139

08Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: vpa
Date: Wed May 6 21:19:35 2015 +0300

    0026139: AIS_InteractiveContext::Display performance regression
    
    NCollection_Sequence in SelectMgr_SensitiveEntitySet was replaced by data map and vector to provide fast access for BVH
09Commenter 9
Dear Anton,

please review patch from branch CR26139_2.
10Commenter 10
Dear Mikhail,

Reviewed. Please test.

11Commenter 1
12Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: abv
Date: Thu May 7 10:23:53 2015 +0300

    Minor correction

13Commenter 13
Correction pushed to CR26139_2, please re-test
14Commenter 14
Dear Varvara,

There are a lot of regressions detected on Linux during testing of CR26139. Full report will be posted after testing on Windows.
More information about testing on Linux could be found by the following link:
http://occt-tests/CR26139-2-master-occt-64/Debian60-64/summary.html
15Commenter 3
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: vpa
Date: Thu May 7 18:36:16 2015 +0300

    Corrections

16Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: vpa
Date: Thu May 7 18:39:36 2015 +0300

    0026139: AIS_InteractiveContext::Display performance regression
    
    NCollection_Sequence in SelectMgr_SensitiveEntitySet was replaced by indexed data map
17Author
Add Draw test with stl model (send model to Sergey ANIKIN, because model is cannot be attached to the tracker). I've provided Amplifier screen shots with and without std::deque usage.

Occ release with deb info (last git):
Draw[4]> pload ALL
vinit
chrono
meshfromstl mesh [user path removed]/RL_Extern_NXSpeedBoat.stl
1
Draw[5]> Driver1/Viewer1/View1
Draw[6]> Chronometers activated.

Draw[7]> Nodes : 117256
Elements : 235534
Construction is finished
Reading OK...
Data source is created successful
MeshVS_Mesh is created successful

Elapsed time: 0 Hours 1 Minutes 0.053043 Seconds
CPU user time: 59.64 seconds
CPU system time: 0.14 seconds
Draw[8]>
Elapsed time: 0 Hours 0 Minutes 5.69999999982e-05 Seconds



Occ release with deb info (last git + std::deque usage):
Draw[4]> pload ALL
vinit
chrono
meshfromstl mesh [user path removed]/RL_Extern_NXSpeedBoat.stl1
Draw[5]> Driver1/Viewer1/View1
Draw[6]> Chronometers activated.

Draw[7]>
Nodes : 117256
Elements : 235534
Construction is finished
Reading OK...
Data source is created successful
MeshVS_Mesh is created successful

Elapsed time: 0 Hours 0 Minutes 3.682833 Seconds
CPU user time: 3.52 seconds
CPU system time: 0.15 seconds
Draw[8]> 3D View - Driver1/Viewer1/View1 was deleted.
exit
18Author
Hello, I've found Ncollection_BaseSequence is also bottleneck in OpenGl_BHVClipPrimitives. It became important when big models was displayed. See Attachment 2 (PNG).
19Commenter 3
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: Sergey Solomin
Date: Fri May 8 13:36:13 2015 +0300

    0026139: AIS_InteractiveContext::Display performance regression
    
    Replacing NCollection_BaseSequence with std::deque
20Commenter 3
Branch [archived branch] has been deleted by Author.

[revision removed]
21Commenter 21
Dear Author,

please take a look at patch in branch CR26139_3, where NCollection_Sequence was replaced by NCollecion_IndexedMap. That change allowed to reduce display time up to 2.5 times and remove time up to 270 times (in comparison to OCCT v6.9.0 beta2). Note that dequeue solution you proposed requires iteration through collection to remove elements, meanwhile indexed map allows to do it in constant time.

Regarding to performance of OpenGl_BHVClipPrimitives, the bug will be fixed within issue #0026199. Thanks for your contribution! :)

22Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
23Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
24Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
25Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]

Related records