View Issue Details

IDProjectCategoryView StatusLast Update
0023592CommunityOCCT:Foundation Classespublic2021-11-17 16:28
ReporterRoman Lygin Assigned ToRoman Lygin  
PrioritynormalSeverityintegration request 
Status closedResolutionfixed 
PlatformAOSL 
Target Version6.6.0Fixed in Version6.6.0 
Summary0023592: Enabling TBB allocator by default for OCC built with -DHAVE_TBB
DescriptionWithout the fix, OCC built with HAVE_TBB defaults to OS allocator (i.e. malloc(), free()), if the variable MMGT_OPT is not explicitly set to 2. This leads to poorer performance if the variable has not been set by a target application developer or in end-user environment. For library ISV's (e.g. in the case of CAD Exchanger SDK) there is no way to explicitly control the application developer and the end-user environment (when the application integrating the SDK is deployed at end user premise). It is also impossible (due to lack of API) to check which allocator has been actually chosen and to issue a corresponding warning and suggestion messages if it is not TBB the allocator that was chosen.
      
Defaulting to TBB allocator makes sense as this choice has been made during *build* time, when the library developer has deliberately made a decision to use TBB.
      
General note 1: ideally there should be a programmatic way (API) to dynamically set an instance of developer-defined allocator (subclass of Standard_MMgrRoot), e.g. not part of the Standard package. However this will require thorough analysis of feasibility (e.g. how to deal with static objects initialized during load time).
      
General note 2: influencing OCC behavior should be made more possible via API, not only via env vars. Even for application (not only library) developers, API can be more reliable and user-friendly approach. For greater flexibility influencing via env vars should be preserved, of course. But this is a general topic for broader roadmap discussion.
Steps To ReproduceN/A
TagsNo tags attached.
Test case numberNot needed

Relationships

parent of 0024110 assigned Documentation - add description of OCCT_MMGT_OPT_DEFAULT macro parameter 
Not all the children of this issue are yet resolved or closed.

Activities

Roman Lygin

2012-11-28 13:01

developer   ~0022403

Pushed branch CR23592 into the git repository

abv

2012-11-28 13:10

manager   ~0022405

I suggest that separate pre-processor macro (e.g. MMGT_OPT :-) can be added to manipulate default value of this parameter at build time. This would allow manipulating default setting independently of availability of TBB which is indicated by HAVE_TBB macro.

Roman Lygin

2012-11-28 14:46

developer   ~0022410

Andrey, thanks for the idea. Do you suggest something like this:

in Standard.cxx:
#ifndef OCCT_MMGT_OPT_DEFAULT
#define OCCT_MMGT_OPT_DEFAULT 0
#endif

Standard_Integer anAllocId = (aVar = getenv ("MMGT_OPT" )) ? atoi (aVar) : OCCT_MMGT_OPT_DEFAULT;

and the developer could add "OCCT_MMGT_OPT_DEFAULT=2" to CSF_DEFINES env var on Windows or /DOCCT_MMGT_OPT_DEFAULT=2 when configuring on Linux ?

That can make sense indeed.
Of course, respective amendments will have to be made:
a). in ros/env.bat as it currently only checks for HAVE_{TBB|FREEIMAGE|GL2PS} variables.
b). in documentation

Would you like me to do any/all of this or would you take some time to think over ? Please set bug ownership respectively.

abv

2012-11-28 15:14

manager   ~0022411

Yes, that was an idea. If you agree, I suggest you do this (as the most interested person -- this will also ensure that it works as expected for you). For documentation update, just put your proposal in "Additional info..." field -- this should be taken into account by documentation engineers when building Release Notes.

As for update of the env.bat, I suppose it is not really needed, rather we need to document all #defines that affect OCCT builds.. but this is another story

Roman Lygin

2012-11-28 16:59

developer   ~0022415

OK to prepare a modification.

Re preprocessor definitions on Windows: project files use %CSF_DEFINES%. So the developer has to set it prior to opening a project file, but the env.bat resets CSF_DEFINE to empty value and only recognizes HAVE_* vars. Thus, it has to be either be made aware of all supported macros, or to not erase CSF_DEFINE if it was set before launching env.bat. I am inclined to the latter for its greater flexibility.
Let me know if I miss anything.

Roman Lygin

2012-11-29 21:45

developer   ~0022461

Standard.cxx pushed into the git repository.
Macro prefix OCCT has been chosen in accordance with 0022916.

