-
Notifications
You must be signed in to change notification settings - Fork 402
varnishncsa: Add hitmiss hitpass indicators to Varnish:handling #4217
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1128,6 +1128,14 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], | |
| case SLT_RespUnset: | ||
| process_hdr(FMTPOL_RESP, &CTX.watch_resphdr, b, e, 1); | ||
| break; | ||
| case SLT_HitMiss: | ||
| CTX.hitmiss = "miss"; | ||
| CTX.handling = "hitmiss"; | ||
| break; | ||
| case SLT_HitPass: | ||
| CTX.hitmiss = "miss"; | ||
| CTX.handling = "hitpass"; | ||
| break; | ||
| case SLT_VCL_call: | ||
| if (!strcasecmp(b, "recv")) { | ||
| CTX.recv_compl = 1; | ||
|
|
@@ -1136,10 +1144,10 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], | |
| } else if (!strcasecmp(b, "hit")) { | ||
| CTX.hitmiss = "hit"; | ||
| CTX.handling = "hit"; | ||
| } else if (!strcasecmp(b, "miss")) { | ||
| } else if (!strcasecmp(b, "miss") && strcmp(CTX.handling, "hitmiss")) { | ||
| CTX.hitmiss = "miss"; | ||
| CTX.handling = "miss"; | ||
| } else if (!strcasecmp(b, "pass")) { | ||
| } else if (!strcasecmp(b, "pass") && strcmp(CTX.handling, "hitpass")) { | ||
| CTX.hitmiss = "miss"; | ||
| CTX.handling = "pass"; | ||
|
Comment on lines
-1139
to
1152
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we conditionally update only the hitmiss in these blocks? In both
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand what you are trying to say. The intention is to preserve
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: using simplified formats %hitmiss and %handling to distinguish with hitmiss and hitpass values to hopefully avoid ambiguity. What I had in mind was "%hitmiss/%handling" leading to for example "hitmiss/pass" after a return(pass) from vcl_miss in a hit-for-miss scenario. Reading the current documentation for %hitmiss and %handling formats I think we should actually not change them this way because %hitmiss is intentionally limited and I think %handling is not a good host for "hitmiss" and "hitpass" values. What I mean by that is that a hit-for-pass transaction is handled the same as a regular pass transaction, whether you return(pass) from vcl_recv, vcl_hit, or vcl_miss. You essentially get a private fetch, this is how the request is handled. This is how I think %handling should be reported (and already is if I'm reading correctly). We should maybe leave %hitmiss and %handling formats alone and introduce a new format with a finer-grained set of values. Let's for example call it %lookup and it could have the following values:
And of course, I'm counting on the documentation to clarify what's what. This way you can keep %hitmiss as a source of de-facto hit ratio with hits vs everything else in your VSL sample. edit: replaced one %hitpass occurrence with %handling
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you are proposing exactly the same plus To clarify: 🟢 exists already 🟡 proposed by this PR 🔵 proposed by Dridi in addition
I have not checked if And should we have a new %format? @gquintard says no, @dridi says yes, I don't care. But I do not think that %format inflation helps much here, I would just keep %handling.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like I forgot to reply to some comments:
Yes. How does this not work with the current patch? I added this to the test case: 143390b The
😖 This patch proposes to report a difference between a regular
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wfm |
||
| } else if (!strcasecmp(b, "synth")) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| varnishtest "varnishncsa handling" | ||
|
|
||
| server s1 -repeat 4 { | ||
| rxreq | ||
| txresp | ||
| } -start | ||
|
|
||
| varnish v1 -vcl+backend { | ||
| backend none none; | ||
|
|
||
| sub vcl_backend_fetch { | ||
| # XXX would like to do everything in v_b_e, but | ||
| # return(pass(x)) is not supported | ||
| if (bereq.url == "/hitpass") { | ||
| set bereq.backend = s1; | ||
| } else { | ||
| set bereq.backend = none; | ||
| } | ||
| } | ||
|
|
||
| sub vcl_backend_response { | ||
| set beresp.ttl = 1y; | ||
| return (pass(1y)); | ||
| } | ||
|
|
||
| sub vcl_backend_error { | ||
| set beresp.status = 200; | ||
| set beresp.ttl = 1y; | ||
| set beresp.body = bereq.url; | ||
| if (bereq.url ~ "^/hitmiss") { | ||
| set beresp.uncacheable = true; | ||
| } | ||
| return (deliver); | ||
| } | ||
|
|
||
| sub vcl_miss { | ||
| if (req.url == "/hitmisspass" && req.is_hitmiss) { | ||
| return (pass); | ||
| } | ||
| } | ||
|
|
||
| sub vcl_recv { | ||
| if (req.url == "/pass") { | ||
| return (pass); | ||
| } | ||
| if (req.url == "/synth") { | ||
| return (synth(204)); | ||
| } | ||
| } | ||
| } -start | ||
|
|
||
| client c1 { | ||
| # prime | ||
| txreq -url "/hitmiss" | ||
| rxresp | ||
| txreq -url "/hitmisspass" | ||
| rxresp | ||
| expect resp.status == 200 | ||
| txreq -url "/hitpass" | ||
| rxresp | ||
| expect resp.status == 200 | ||
| txreq -url "/hit" | ||
| rxresp | ||
| expect resp.status == 200 | ||
|
|
||
| # re-check | ||
| txreq -url "/hitmiss" | ||
| rxresp | ||
| expect resp.status == 200 | ||
| txreq -url "/hitmisspass" | ||
| rxresp | ||
| expect resp.status == 200 | ||
| txreq -url "/hitpass" | ||
| rxresp | ||
| expect resp.status == 200 | ||
| txreq -url "/hit" | ||
| rxresp | ||
| expect resp.status == 200 | ||
|
|
||
| # others | ||
| txreq -url "/pass" | ||
| rxresp | ||
| expect resp.status == 200 | ||
| txreq -url "/synth" | ||
| rxresp | ||
| expect resp.status == 204 | ||
| } -run | ||
|
|
||
| shell { | ||
| cat <<EOF >expect | ||
| miss /hitmiss | ||
| miss /hitmisspass | ||
| miss /hitpass | ||
| miss /hit | ||
| hitmiss /hitmiss | ||
| pass /hitmisspass | ||
| hitpass /hitpass | ||
| hit /hit | ||
| pass /pass | ||
| synth /synth | ||
| EOF | ||
| varnishncsa -d -n ${v1_name} -F "%{Varnish:handling}x %U" >have | ||
| diff -u expect have | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.