[omniORB] omniorbpy: switching GC off for duration of every outgoing call

Michael Kilburn crusader.mike at gmail.com
Wed Jan 21 00:05:44 GMT 2015


Here is the solution I came up with:

import _omnipy
_omnipy_invoke = _omnipy.invoke

def invoke_mk2(*args):
   import gc
   gc_flag = gc.isenabled()
   try:
     if gc_flag: gc.disable()
     return _omnipy_invoke(*args)
   finally:
     if gc_flag: gc.enable()

_omnipy.invoke = invoke_mk2


Apparently problem this snippet solves was addressed in Python 2.7. Though,
I would imagine switching off GC completely is still better than reducing
number of collections.

Duncan, you might want to include it in omniORB at some point :-)



On Fri, Jan 16, 2015 at 7:37 PM, Michael Kilburn <crusader.mike at gmail.com>
wrote:

> On Fri, Jan 16, 2015 at 9:07 AM, Duncan Grisby <duncan at grisby.org> wrote:
>
>> On Mon, 2015-01-12 at 23:48 -0600, Michael Kilburn wrote:
>> > Is there any easy way in omniOrbPy to automatically switch gc off in
>> > every outgoing call? (and then switch it back once all data is
>> > received and converted to python objects)
>>
>> You could register clientSendRequest and clientReceiveReply interceptors
>> to disable and then re-enable the GC. Beware that if your code is
>> multi-threaded, the GC is a global option, so your threads could tread
>> on each other.
>>
>
> Nope... Tested it today -- it does not work the way I need.
> clientReceiveReply gets called before incoming data gets converted into
> Python types and I suspect clientSendRequest is similar.
>
> Basically I am looking for an easy way to get effect (equivalent to
> following pseudo-code) applied to every CORBA call in my python app:
>
> before:
>       data = myObj->corba_method();
>
> after:
>      gc.disable()
>      data = myObj->corba_method();
>      gc.enable();
>
> (well, obviously it needs to be more robust than that, take care of MT
> issues -- but it is irrelevant on this stage).
>
> Any ideas?
>
> P.S. In case if you think I am nuts -- in my case this difference
> translates into 10 vs 160 seconds of  execution time (i.e. up to 16-fold
> speedup). Yep, we move around large number of very tiny Python objects.
>
>


-- 
Sincerely yours,
Michael.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20150120/92b8e6c6/attachment.html>


More information about the omniORB-list mailing list