Priority Linked Blocking Deque Implementation (not intended to be merged)#1
Priority Linked Blocking Deque Implementation (not intended to be merged)#1mpoemsl wants to merge 32 commits intotorchserve-0.7.1from
Conversation
| scheduled = begin; | ||
|
|
||
| Map<String, String> headers = input.getHeaders(); | ||
| if (headers.containsKey("X-Priority")) { |
There was a problem hiding this comment.
Not that it is incorrect, but maybe it is a bit unnatural to use a header instead of the body for the priority? But if it is the only way, then lets keep it.
I am also not sure about the name X-Priority - apparently that header is already used in some cases for emails.
In the past, I started using the convention of prefixing headers with X-TS- so that it is clear, that it is our own header.
There was a problem hiding this comment.
That's a good idea, I'll change it to X-TS-. I think at this point the request body is not yet parsed, so it has to be a header unless we want introduce overhead at the pre-queueing stage.
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class PriorityLinkedBlockingDeque<T extends Prioritisable> { |
There was a problem hiding this comment.
If we wanted to be future proof, we probably had to implement all interfaces implemented by LinkedBlockingDeque. But I guess just implementing the methods that are actually used is okay for now.
…rical Make priority values categorical
This PR implements request priorisation by replacing LinkedBlockingDeque in Model.java with a wrapper of multiple
LinkedBlockingDeques (one for each priority class).This PR builds on TorchServe
0.7.1. The behavior is as explained in #88. The implementation of this behavior is achieved with these changes:Jobs parse anint priorityfrom the HTTP headerX-Priority(default priority class is0) and extend thePrioritisableinterface (getter and setter forpriority)Models storeJobs in a new classPriorityLinkedBlockingDequewhich wraps multipleLinkedBlockingDeques (one for each priority class, the number of which is specified viaTS_NUMBER_OF_PRIORITIES)PriorityLinkedBlockingDequeimplements all methods ofLinkedBlockingDequethat are used in TorchServe, namelyaddFirstandofferfor insertion andpollfor extraction.LinkedBlockingDequefor aJob's priority (if it is full, aServiceUnavailableExceptionis thrown)5.1. Deque for priority
05.2. Deque for sampled priority
>05.3. All other deques
If all deques are empty, poll sampled deque until next insertion in any deque.
RequestPrioritylogs the priority of each request.