summaryrefslogtreecommitdiff
path: root/proxy.h
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2023-01-05 18:36:22 -0800
committerdormando <dormando@rydia.net>2023-01-05 18:36:22 -0800
commitdb855da755f297df3165809073b0ca6a6299fcbd (patch)
treed080622f12962848c361fc7ffefb51a86f622db8 /proxy.h
parent3158e85e84909c81eeb60e719c3d582677ec32c8 (diff)
downloadmemcached-db855da755f297df3165809073b0ca6a6299fcbd.tar.gz
proxy: log time now relative to resp lifetime
Originally I envisioned taking an inbound request object, tagging it with the time, and at the very end of a function logging is called. This would give you the total time of the "backend" part of a request. On rethinking, the timing information that's most useful in the proxy's perspective is the time it takes for a response to happen + the status of a response. One request may generate several sub-responses and it is impossible to check the timing of each of those and log outliers. You now cannot get the total time elapsed in a function anymore, but I believe that is less useful information to the user of a proxy. The best picture of latency will still be from the client, and response latency can educate the proxy on issues with backends. resp:elapsed() has been added as a compromise; it returns the elapsed microseconds that a response took, so you can add the time together and get an approximation of total time (if running req/resp's sequentially). This change also means that calling mcp.await() and waiting for multiple responses will give the timing of each sub-response accurately.
Diffstat (limited to 'proxy.h')
-rw-r--r--proxy.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/proxy.h b/proxy.h
index dbd217e..c5a42fb 100644
--- a/proxy.h
+++ b/proxy.h
@@ -281,7 +281,6 @@ struct mcp_parser_s {
#define MAX_REQ_TOKENS 2
struct mcp_request_s {
mcp_parser_t pr; // non-lua-specific parser handling.
- struct timeval start; // time this object was created.
mcp_backend_t *be; // backend handling this request.
bool ascii_multiget; // ascii multiget mode. (hide errors/END)
bool was_modified; // need to rewrite the request
@@ -396,6 +395,8 @@ typedef struct {
mcmc_resp_t resp;
char *buf; // response line + potentially value.
size_t blen; // total size of the value to read.
+ struct timeval start; // time this object was created.
+ long elapsed; // time elapsed once handled.
int status; // status code from mcmc_read()
int bread; // amount of bytes read into value so far.
uint8_t cmd; // from parser (pr.command)