Hello,
I am using SBCL 1.0.23.50 on Ubuntu 8.04 (x86-64). While testing a TCP
server written using SBCL and usocket, I noticed that FORCE-OUTPUT seems
to hang periodically. The server runs like an I/O multiplexer: the
listener runs on a dedicated thread of its own; and a worker thread
waits for input on any of the connected sockets (using
usocket:wait-for-input), processing them as input arrives.
At times, while flushing output down a particular socket (which is done
in the worker thread), FORCE-OUTPUT blocks -- usually for a few seconds,
but sometimes longer. As a result, the worker thread can't do any
further processing till FORCE-OUTPUT returns, and no other client can be
handled. I have attached with this mail the complete backtrace (obtained
with slime-thread-debug) but the interesting bits, I guess, are these:
10: (SB-SYS:INVOKE-INTERRUPTION #<FUNCTION (FLET SB-UNIX::INTERRUPTION)
{1000072B99}>)
11: ("foreign function: #x41EC42")
12: ("foreign function: #x41ED20")
13: ("foreign function: #x7F5983A5554B")
14: (SB-C::INVOKE-WITH-SAVED-FP-AND-PC #<CLOSURE (LAMBDA #) {1003A48089}>)
15: ((FLET SB-UNIX::%WRITE) #.(SB-SYS:INT-SAP #X7F5980D8C000))
16: (SB-UNIX:UNIX-WRITE 165 #.(SB-SYS:INT-SAP #X7F5980D8C000) 0
650)[:EXTERNAL]
17: (SB-IMPL::FLUSH-OUTPUT-BUFFER #<SB-SYS:FD-STREAM for "a socket"
{1003194001}>)
18: (FORCE-OUTPUT #<SB-SYS:FD-STREAM for "a socket" {1003194001}>)
This behaviour occurs consistently when I have a hundred or so clients
sending messages to the server once every second. Note that this means
that a lot of output is being flushed down the client sockets. I haven't
found any lower limit for this, but it doesn't happen when I have very
few clients (< 5) periodically sending messages to the server.
Any help on why this would be happening? And how to fix this?
Thanks,
Chaitanya
|