Ok, so here is the full submission for priority based queuing. Notes since previous update:
Wasn't really able to optimize the tree search any. Tried a few things, but nothing made a measurable performance difference. I added a warning message and documentation making clear the issues with timestamp wrapping. Though one thing that might not be completely obvious is that even if the user does not configure `set-priority-offset` at all, they're still susceptible to the wrapping issue as the priority is the queue key whether priority is adjusted or not. The implementation of the %sq (srv_queue) and %bq (backend_queue) was change to keep the description accurate. The description is "number of requests which were processed before this one". The previous implementation just stored the size of the queue at the time the connection was queued. Since we can inject a connection into the middle of the queue, this no longer works. Now we keep a count of dequeued connections, and take the difference between when the connection was queued, and then dequeued. This also means the value will be slightly different even for users who don't use priority, as the previous method would have included connections which closed without being processed. I added sample fetches for retrieving the class/offset of the current transaction. I think it might be beneficial to add some other fetches for tracking the health of the queue, such as average class/offset, or an exponential moving average of the class/offset for requests added to the queue, requests processed, and requests which closed/timed out. But this is just more stuff the code would have to store, so unsure if they're worth it. I wasn't convinced the 64-bit key was a bad idea, so I implemented the idea with a 12/52 split and an absolute timestamp. On my system (which is 64-bit) the performance is about 20% faster. The code is much simpler. And it also solves the limitations and issues with wrapping. The patch for this is included in case it's of interest. -Patrick Patrick Hemmer (2): MEDIUM: add set-priority-class and set-priority-offset use a 64-bit int with absolute timestamp for priority-offset doc/configuration.txt | 38 +++++++ doc/lua-api/index.rst | 18 ++++ include/types/proxy.h | 3 +- include/types/queue.h | 2 +- include/types/server.h | 3 +- include/types/stream.h | 7 +- src/cfgparse.c | 15 +++ src/hlua.c | 69 +++++++++---- src/log.c | 4 +- src/proto_http.c | 4 +- src/proxy.c | 2 +- src/queue.c | 261 +++++++++++++++++++++++++++++++++++++++++-------- src/server.c | 2 +- src/stream.c | 10 +- 14 files changed, 366 insertions(+), 72 deletions(-) -- 2.16.3

