Re: debugging or tracing a multi-threaded program



On Aug 21, 11:20 pm, sam.n.seab...@xxxxxxxxx wrote:
Hi all,

I am writing a multi threaded app (basically a small HTTP server that
uses threadpools) and stress testing it with 20-30 simultaneous client
connections (sort of like apachebench). (This is on AIX 5.3.)

The basic design is around a main thread (that accepts client conns
and select()'s over them to detect client activity) and a bunch of
worker threads (that process one transaction and return to the pool to
idle). I am experimenting with this and other multiprocess/multithread
models.

I'm facing issues around mutex locking, pthread_cond_wait, and in some
cases the server just stops, possibly due to either deadlock or maybe
something else. To try and get to the bottom of this, I'm used
printf()s, then went to using write()s to a debug file, but I feel
both are too slow or otherwise unreliable. I guess my basic problem is
to trace through the thread activity to see which threads get woken up
when, and what they do.

My questions is: is there a good i.e. reliable and efficient way to
trace the execution of the program i.e. when threads become active and
when they return? In my case, threads are woken up by signals and they
restore the mask when they go back to idling. I have googled and RTMs
of GDB, DBX and others, but they only go as far as to indicate when
threads are created or are exiting e.g. GDB print thread-events. Also,
debuggers give a snapshot view instead of an execution view: typing
"threads" or "lwps" into dbx shows snapshots of what all the threads
are doing, and it's hard to piece these snapshots together to find out
what's happening from start to end.

I am guessing there are probably 3 alternatives:
1. write a debugger script that takes these snapshots at high speed
and dumps them somewhere; but will that perturb the actual application
too much?
2. fast write() in the app, but how to synchronize across threads? yet
another lock, causing more perturbation?
3. app writes out debug messages to a socket that is read by another
reader app; but will the OS (AIX 5.3) guarantee that concurrent
write()s by different threads will be delivered in order?

Any other suggestions or hints would be appreciated.

thanks in advance,
-SNS

hi
this may not be the answer you are looking for, but have you ever used
static analysis tools? I recently found a tool called findbugs that
looks over your java source code and points out anything sketchy you
may be doing A friend told me about some similar tools they were
using, a few of which supported multithreaded applications. This post
reminded me of them. Maybe you could google for threaded static
analysis tools to find something to help you?
.



Relevant Pages

  • Re: Authenticate with RACF from Web App
    ... The web server on distributed redirects to the HTTP Server on z/OS ... The app is web-based running on non-zOS platform. ... For IBM-MAIN subscribe / signoff / archive access instructions, ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ...
    (bit.listserv.ibm-main)
  • Re: Something like "ping" for windows messages.
    ... going to depend solely on what your app is doing, what its current priority is relative to ... in general measuring the responsiveness to any one message is problematic in predicting ... same and only varying one part (the http server), ... I need a way to test the message pump. ...
    (microsoft.public.vc.mfc)
  • Re: Looking for advice on rsync
    ... >> they can't use the app. ... If they use snapshots, that period can be ... > for LVM snapshots. ... snapshots to not be "crud," the data has to be in a consistent state. ...
    (comp.os.linux.misc)
  • Re: Looking for advice on rsync
    ... >> they can't use the app. ... If they use snapshots, that period can be ... A/R detail or if an index file is consistent with the data it points ... Tony Lawrence ...
    (comp.os.linux.misc)
  • Re: Running PHP in custom www server app
    ... >> same app actually). ... >> generated pages through PHP. ... you forgot to mention what HTTP server you are using... ... arisen a need to add PHP support to our "server"... ...
    (comp.lang.php)

Quantcast