Performance/Ideas/Easy UNO Services Merging

From Apache OpenOffice Wiki
< Performance
Revision as of 12:58, 19 February 2009 by Mt (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Loading many small libraries results in performance penalties, compared to loading fewer large libraries, so people suggested to combine some of the UNO services libraries.

The problem here is that all libraries export functions with the same names

 component_getImplementationEnvironment
 component_writeInfo
 component_getFactory

So merging libraries means you also need to combine these functions - every time you want to organize the services differently.

For making it easier, it could be a good idea to make all these function names unique for each service:

 component_getImplementationEnvironment_<current_library_name>
 component_writeInfo_<current_library_name></i>
 component_getFactory_<current_library_name></i>

A new tool could then create a stub for each UNO service library:

 unostub <name1> [<name2>, ...]

For getting the current behavior, with all the single service libraries, you would add something to the makefile like

 unostub <current_library_name>

which will result something like

 component_getImplementationEnvironment 
 {
   component_getImplementationEnvironment_<current_library_name> 
 }
 component_writeInfo
 {
   component_writeInfo_<current_library_name> 
 }
 component_getFactory
 {
   return component_getFactory_<current_library_name> 
 }

So in the end you will have exactly the same like before, only one indirection more.

The benefit starts when you try to combine certain services, which you probably do based on some logic (what belongs together), or some experiments (what is needed simple svdem, OOo backing window, ...).

 unostub <current_library_name_1> <current_library_name_2> <current_library_name_n>
 component_getImplementationEnvironment ( const sal_Char** ppEnvTypeName, ... )
 {
   *ppEnvTypeName = NULL;
   component_getImplementationEnvironment_<current_library_name_1>(ppEnvTypeName,...)
   if ( *ppEnvTypeName )
     component_getImplementationEnvironment_<current_library_name_2>(ppEnvTypeName,...) 
   ...
   if ( *ppEnvTypeName )
     component_getImplementationEnvironment_<current_library_name_n>(ppEnvTypeName,...) 
 }
 component_writeInfo
 {
   component_writeInfo_<current_library_name_1> 
   component_writeInfo_<current_library_name_2> 
   ...
   component_writeInfo_<current_library_name_n> 
 }
 component_getFactory
 {
   void* pRet = NULL
   if ( *pRet )
     pRet = component_getFactory_<current_library_name_1>(...) 
   if ( *pRet )
     pRet = component_getFactory_<current_library_name_2>(...) 
   ...
   if ( *pRet )
     pRet = component_getFactory_<current_library_name_n>(...) 
 }

This way, we could very easily combine different services, or change anything later again.

In the different UNO services implementations, you must make sure that

 a) Don't have a unconditional "else" clause assuming it can only be the last service you didn't check for with "if" before
 b) Don't use assertions if you receive a service name you didn't expect

TBD...

Personal tools