rpyc critical performance issue with BgServingThread #32

Closed
pan2003 opened this Issue Mar 15, 2011 · 2 comments

Projects

None yet

2 participants

@pan2003
pan2003 commented Mar 15, 2011

I work with RPYC classic server (see code below) under Windows XP.

When I have BgServingThread, 100 calls of execute() takes about 10 seconds.
Without BgServingThread, 100 calls of execute() takes about 0.01 seconds.

Why? What can I do to have both BgServingThread running and execute() working fast?

import rpyc 
import time 

c = rpyc.classic.connect("localhost") 
t = rpyc.BgServingThread(c) # delete this line for fast execute

start = time.time() 
for i in range(100): 
    c.execute("newObj = %d" % (i)) 
stop = time.time() 
print "added %d simple objects one by one, %f seconds" % (100, stop - start) 

t.stop()  # delete this line if deleted line above

Need any ideas...

@tomerfiliba
Owner

have a look at: http://github.com/tomerfiliba/rpyc/blob/v3.0.7/utils/helpers.py#L70 and http://github.com/tomerfiliba/rpyc/blob/v3.0.7/core/protocol.py#L296

the bg server thread calls serve with a timeout of 0.1 seconds each time. while it attempts to serve, no other thread can use the connection, so calls to c.execute (or any other remote invocation, for that matter) have to wait for an average of 0.1 seconds before being able to lock the connection and send their data.

100 calls * 0.1 second delay for lock = 10 seconds.

i will try to find a better way to solve the contention between threads sharing the connection... but it won't happen in 3.1.0

@tomerfiliba
Owner

closed by e407ada

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment