Repository navigation
Negative caching shouldn't happen on 400 response (#396) - #2031
persiaAziz-zz wants to merge 1 commit into
Conversation
a600e6d to
1a4e4f6
Compare
|
|
||
| switch (s->hdr_info.server_response.status_get()) { | ||
| case HTTP_STATUS_NO_CONTENT: | ||
| case HTTP_STATUS_USE_PROXY: |
There was a problem hiding this comment.
hmmm, I guess I don't understand what was wrong with the old switch. Compilers can typically optimize that into very efficient code I think.
| c.codeNegCache.add(HTTP_STATUS_NO_CONTENT); | ||
| c.codeNegCache.add(HTTP_STATUS_USE_PROXY); | ||
| c.codeNegCache.add(HTTP_STATUS_FORBIDDEN); | ||
| c.codeNegCache.add(HTTP_STATUS_NOT_FOUND); |
There was a problem hiding this comment.
Honestly, since the number of status codes are limited, a standard C array with 1000 bool elements would be easier, and definitely faster.
ink_zero(codeNegCache, sizeof(codeNegCache);
codeNegCache[HTTP_STATUS_NO_CONTENT] = true;
codeNegCache[HTTP_STATUS_USE_PROXY] = true;
etc. Then the check if a particular status code is cacheable is O(1). Yeh, so we waste 1KB (give or take) of RAM, but I bet all this code makes up for that anyways :-).
There was a problem hiding this comment.
As amc pointed out, you could even make the array smaller since, 400-599 (so two hundred bytes).
| else | ||
| return bin_search(s, mid - 1, lt, eq, item); | ||
|
|
||
| return false; |
There was a problem hiding this comment.
Should probably remove this, to make sure the compiler can tail recurse this for sure.
There was a problem hiding this comment.
That will likely create a coverity issue as well.
There was a problem hiding this comment.
We wouldn't need this if we replace the vec in this patch with array. I can make a separate patch for the binary search if you think this might be useful.
| c.codeNegCache.add(HTTP_STATUS_NO_CONTENT); | ||
| c.codeNegCache.add(HTTP_STATUS_USE_PROXY); | ||
| c.codeNegCache.add(HTTP_STATUS_FORBIDDEN); | ||
| c.codeNegCache.add(HTTP_STATUS_NOT_FOUND); |
There was a problem hiding this comment.
As amc pointed out, you could even make the array smaller since, 400-599 (so two hundred bytes).
| params->synthetic_port = m_master.synthetic_port; | ||
|
|
||
| m_id = configProcessor.set(m_id, params); | ||
| params->codeNegCache = m_master.codeNegCache; |
There was a problem hiding this comment.
This was unclear to me too, but amc told me that the intent was to make this configurable (but it obviously isn't in this patch). So ignore my comment on the switch statement, it would not suffice if you plan on making this vector / array configurable.
|
I think when this was started we hadn't moved to eleventy yet. In view of that I'd recommend
Finally, I thought the goal of this was to be able to configure the negative cache enabled list. |
|
@SolidWallOfCode @zwoop yah this patch is pretty old. Array sounds like a better idea. I will update this accordingly. |
|
Just reading all the comments in order, and I agree with @SolidWallOfCode. Use |
dragon512
left a comment
There was a problem hiding this comment.
Can we add a test for this
|
will resurrect later |
Uh oh!
There was an error while loading. Please reload this page.