View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0028636 | Open CASCADE | OCCT:Coding | public | 2017-04-06 11:19 | 2017-09-29 16:25 |
Reporter | Assigned To | bugmaster | |||
Priority | normal | Severity | tweak | ||
Status | closed | Resolution | fixed | ||
Product Version | 7.1.0 | ||||
Target Version | 7.2.0 | Fixed in Version | 7.2.0 | ||
Summary | 0028636: Optimisation of gp_* classes in order to avoid unnecesary calling gp_Dir* constructors with normalisation | ||||
Description | Many constructors of gp_* classes contains fields asgp_Dir v and v is initialized by the value (1, 0). While such initialization, copy-constructor is used, which computes expression such as sqrt(1*1+0*0) and spent much time. The main idea of optimization is to avoid using constructors with normalization for trivial cases. P.S. This problem has been observed while fixing performance degradation in the issue #28211. Though this was very little hot spot (about 1-3%) it was decided to correct such obvious issue. | ||||
Steps To Reproduce | New test case is not required. | ||||
Tags | No tags attached. | ||||
Test case number | Not needed | ||||
|
Branch CR28636 has been created by msv. SHA-1: 75da7906240cfc6663a455a38912cb4885cc6898 Detailed log of new commits: Author: msv Date: Thu Apr 6 15:28:26 2017 +0300 0028636: Optimisation of gp_* classes in order to avoid unnecesary calling gp_Dir* constructors with normalisation The improvement is concluded in replacement of calls to gp_Dir2d(1,0) with calls to gp_Dir2d(void), and calls to gp_Dir2d(0,1) to gp_Dir2d(gp::DY2d()). Thus we avoid sqrt() that is called from within gp_Dir2d(double,double). The same is with direction in 3D space. |
|
Dear Eugeny, please review the fix. |
|
Mikhail, please provide results of your performance measurements showing the positive effect of the change. |
|
Reviewed. |
|
Test case is to be created. |
|
Branch CR28636_1 has been created by msv. SHA-1: 7c022c420d2bb05933c258b00b07fcfefde77b36 Detailed log of new commits: Author: msv Date: Thu Apr 6 15:28:26 2017 +0300 0028636: Optimisation of gp_* classes in order to avoid unnecesary calling gp_Dir* constructors with normalisation The improvement is concluded in replacement of calls to gp_Dir2d(1,0) with calls to gp_Dir2d(void). Thus we avoid sqrt() that is called from within gp_Dir2d(double,double). The same is with direction in 3D space. Test cases have been created to check the improvement. |
|
Branch CR28636_1 has been updated forcibly by msv. SHA-1: e57e1e343ba81e3975fb089716ebc61016988d89 |
|
I have created synthetic test case to call default constructor in a loop. The code is the following:Standard_Integer nbRep = 1000000; Standard_Real dummy = 0.; for (; nbRep > 0; nbRep--) { for (Standard_Integer n = 100; n > 0; n--) { gp_Ax2d anAx1, anAx2; anAx2.Mirror(gp_Pnt2d(1., 1.)); dummy += anAx1.Direction().XY() * anAx2.Direction().XY(); } } The following is comparison of CPU time spent in the fix vs master: 0.46875/1.203125 Dear Kirill, please review. |
|
-inline gp_Ax3::gp_Ax3() : vydir(0.,1.,0.), vxdir(1.,0.,0.) +inline gp_Ax3::gp_Ax3() + : + vydir(0.,1.,0.) + // vxdir(1.,0.,0.) use default ctor of gp_Dir, as it creates the same dir(1,0,0) Both vydir and vxdir are gp_Dir, but patch modifies initialization only of vxdir - why? Does initialization of vydir(0.,1.,0.) somehow avoid normalization while vxdir(1.,0.,0.) does not? Patch looks incomplete if it is intended to improve performance. There might be many other options for making gp_Dir/gp_Dir2d constructors for standard directions without normalization: - Extra bool flag to prevent normalization. Can be useful also in context when normalization is performed in advance (especially taking into account gp_Dir throws exception on division by zero). - Constructor with constexpr looks like a good example what constexpr is designed for. - Constructor taking enum with standard directions. - Template constructor/method as alternative to constexpr. |
|
Branch CR28636_2 has been created by msv. SHA-1: 9c1a3136a17e3647253a6ee625ed2279428c7031 Detailed log of new commits: Author: msv Date: Thu Apr 6 15:28:26 2017 +0300 0028636: Optimisation of gp_* classes in order to avoid unnecesary calling gp_Dir* constructors with normalisation The improvement is concluded in replacement of calls to gp_Dir2d(1,0) with calls to gp_Dir2d(void). Thus we avoid sqrt() that is called from within gp_Dir2d(double,double). The same is with direction in 3D space. |
|
Please review again. |
|
Please test the patch. |
|
Dear BugMaster, Branch CR28636_2 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested. SHA-1: 9c1a3136a17e3647253a6ee625ed2279428c7031 Number of compiler warnings: occt component: Linux: 0 (0 on master) Windows: 0 (0 on master) MasOS: 0 (0 on master) products component: Linux: 64 Windows: 0 MacOS: 1198 Regressions/Differences: Not detected Testing cases: Not needed Testing on Linux: Total MEMORY difference: 91799412 / 91395470 [+0.44%] Total CPU difference: 19636.610000000222 / 19613.34000000024 [+0.12%] Testing on Windows: Total MEMORY difference: 57855660 / 57855806 [-0.00%] Total CPU difference: 18299.525703898533 / 18063.40259029849 [+1.31%] |
|
Branch CR28636 has been deleted by kgv. SHA-1: 75da7906240cfc6663a455a38912cb4885cc6898 |
|
Branch CR28636_1 has been deleted by kgv. SHA-1: e57e1e343ba81e3975fb089716ebc61016988d89 |
|
Branch CR28636_2 has been deleted by kgv. SHA-1: 9c1a3136a17e3647253a6ee625ed2279428c7031 |
occt: master 0bd575a7 2017-04-06 12:28:26
Committer: bugmaster Details Diff |
0028636: Optimisation of gp_* classes in order to avoid unnecesary calling gp_Dir* constructors with normalisation The improvement is concluded in replacement of calls to gp_Dir2d(1,0) with calls to gp_Dir2d(void). Thus we avoid sqrt() that is called from within gp_Dir2d(double,double). The same is with direction in 3D space. |
Affected Issues 0028636 |
|
mod - src/gp/gp_Ax2.lxx | Diff File | ||
mod - src/gp/gp_Ax22d.lxx | Diff File | ||
mod - src/gp/gp_Ax2d.lxx | Diff File | ||
mod - src/gp/gp_Ax3.lxx | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2017-04-06 11:19 |
|
New Issue | |
2017-04-06 11:19 |
|
Assigned To | => msv |
2017-04-06 11:20 |
|
Description Updated | |
2017-04-06 12:32 |
|
Status | new => assigned |
2017-04-06 12:32 |
|
Product Version | => 7.1.0 |
2017-04-06 15:28 | git | Note Added: 0064981 | |
2017-04-06 15:29 |
|
Note Added: 0064982 | |
2017-04-06 15:29 |
|
Assigned To | msv => emv |
2017-04-06 15:29 |
|
Status | assigned => resolved |
2017-04-06 15:42 |
|
Note Added: 0064984 | |
2017-04-06 15:49 |
|
Note Added: 0064988 | |
2017-04-06 15:49 |
|
Assigned To | emv => bugmaster |
2017-04-06 15:49 |
|
Status | resolved => reviewed |
2017-04-06 16:14 |
|
Assigned To | bugmaster => apv |
2017-04-06 16:15 |
|
Note Added: 0064994 | |
2017-04-06 16:15 |
|
Assigned To | apv => msv |
2017-04-06 16:15 |
|
Status | reviewed => assigned |
2017-04-07 19:44 | git | Note Added: 0065056 | |
2017-04-07 20:01 | git | Note Added: 0065057 | |
2017-04-07 20:08 |
|
Note Added: 0065058 | |
2017-04-07 20:08 |
|
Assigned To | msv => kgv |
2017-04-07 20:08 |
|
Status | assigned => resolved |
2017-04-07 20:25 | kgv | Note Added: 0065059 | |
2017-04-07 20:25 | kgv | Assigned To | kgv => msv |
2017-04-07 20:25 | kgv | Status | resolved => assigned |
2017-04-07 20:27 | kgv | Note Edited: 0065059 | |
2017-04-07 20:31 | kgv | Note Edited: 0065059 | |
2017-04-09 21:35 | kgv | Note Edited: 0065059 | |
2017-04-10 10:06 |
|
Description Updated | |
2017-04-10 10:13 |
|
Note Edited: 0065058 | |
2017-04-10 10:18 | git | Note Added: 0065071 | |
2017-04-10 10:20 |
|
Note Added: 0065073 | |
2017-04-10 10:20 |
|
Assigned To | msv => kgv |
2017-04-10 10:20 |
|
Status | assigned => resolved |
2017-04-10 10:23 | kgv | Note Added: 0065074 | |
2017-04-10 10:23 | kgv | Assigned To | kgv => bugmaster |
2017-04-10 10:23 | kgv | Severity | minor => tweak |
2017-04-10 10:23 | kgv | Status | resolved => reviewed |
2017-04-10 10:48 |
|
Assigned To | bugmaster => apv |
2017-04-11 12:06 |
|
Test case number | => Not needed |
2017-04-11 12:53 |
|
Note Added: 0065127 | |
2017-04-11 12:53 |
|
Assigned To | apv => bugmaster |
2017-04-11 12:53 |
|
Status | reviewed => tested |
2017-04-14 14:28 | bugmaster | Changeset attached | => occt master 0bd575a7 |
2017-04-14 14:28 | bugmaster | Status | tested => verified |
2017-04-14 14:28 | bugmaster | Resolution | open => fixed |
2017-05-12 11:36 | git | Note Added: 0065956 | |
2017-05-12 11:36 | git | Note Added: 0065957 | |
2017-05-12 11:36 | git | Note Added: 0065958 | |
2017-09-29 16:19 |
|
Fixed in Version | => 7.2.0 |
2017-09-29 16:25 |
|
Status | verified => closed |