MantisBT - Open CASCADE
View Issue Details
0030165Open CASCADE[OCCT] OCCT:Foundation Classespublic2018-09-26 20:442019-03-05 10:12
kgv 
bugmaster 
normalfeature 
closedwon't fix 
 
[OCCT] 7.4.0 
0030165: Foundation Classes, TColStd_PackedMapOfInteger - provide flag for pre-allocating map of fixed size
Currently TColStd_PackedMapOfInteger behaves like a normal map - it dynamically resized the array of buckets and re-allocates each bucket after clearing the map.

In some scenarios memory allocation might be a performance bottleneck, so that alternative approach might be considered - preserving map size with pessimistic scenario (number of buckets each to maximum integer key in the map, so that HashCode() would not truncate value).
No tags attached.
Issue History
2018-09-26 20:44kgvNew Issue
2018-09-26 20:44kgvAssigned To => abv
2018-09-26 22:59gitNote Added: 0079422
2018-09-26 23:02kgvRelationship addedrelated to 0030161
2018-10-02 15:18abvNote Added: 0079601
2018-10-02 15:36kgvNote Added: 0079605
2018-10-02 15:43kgvNote Added: 0079606
2019-03-02 23:35kgvNote Added: 0082537
2019-03-02 23:35kgvAssigned Toabv => bugmaster
2019-03-02 23:35kgvStatusnew => feedback
2019-03-02 23:35kgvResolutionopen => won't fix
2019-03-05 10:12bugmasterStatusfeedback => closed

Notes
(0079422)
git   
2018-09-26 22:59   
Branch CR30165 has been created by kgv.

SHA-1: 979f4e631ce1c8c8f7a3bfc057028dc284c98a76


Detailed log of new commits:

Author: kgv
Date: Wed Sep 26 22:11:59 2018 +0300

    TColStd_PackedMapOfInteger::SparseAllocation() - added new flag managing memory allocation scheme between map style and array style.

Author: kgv
Date: Wed Sep 26 17:10:30 2018 +0300

    0030165: Foundation Classes, TColStd_PackedMapOfInteger - provide flag for pre-allocating map of fixed size
    
    TCollection_BasicMap has been merged into TColStd_PackedMapOfInteger.
    TColStd_PackedMapOfInteger has been cleaned up from unsafe type casts.
(0079601)
abv   
2018-10-02 15:18   
Does it help in some known scenario?
(0079605)
kgv   
2018-10-02 15:36   
This option gives only up to ~ 15% performance boost within my local tests.
So that TColStd_BitField is expected to be better for extreme performance improvement, but this should be checked considering real bottlenecks in the whole process.

On AIS_PointCloud:
pload MODELING VISUALIZATION
restore dem.brep d
tcopy -mesh d d2
compound d d2 c
trinfo c
vclear
vinit View1
vpointcloud p c
vfit
vzoom 0.5
chrono t reset; chrono t start
vselmode p 1 1
chrono t stop; chrono t show


chrono t reset; chrono t start
vmoveto 250 250
chrono t stop; chrono t show

vselect 0 0
chrono t reset; chrono t start
vselect 10 10 400 400
chrono t stop; chrono t show

vselect 0 0
chrono t reset; chrono t start
vselect 100 100 250 250
chrono t stop; chrono t show


Results for rectangular selection
(includes time for highlighting selected points):
This shape contains 21807496 triangles.
                    10916172 nodes.

OLD map:
Elapsed time: 0 Hours 0 Minutes 0.934069483563 Seconds
NEW map:
Elapsed time: 0 Hours 0 Minutes 0.834714741781 Seconds
OLD map parallel:
Elapsed time: 0 Hours 0 Minutes 0.709464338026 Seconds
NEW map parallel:
Elapsed time: 0 Hours 0 Minutes 0.676648563385 Seconds
(0079606)
kgv   
2018-10-02 15:43   
The code clean up of TColStd_PackedMapOfInteger also gives a tiny boost: 0.966598009458 s -> 0.934069483563 s of rectangular points selection with highlighting.
In particular, current TColStd_PackedMapOfInteger implementation uses unneeded inheritance from Standard_Transient for map nodes.
(0082537)
kgv   
2019-03-02 23:35   
Please close the issue.