-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
varnishd: add backend age & reuses to Open & Close #4007
base: master
Are you sure you want to change the base?
Conversation
227df30
to
bb5da78
Compare
Sorry for the long RTT, I must have forgotten about it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, as I have given up arguing for use of VTIM_mono
...
bin/varnishd/cache/cache_conn_pool.c
Outdated
vtim_real created; | ||
uint64_t reused; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @nigoroll has a point (although he didn't try to make it) that in this case we don't need real time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @nigoroll , I intended to ack on it but forgot.
I have made the switch over to vtim_mono
.
include/tbl/vsl_tags.h
Outdated
"\t| | | | | | | | +- Connection uses\n" | ||
"\t| | | | | | | +------ Connection age\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for flip-flopping on this one but looking at the reused field it should probably say "Connection reuses" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, addressed.
bin/varnishd/cache/cache_conn_pool.c
Outdated
vtim_real | ||
PFD_Age(const struct pfd *p, vtim_real now) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should return a vtim_dur
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
bin/varnishd/cache/cache_backend.c
Outdated
VSLb(bo->vsl, SLT_BackendOpen, | ||
"%d %s %s %s %s %s reuse %.6f %ju", *fdp, | ||
VRT_BACKEND_string(dir), abuf2, pbuf2, abuf1, pbuf1, | ||
PFD_Age(pfd, VTIM_real()), PFD_Reused(pfd)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no point having a now
argument in PFD_Age()
if we end up passing VTIM_real()
, we just create ceremony. My expectation was that we should have a ctx->now
, or one ctx->wrk->lastused
freshly computed from the last timestamp update.
If we are not reusing a real timestamp available in this scope then there is no point having a now
argument or using real time at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have for now dropped the now
argument. In the future we might add it back as vtim_mono
, but let's not delve into this right now.
bb5da78
to
e244e96
Compare
This extra information comes handy when trubleshooting idle timeout from the backend. Signed-off-by: Asad Sajjad Ahmed <asadsa@varnish-software.com>
e244e96
to
3e53d5b
Compare
include/tbl/vsl_tags.h
Outdated
"\t| | +------------- Remote address\n" | ||
"\t| +---------------- Backend display name\n" | ||
"\t+------------------- Connection file descriptor\n" | ||
"\t%d %s %s %s %s %s %s [ %.6f %ld ]\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we don't specify the precision in the manual, we simply go for %f
(probably from a log consumer point of view).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point. Did not realize we have not done this in the past.
I am leaning toward consistency, but having the precision allows you to select the correct data type to store this value.
Are we fine making such promises? or should I simply use %f
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should put %f
here to be consistent with the rest of the tags.
bin/varnishd/cache/cache_conn_pool.h
Outdated
@@ -45,6 +45,8 @@ struct pfd; | |||
|
|||
unsigned PFD_State(const struct pfd *); | |||
int *PFD_Fd(struct pfd *); | |||
vtim_real PFD_Age(const struct pfd *); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vtim_dur
bin/varnishd/cache/cache_conn_pool.c
Outdated
CHECK_OBJ_NOTNULL(p, PFD_MAGIC); | ||
now = VTIM_mono(); | ||
assert(now >= p->created); | ||
|
||
return (now - p->created); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we need an assertion here ¯\(ツ)/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken form man 2 clock_gettime
:
All CLOCK_MONOTONIC
variants guarantee that the time returned by consecutive calls
will not go backwards, but successive calls may—depending on the
architecture—return identical (not-increased) time values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, if you switched to vtim_mono now (thank you), I would prefer to not call variables holding it now
, but rather t_mono
or somthing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did actually grep before naming the variable:
$ git grep -rne "now = VTIM_mono"
bin/varnishd/mgt/mgt_vcl.c:676: now = VTIM_mono();
bin/varnishd/mgt/mgt_vcl.c:1089: now = VTIM_mono();
bin/varnishstat/varnishstat_curses.c:1181: now = VTIM_mono();
lib/libvarnishapi/vsl_dispatch.c:942: now = VTIM_mono();
lib/libvarnishapi/vsl_dispatch.c:1453: now = VTIM_mono();
lib/libvarnishapi/vut.c:401: now = VTIM_mono();
I can rename the one in this PR here, or we can handle it as one commit tree-wide after this PR has gone in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side note: we got no type safety of the three vim_*
types. Years ago I attempted struct-wrapping them, which achieved the goal, but was messy. So for now, we need to be careful to not confuse them.
Signed-off-by: Asad Sajjad Ahmed <asadsa@varnish-software.com>
Thanks for the review comments, it should have been addressed now. |
This extra information comes handy when trubleshooting idle timeout from the backend.