[sheepdog] [PATCH 0/5] rework trace to work with current code

Liu Yuan namei.unix at gmail.com
Thu Aug 30 08:59:09 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

There are mainly two changes:
 1 remove dumb ring_buffer and use strbuf to store trace items
 2 use another mechanism to suspend/resume worker threads for dynamic patching.

As before, if users don't configure with --enable-trace, there is actually zero
impact on the code base. All the tracer funtions will be complied out completely
from binary.

With reworks, add a new field to trace output: thread name (worker_name + worker_idx).

For e.x, we can only filter the trace output and get the gateway thread trace:

$ collie/collie debug trace start
... cluster is operating
$ collie/collie debug trace stop
$ collie/collie debug trace cat > t
$ grep 'gway 27' t | > t1
$ cat t1
   Thread Name      |  Time(us)  |  Function Graph
--------------------------------------------------
gway 27             |            |   do_process_work() {
gway 27             |            |      gateway_write_obj() {
gway 27             |            |         gateway_forward_request() {
gway 27             |            |            gateway_to_peer_opcode() {
gway 27             |       0.793|            }
gway 27             |            |            get_sd_op() {
gway 27             |       0.598|            }
gway 27             |            |            get_req_copy_number() {
gway 27             |       0.547|            }
gway 27             |            |            sheep_get_sockfd() {
gway 27             |            |               addr_to_str() {
gway 27             |       1.904|               }
gway 27             |            |               sockfd_cache_search() {
gway 27             |       0.675|               }
gway 27             |            |               xmalloc() {
gway 27             |       1.36 |               }
gway 27             |      19.773|            }
gway 27             |            |            send_req() {
gway 27             |      29.548|            }
gway 27             |            |            sheep_get_sockfd() {
gway 27             |            |               addr_to_str() {
gway 27             |       2.499|               }
gway 27             |            |               sockfd_cache_search() {
gway 27             |       5.33 |               }
gway 27             |            |               xmalloc() {
gway 27             |       1.859|               }
gway 27             |      35.478|            }
gway 27             |            |            send_req() {
gway 27             |      27.173|            }
gway 27             |            |            sheep_do_op_work() {
gway 27             |            |               peer_write_obj() {
gway 27             |            |                  do_write_obj() {
gway 27             |            |                     strbuf_addf() {
gway 27             |       5.809|                     }
gway 27             |            |                     jrnl_begin() {
gway 27             |            |                        xzalloc() {
gway 27             |            |                           xmalloc() {
gway 27             |       1.143|                           }
gway 27             |       3.141|                        }
gway 27             |            |                        xpwrite() {
gway 27             |   41206.762|                        }
gway 27             |            |                        xpwrite() {
gway 27             |   27106.822|                        }
gway 27             |            |                        xpwrite() {
gway 27             |   16433.765|                        }
gway 27             |   84822.558|                     }
gway 27             |            |                     default_write() {
gway 27             |            |                        get_obj_path() {
gway 27             |       1.873|                        }
gway 27             |            |                        xpwrite() {
gway 27             |   37716.486|                        }
gway 27             |   37739.304|                     }
...

Liu Yuan (5):
  lib: add a helper to strip out strbuf
  logger: add a helper to get the thread name
  trace: rework the trace mechnasim to work with current code
  sheep: rename worker threads for gateway and revoery
  collie: rework debug trace funtions to use subcommand mechanism

 collie/debug.c      |  180 ++++++++++++++++++++++++++++++++++++++-------------
 configure.ac        |    9 +--
 doc/api-strbuf.txt  |    6 ++
 include/logger.h    |    1 +
 include/sheep.h     |    3 +-
 include/strbuf.h    |    3 +-
 include/util.h      |   23 -------
 lib/Makefile.am     |    3 +-
 lib/logger.c        |   10 +++
 lib/ring_buffer.c   |   54 ----------------
 lib/strbuf.c        |   16 ++++-
 lib/util.c          |    2 +-
 sheep/ops.c         |    3 +-
 sheep/sheep.c       |    4 +-
 sheep/trace/graph.c |   20 +++---
 sheep/trace/trace.c |  163 +++++++++++++++++++++++++++++-----------------
 sheep/trace/trace.h |   18 +++---
 sheep/work.c        |    4 ++
 sheep/work.h        |    2 +
 19 files changed, 309 insertions(+), 215 deletions(-)
 delete mode 100644 lib/ring_buffer.c

-- 
1.7.10.2




More information about the sheepdog mailing list