Archived issue #0026936
Drawbacks of inlining in new type system in OCCT 7.0
Description
Recently Roman Lygin has reported several drawbacks of new implementation of OCCT type system, related to inlining of DynamicType() function:
1. Macro DEFINE_STANDARD_RTTI is incompatible with one used in OCCT 6.9.1
Due to this, additional effort will be required on client level to make a code suitable for building with both versions of OCCT
See http://dev.opencascade.org/index.php?q=node/1136
2. Multiple instances of type descriptor functions
Method opencascade::type_instance::get() gets instantiated in every translation unit / library where it (or any of descendant types) is used. This may lead to extra dependencies between libraries.
See http://dev.opencascade.org/index.php?q=node/1137 and #0026913
3. Increased size of binaries
The reduction of the size of OCCT binaries due to templated handles (#0024023) reported in http://dev.opencascade.org/index.php?q=node/1091 (measured using VC++ 10 compiler) finally is not observed in other compilers, and even for VC++ 10 if compared to OCCT 6.9.1. If for VC++ 10 increase is about 1%, more modern compilers (VC++ 14, GCC 5.2.1, CLang 3.6.2) produce about 30% larger binaries.
The most obvious reason of this is multiple instantiation of templates, and in particular DynamicType() function.
1. Macro DEFINE_STANDARD_RTTI is incompatible with one used in OCCT 6.9.1
Due to this, additional effort will be required on client level to make a code suitable for building with both versions of OCCT
See http://dev.opencascade.org/index.php?q=node/1136
2. Multiple instances of type descriptor functions
Method opencascade::type_instance::get() gets instantiated in every translation unit / library where it (or any of descendant types) is used. This may lead to extra dependencies between libraries.
See http://dev.opencascade.org/index.php?q=node/1137 and #0026913
3. Increased size of binaries
The reduction of the size of OCCT binaries due to templated handles (#0024023) reported in http://dev.opencascade.org/index.php?q=node/1091 (measured using VC++ 10 compiler) finally is not observed in other compilers, and even for VC++ 10 if compared to OCCT 6.9.1. If for VC++ 10 increase is about 1%, more modern compilers (VC++ 14, GCC 5.2.1, CLang 3.6.2) produce about 30% larger binaries.
The most obvious reason of this is multiple instantiation of templates, and in particular DynamicType() function.
Steps to reproduce
Compare size of binaries against OCCT 6.9.1
Public activity
19 archived notes
Participants are labeled by their role within this record.
Branch [archived branch] has been created by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sat Nov 28 15:34:35 2015 +0300
0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
Automatic restore of IMPLEMENT_STANDARD_RTTIEXT macro (upgrade -rtti)
Author: Author
Date: Mon Nov 30 07:49:48 2015 +0300
0026936: Drawbacks of inlining in new type system in OCCT 7.0
Restored possibility to have out-of-line implementation of DynamicCast() and STANDART_TYPE():
- Macro STANDARD_TYPE() now resolves to function get_type_descriptor() of the class
- Macro DEFINE_STANDARD_RTTI is split in two:
- DEFINE_STANDARD_RTTI_INLINE works as before, defining DynamicCast() and get_type_descriptor() as inline functions
- DEFINE_STANDARD_RTTIEXT declares DynamicCast() and get_type_descriptor() as exported
- Macro IMPLEMENT_STANDARD_RTTIEXT provides definition of DynamicCast() and get_type_descriptor() for a class
Upgrade script amended to replace DEFINE_STANDARD_RTTI by pair of DEFINE_STANDARD_RTTIEXT / IMPLEMENT_STANDARD_RTTIEXT if source file with the same name as header is found in the same folder, and by DEFINE_STANDARD_RTTI_INLINE if either source is not found or class is defined in the source (i.e. not in header)
[revision removed]
Detailed log of new commits:
Author: Author
Date: Sat Nov 28 15:34:35 2015 +0300
0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
Automatic restore of IMPLEMENT_STANDARD_RTTIEXT macro (upgrade -rtti)
Author: Author
Date: Mon Nov 30 07:49:48 2015 +0300
0026936: Drawbacks of inlining in new type system in OCCT 7.0
Restored possibility to have out-of-line implementation of DynamicCast() and STANDART_TYPE():
- Macro STANDARD_TYPE() now resolves to function get_type_descriptor() of the class
- Macro DEFINE_STANDARD_RTTI is split in two:
- DEFINE_STANDARD_RTTI_INLINE works as before, defining DynamicCast() and get_type_descriptor() as inline functions
- DEFINE_STANDARD_RTTIEXT declares DynamicCast() and get_type_descriptor() as exported
- Macro IMPLEMENT_STANDARD_RTTIEXT provides definition of DynamicCast() and get_type_descriptor() for a class
Upgrade script amended to replace DEFINE_STANDARD_RTTI by pair of DEFINE_STANDARD_RTTIEXT / IMPLEMENT_STANDARD_RTTIEXT if source file with the same name as header is found in the same folder, and by DEFINE_STANDARD_RTTI_INLINE if either source is not found or class is defined in the source (i.e. not in header)
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
Branch [archived branch] has been updated by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Mon Nov 30 19:09:03 2015 +0300
Corrected placement of IMPLEMENT_STANDARD_RTTIEXT macro in platform-specific code
Author: Author
Date: Mon Nov 30 14:53:49 2015 +0300
Eliminate warnings of upgrade tool
Upgrade tool improved to recognize include statements with path prefix, like #include <occt/gp_Pnt.hxx>
Template of CXX file for testing upgrade tool added
[revision removed]
Detailed log of new commits:
Author: Author
Date: Mon Nov 30 19:09:03 2015 +0300
Corrected placement of IMPLEMENT_STANDARD_RTTIEXT macro in platform-specific code
Author: Author
Date: Mon Nov 30 14:53:49 2015 +0300
Eliminate warnings of upgrade tool
Upgrade tool improved to recognize include statements with path prefix, like #include <occt/gp_Pnt.hxx>
Template of CXX file for testing upgrade tool added
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
Branch [archived branch] has been updated by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Tue Dec 1 09:58:56 2015 +0300
0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- samples
Automatic upgrade of samples (upgrade -rtti)
[revision removed]
Detailed log of new commits:
Author: Author
Date: Tue Dec 1 09:58:56 2015 +0300
0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- samples
Automatic upgrade of samples (upgrade -rtti)
Fix pushed to branches CR26936 in OCCT and Products, please review
Please test the patch.
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
Dear Commenter 1,
Branch CR26936 from occt git-repository (and CR26936 from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
[revision removed]
There are following compilation errors:
Linux:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_occt_products_linux/1/parsed_console/
../../../../src/OMFVS/OMFVS_DataSource.cxx:96:84: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFVS_HArray1OfMesh>&' from an rvalue of type 'opencascade::handle<OMFVS_HArray1OfMesh>'
../../../../src/OMFVS/OMFVS_DataSource.cxx:49:25: error: in passing argument 2 of 'Standard_Boolean checkSubMeshes(const opencascade::handle<OMFDS_Mesh>&, opencascade::handle<OMFVS_HArray1OfMesh>&)'
../../../../src/OMFVS/OMFVS_DataSource.cxx:127:84: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFVS_HArray1OfMesh>&' from an rvalue of type 'opencascade::handle<OMFVS_HArray1OfMesh>'
../../../../src/OMFVS/OMFVS_DataSource.cxx:49:25: error: in passing argument 2 of 'Standard_Boolean checkSubMeshes(const opencascade::handle<OMFDS_Mesh>&, opencascade::handle<OMFVS_HArray1OfMesh>&)'
MacOS:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_prepare_build_occt_MacOS/1/parsed_console/
[user path removed]/tools/WOK680/wok_entities/LOC/dev/CR26936-CR26936-occt/src/Standard/Standard_Transient.hxx:115:49: error: typedef redefinition with different types ('opencascade::handle<Standard_Transient> (Standard_Transient)' vs 'Ptr *' (aka 'char **'))
typedef opencascade::handle<Standard_Transient> Handle(Standard_Transient);
^
/usr/include/MacTypes.h:240:41: note: previous definition is here
typedef Ptr * Handle;
^
1 error generated.
Windows:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_occt_mfc_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_java_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_mfc_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_qt_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_training/1/parsed_console/
Branch CR26936 from occt git-repository (and CR26936 from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
[revision removed]
There are following compilation errors:
Linux:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_occt_products_linux/1/parsed_console/
../../../../src/OMFVS/OMFVS_DataSource.cxx:96:84: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFVS_HArray1OfMesh>&' from an rvalue of type 'opencascade::handle<OMFVS_HArray1OfMesh>'
../../../../src/OMFVS/OMFVS_DataSource.cxx:49:25: error: in passing argument 2 of 'Standard_Boolean checkSubMeshes(const opencascade::handle<OMFDS_Mesh>&, opencascade::handle<OMFVS_HArray1OfMesh>&)'
../../../../src/OMFVS/OMFVS_DataSource.cxx:127:84: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFVS_HArray1OfMesh>&' from an rvalue of type 'opencascade::handle<OMFVS_HArray1OfMesh>'
../../../../src/OMFVS/OMFVS_DataSource.cxx:49:25: error: in passing argument 2 of 'Standard_Boolean checkSubMeshes(const opencascade::handle<OMFDS_Mesh>&, opencascade::handle<OMFVS_HArray1OfMesh>&)'
MacOS:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_prepare_build_occt_MacOS/1/parsed_console/
[user path removed]/tools/WOK680/wok_entities/LOC/dev/CR26936-CR26936-occt/src/Standard/Standard_Transient.hxx:115:49: error: typedef redefinition with different types ('opencascade::handle<Standard_Transient> (Standard_Transient)' vs 'Ptr *' (aka 'char **'))
typedef opencascade::handle<Standard_Transient> Handle(Standard_Transient);
^
/usr/include/MacTypes.h:240:41: note: previous definition is here
typedef Ptr * Handle;
^
1 error generated.
Windows:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_occt_mfc_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_java_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_mfc_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_qt_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_training/1/parsed_console/
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
Branch [archived branch] has been updated forcibly by Author.
[revision removed]
[revision removed]
I have pushed correction to branch CR26936 in both OCCT (forced update) and Products, please check
Dear Commenter 1,
Branch CR26936 from occt git-repository (and CR26936 from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
[revision removed]
There are following compilation errors:
Linux:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_occt_products_linux/1/parsed_console/
../../../../src/OMFQM/OMFQM_IMesh.cxx: In member function 'virtual void OMFQM_IMeshFace::Commit(Standard_Real)':
../../../../src/OMFQM/OMFQM_IMesh.cxx:219:81: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFDS_MeshFace>&' from an rvalue of type 'opencascade::handle<OMFDS_MeshFace>'
../../../../src/OMFQM/OMFQM_IMesh.cxx:291:81: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFDS_MeshFace>&' from an rvalue of type 'opencascade::handle<OMFDS_MeshFace>'
make[2]: *** [OMFQM_IMesh.lo] Error 1
Windows:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_training/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_qt_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_mfc_samples_windows/1/parsed_console/
Branch CR26936 from occt git-repository (and CR26936 from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
[revision removed]
There are following compilation errors:
Linux:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_occt_products_linux/1/parsed_console/
../../../../src/OMFQM/OMFQM_IMesh.cxx: In member function 'virtual void OMFQM_IMeshFace::Commit(Standard_Real)':
../../../../src/OMFQM/OMFQM_IMesh.cxx:219:81: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFDS_MeshFace>&' from an rvalue of type 'opencascade::handle<OMFDS_MeshFace>'
../../../../src/OMFQM/OMFQM_IMesh.cxx:291:81: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFDS_MeshFace>&' from an rvalue of type 'opencascade::handle<OMFDS_MeshFace>'
make[2]: *** [OMFQM_IMesh.lo] Error 1
Windows:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_training/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_qt_samples_windows/1/parsed_console/
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_products_mfc_samples_windows/1/parsed_console/
I have pushed correction to CR26936 (products only), please check
Dear Commenter 1,
Branch CR26936 from products git-repository was compiled on Linux and Windows platforms on Release mode.
[revision removed]
There is following compilation error:
Linux:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_occt_products_linux/2/parsed_console/
../../../../src/OMFQM/OMFQM_IMesh.cxx: In member function 'virtual void OMFQM_IMeshFace::Commit(Standard_Real)':
../../../../src/OMFQM/OMFQM_IMesh.cxx:291:81: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFDS_MeshFace>&' from an rvalue of type 'opencascade::handle<OMFDS_MeshFace>'
make[2]: *** [OMFQM_IMesh.lo] Error 1
Branch CR26936 from products git-repository was compiled on Linux and Windows platforms on Release mode.
[revision removed]
There is following compilation error:
Linux:
http://jenkins-test-01.nnov.opencascade.com:8080/view/CR26936-CR26936/job/CR26936-CR26936_build_occt_products_linux/2/parsed_console/
../../../../src/OMFQM/OMFQM_IMesh.cxx: In member function 'virtual void OMFQM_IMeshFace::Commit(Standard_Real)':
../../../../src/OMFQM/OMFQM_IMesh.cxx:291:81: error: invalid initialization of non-const reference of type 'opencascade::handle<OMFDS_MeshFace>&' from an rvalue of type 'opencascade::handle<OMFDS_MeshFace>'
make[2]: *** [OMFQM_IMesh.lo] Error 1
Corrected, sorry
Dear Commenter 1,
Branch CR26936 from occt git-repository (and CR26936 from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
[revision removed]
Number of compiler warnings:
occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 132 (134 on master)
products component :
Linux: 37 (39 on master)
Windows: 0 (0 on master)
Regressions/Differences/Improvements:
No regressions/differences
Testing cases:
Not needed
Testing on Linux:
occt component :
Total MEMORY difference: 92660934 / 91608431 [+1.15%]
Total CPU difference: 19821.519999999455 / 20030.479999999705 [-1.04%]
products component :
Total MEMORY difference: 26267904 / 26094815 [+0.66%]
Total CPU difference: 6519.189999999957 / 6561.399999999947 [-0.64%]
Testing on Windows:
occt component :
Total MEMORY difference: 56252154 / 57831380 [-2.73%]
Total CPU difference: 18802.254526499222 / 20089.44997769905 [-6.41%]
products component :
Total MEMORY difference: 16547830 / 17155904 [-3.54%]
Total CPU difference: 5747.42004219997 / 6301.114391499977 [-8.79%]
There are no differences in images found by testdiff.
Branch CR26936 from occt git-repository (and CR26936 from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested on Release mode.
[revision removed]
[revision removed]
Number of compiler warnings:
occt component :
Linux: 0 (0 on master)
Windows: 0 (0 on master)
MacOS : 132 (134 on master)
products component :
Linux: 37 (39 on master)
Windows: 0 (0 on master)
Regressions/Differences/Improvements:
No regressions/differences
Testing cases:
Not needed
Testing on Linux:
occt component :
Total MEMORY difference: 92660934 / 91608431 [+1.15%]
Total CPU difference: 19821.519999999455 / 20030.479999999705 [-1.04%]
products component :
Total MEMORY difference: 26267904 / 26094815 [+0.66%]
Total CPU difference: 6519.189999999957 / 6561.399999999947 [-0.64%]
Testing on Windows:
occt component :
Total MEMORY difference: 56252154 / 57831380 [-2.73%]
Total CPU difference: 18802.254526499222 / 20089.44997769905 [-6.41%]
products component :
Total MEMORY difference: 16547830 / 17155904 [-3.54%]
Total CPU difference: 5747.42004219997 / 6301.114391499977 [-8.79%]
There are no differences in images found by testdiff.
Branch [archived branch] has been deleted by Commenter 3.
[revision removed]
[revision removed]
Related records