env.bat is not available for modification, so here is a suggested one:
a). either remove these lines:
set "PRODUCTS_DEFINES="
set "CSF_DEFINES="
b).
if not ["%OCCT_MMGT_OPT_DEFAULT"] == [""] (
  set "CSF_DEFINES=OCCT_MMGT_OPT_DEFAULT=%OCCT_MMGT_OPT_DEFAULT%;%CSF_DEFINES%"
  set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DOCCT_MMGT_OPT_DEFAULT=%OCCT_MMGT_OPT_DEFAULT%"
)

Roman Lygin

2012-11-29 22:04

developer   ~0022462

Amendments for the documentation.


1. Into OCC overview / Building Modules chapter:

a). Rebuilding on Windows.

under "use variable CSF_DEFINES to specify additional compiler macros:"

add as a separate bullet:

OCCT_MMGT_OPT_DEFAULT=value (where value is 0, 1 or 2) if you want to specify a memory allocator which will be used in run-time as a fallback in the case if the environment variable MMGT_OPT has not been explicitly defined.

b). Rebuilding on Linux with autoconf, automake and libtool scripts.

under "Additional flags:"

add as a separate bullet:

CXXFLAGS="-DOCCT_MMGT_OPT_DEFAULT=value" (where value is 0, 1 or 2) if you want to specify a memory allocator which will be used in run-time as a fallback in the case if the environment variable MMGT_OPT has not been explicitly defined.

2). Into Foundation Classes User's Guide.

Chapter 2.3.2. Configuring the memory manager

Under "MMGT_OPT:" bullet add as a sub-bullet.

Default value is defined in compile-time with the help of the pre-processor macro OCCT_MMGT_OPT_DEFAULT. If set, it must have a valid numeric value (0, 1 or 2). If not set (by default) then the value 0 will be used.

abv

2012-11-30 13:48

manager   ~0022482

No remarks, please test. Note that I have pushed relevant modification in env.bat file (removal of line setting CSF_DEFINES to empty string) in WOK branch CR23592.

mkv

2012-12-03 14:46

tester   ~0022514

Dear BugMaster,
Branch CR23592 (and products from GIT master) was compiled on Linux and Windows platforms and tested.

Regressions:
Not detected

Improvements:
Not detected

Testing cases:
Not needed

Related Changesets

occt: master a0d8a9fc

2012-12-07 08:08:09

Roman Lygin

Details Diff
0023592: Enabling TBB allocator by default for OCC built with -DHAVE_TBB
Implementation updated based on discussion with OCC team
Affected Issues
0023592
mod - src/Standard/Standard.cxx Diff File

Issue History

Date Modified Username Field Change
2012-11-28 12:57 Roman Lygin New Issue
2012-11-28 12:57 Roman Lygin Assigned To => abv
2012-11-28 13:01 Roman Lygin Note Added: 0022403
2012-11-28 13:01 Roman Lygin Status new => resolved
2012-11-28 13:08 abv Assigned To abv => Roman Lygin
2012-11-28 13:08 abv Status resolved => assigned
2012-11-28 13:10 abv Note Added: 0022405
2012-11-28 14:46 Roman Lygin Note Added: 0022410
2012-11-28 15:14 abv Note Added: 0022411
2012-11-28 16:59 Roman Lygin Note Added: 0022415
2012-11-29 21:45 Roman Lygin Note Added: 0022461
2012-11-29 22:04 Roman Lygin Note Added: 0022462
2012-11-29 22:05 Roman Lygin Assigned To Roman Lygin => abv
2012-11-29 22:05 Roman Lygin Status assigned => resolved
2012-11-30 13:48 abv Note Added: 0022482
2012-11-30 13:48 abv Assigned To abv => bugmaster
2012-11-30 13:48 abv Status resolved => reviewed
2012-11-30 14:56 mkv Assigned To bugmaster => mkv
2012-12-03 14:46 mkv Note Added: 0022514
2012-12-03 14:47 mkv Test case number => Not needed
2012-12-03 14:47 mkv Assigned To mkv => bugmaster
2012-12-03 14:47 mkv Status reviewed => tested
2012-12-10 17:16 Roman Lygin Changeset attached => occt master a0d8a9fc
2012-12-10 17:16 Roman Lygin Assigned To bugmaster => Roman Lygin
2012-12-10 17:16 Roman Lygin Status tested => verified
2012-12-10 17:16 Roman Lygin Resolution open => fixed
2012-12-10 17:50 bugmaster Target Version => 6.6.0
2013-04-23 13:36 aiv Status verified => closed
2013-04-29 15:21 aiv Fixed in Version => 6.6.0
2013-08-12 13:47 Roman Lygin Relationship added related to 0024110
2021-11-17 16:28 kgv Relationship replaced parent of 0024110