[sheepdog] [PATCH 1/2] sheep: add tracepoints for analyzing request latency

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Fri Jan 16 11:16:14 CET 2015


At Fri, 16 Jan 2015 18:30:36 +0900,
Hitoshi Mitake wrote:
> 
> Cc: Gu Ping <guping610 at qq.com>
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
>  sheep/Makefile.am             |   8 ++++
>  sheep/request.c               |  17 +++++++
>  sheep/tracepoint/request_tp.c |  13 +++++
>  sheep/tracepoint/request_tp.h | 107 ++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 145 insertions(+)
>  create mode 100644 sheep/tracepoint/request_tp.c
>  create mode 100644 sheep/tracepoint/request_tp.h

Applied this series.

Gu, could you try to measure request latencies with lttng/request.py
on your environment? The script is still incomplete, but it would be
helpful for detecting bottleneck.

Thanks,
Hitoshi

> 
> diff --git a/sheep/Makefile.am b/sheep/Makefile.am
> index 68c470b..20f1553 100644
> --- a/sheep/Makefile.am
> +++ b/sheep/Makefile.am
> @@ -72,6 +72,14 @@ if BUILD_EARTHQUAKE
>  sheep_LDADD		+= -leq_embed
>  endif
>  
> +# for LTTng ust tracepoints
> +AM_CPPFLAGS		= -I$(top_srcdir)/sheep/tracepoint
> +noinst_HEADERS		=  tracepoint/request_tp.h
> +
> +if BUILD_LTTNG_UST
> +sheep_SOURCES	+= tracepoint/request_tp.c
> +endif
> +
>  all-local: 
>  	@echo Built sheep
>  
> diff --git a/sheep/request.c b/sheep/request.c
> index 8a2e7dc..af68fbf 100644
> --- a/sheep/request.c
> +++ b/sheep/request.c
> @@ -13,6 +13,9 @@
>  
>  #include "sheep_priv.h"
>  
> +#define TRACEPOINT_DEFINE
> +#include "request_tp.h"
> +
>  static void del_requeue_request(struct request *req)
>  {
>  	list_del(&req->request_list);
> @@ -797,6 +800,8 @@ static void rx_work(struct work *work)
>  			conn->dead = true;
>  		}
>  	}
> +
> +	tracepoint(request, rx_work, conn->fd, work, req, hdr.opcode);
>  }
>  
>  static void rx_main(struct work *work)
> @@ -834,6 +839,8 @@ static void rx_main(struct work *work)
>  			 ci->conn.ipstr,
>  			 ci->conn.port);
>  	}
> +
> +	tracepoint(request, rx_main, ci->conn.fd, work, req);
>  	queue_request(req);
>  }
>  
> @@ -863,6 +870,8 @@ static void tx_work(struct work *work)
>  		sd_err("failed to send a request");
>  		conn->dead = true;
>  	}
> +
> +	tracepoint(request, tx_work, conn->fd, work, req);
>  }
>  
>  static void tx_main(struct work *work)
> @@ -870,6 +879,8 @@ static void tx_main(struct work *work)
>  	struct client_info *ci = container_of(work, struct client_info,
>  					      tx_work);
>  
> +	tracepoint(request, tx_main, ci->conn.fd, work, ci->tx_req);
> +
>  	refcount_dec(&ci->refcnt);
>  
>  	if (is_logging_op(ci->tx_req->op)) {
> @@ -912,6 +923,8 @@ static void clear_client_info(struct client_info *ci)
>  {
>  	struct request *req;
>  
> +	tracepoint(request, clear_client, ci->conn.fd);
> +
>  	sd_debug("connection seems to be dead");
>  
>  	list_for_each_entry(req, &ci->done_reqs, request_list) {
> @@ -964,6 +977,8 @@ static struct client_info *create_client(int fd, struct cluster_info *cluster)
>  
>  	INIT_LIST_HEAD(&ci->done_reqs);
>  
> +	tracepoint(request, create_client, fd);
> +
>  	return ci;
>  }
>  
> @@ -997,6 +1012,7 @@ static void client_handler(int fd, int events, void *data)
>  		refcount_inc(&ci->refcnt);
>  		ci->rx_work.fn = rx_work;
>  		ci->rx_work.done = rx_main;
> +		tracepoint(request, queue_request, fd, &ci->rx_work, 1);
>  		queue_work(sys->net_wqueue, &ci->rx_work);
>  	}
>  
> @@ -1019,6 +1035,7 @@ static void client_handler(int fd, int events, void *data)
>  		refcount_inc(&ci->refcnt);
>  		ci->tx_work.fn = tx_work;
>  		ci->tx_work.done = tx_main;
> +		tracepoint(request, queue_request, fd, &ci->tx_work, 0);
>  		queue_work(sys->net_wqueue, &ci->tx_work);
>  	}
>  }
> diff --git a/sheep/tracepoint/request_tp.c b/sheep/tracepoint/request_tp.c
> new file mode 100644
> index 0000000..fbc08f6
> --- /dev/null
> +++ b/sheep/tracepoint/request_tp.c
> @@ -0,0 +1,13 @@
> +/*
> + * Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License version
> + * 2 as published by the Free Software Foundation.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#define TRACEPOINT_CREATE_PROBES
> +#include "request_tp.h"
> diff --git a/sheep/tracepoint/request_tp.h b/sheep/tracepoint/request_tp.h
> new file mode 100644
> index 0000000..66254bc
> --- /dev/null
> +++ b/sheep/tracepoint/request_tp.h
> @@ -0,0 +1,107 @@
> +/*
> + * Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License version
> + * 2 as published by the Free Software Foundation.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifdef ENABLE_LTTNG_UST
> +
> +#undef TRACEPOINT_PROVIDER
> +#define TRACEPOINT_PROVIDER request
> +
> +#undef TRACEPOINT_INCLUDE
> +#define TRACEPOINT_INCLUDE "./request_tp.h"
> +
> +#if !defined(EVENT_TRACEPOINT_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
> +#define EVENT_TRACEPOINT_H
> +
> +#include <lttng/tracepoint.h>
> +
> +TRACEPOINT_EVENT(
> +	request,
> +	create_client,
> +	TP_ARGS(int, _fd),
> +	TP_FIELDS(
> +		ctf_integer(int, fd, _fd)
> +		)
> +	)
> +
> +TRACEPOINT_EVENT(
> +	request,
> +	clear_client,
> +	TP_ARGS(int, _fd),
> +	TP_FIELDS(
> +		ctf_integer(int, fd, _fd)
> +		)
> +	)
> +
> +TRACEPOINT_EVENT(
> +	request,
> +	queue_request,
> +	TP_ARGS(int, _fd, void *, _work, int, _is_read),
> +	TP_FIELDS(
> +		ctf_integer(int, fd, _fd)
> +		ctf_integer_hex(void *, work, _work)
> +		ctf_integer(int, is_read, _is_read)
> +		)
> +	)
> +
> +TRACEPOINT_EVENT(
> +	request,
> +	rx_work,
> +	TP_ARGS(int, _fd, void *, _work, void *, _req, int, _op),
> +	TP_FIELDS(
> +		ctf_integer(int, fd, _fd)
> +		ctf_integer_hex(void *, work, _work)
> +		ctf_integer_hex(void *, request, _req)
> +		ctf_integer_hex(int, opcode, _op)
> +		)
> +	)
> +
> +TRACEPOINT_EVENT(
> +	request,
> +	rx_main,
> +	TP_ARGS(int, _fd, void *, _work, void *, _req),
> +	TP_FIELDS(
> +		ctf_integer(int, fd, _fd)
> +		ctf_integer_hex(void *, work, _work)
> +		ctf_integer_hex(void *, request, _req)
> +		)
> +	)
> +
> +TRACEPOINT_EVENT(
> +	request,
> +	tx_work,
> +	TP_ARGS(int, _fd, void *, _work, void *, _req),
> +	TP_FIELDS(
> +		ctf_integer(int, fd, _fd)
> +		ctf_integer_hex(void *, work, _work)
> +		ctf_integer(void *, request, _req)
> +		)
> +	)
> +
> +TRACEPOINT_EVENT(
> +	request,
> +	tx_main,
> +	TP_ARGS(int, _fd, void *, _work, void *, _req),
> +	TP_FIELDS(
> +		ctf_integer(int, fd, _fd)
> +		ctf_integer_hex(void *, work, _work)
> +		ctf_integer_hex(void *, request, _req)
> +		)
> +	)
> +
> +#endif /* EVENT_TRACEPOINT_H */
> +
> +#include <lttng/tracepoint-event.h>
> +
> +#else /* ENABLE_LTTNG_UST */
> +
> +#include "lttng_disable.h"
> +
> +#endif
> -- 
> 1.9.1
> 



More information about the sheepdog mailing list