[omniORB] Severe omniORB4 performance problems with local calls and "foreign" threads

Chris Newbold cnewbold@laurelnetworks.com
Fri Aug 16 23:05:01 2002


We've run into a rather severe performance problem with omniORB4's
handling of local calls on "foreign" threads: threads created through
some API other than omnithreads.

The culprit is poaCurrentStackInsert: when it discovers that the current
thread is not an omnithread, it allocates a "temporary" omniCurrent and
a "temporary" omni_thread (omni_thread_dummy). It allocates, initializes
and destroys these objects for each local invocation. Needless to say,
this savages the performance of local calls.

We have our own C++ threading library which handles the same situation
in a more efficient manner. Our thread abstraction, util::Thread, has a
static member function to access the "current" thread:

	static util::Thread* Self();

The constructor of util::Thread stuffs a pointer to itself into
thread-specific storage and this is what util::Thread::Self() returns.
If we find ourself in Self() and our pointer is zero, we're dealing with
a "foreign" thread. We proceed to allocate a new instance of
util::Thread and attach it to the existing thread and go on our way. We
never explicitly remove our util::Thread object, so future calls to
util::Thread::Self() on that thread are fast: it is no longer "foreign".

We install a destructor function for our thread-specific data to take
care of deleting the util::Thread instance when the thread exits.

This technique works extremely well with omniORB, since the threads
dispatching operations on the server are all created by omniORB and are
initially "foreign" to our threading library.

Why doesn't omniORB do the same thing? I couldn't really find anything
which would prevent you from just leaving the omni_thread and
omniCurrent lying around for future use.

For the moment, we've disable POA::Current support to regain the lost
performance...

-- 
====( Chris Newbold  <cnewbold@laurelnetworks.com>
)===========================
      Laurel Networks, Inc. voice: +1 412 809 4200 fax: +1 412 809 4201
"If you fool around with a thing for very long you will screw it up." 
--Murphy
-------------------------------------------------------------------------------