Add a configuration option to skip the lifo_slot
optimization
#4051
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
In our (my coworkers and I) RPC stack, our server overload detection relies on being able to detect when request processing throughput is stalled. Currently, we derive this metric interactively by injecting futures (via
spawn
() in our case) into the Runtime and measures how long they took to begin execution. (this is a vague overview and I can go into more detail if needed)However, this flow relies on 'mostly-FIFO' ordering of request handling.
While tokio does not explicitly provide a FIFO execution guarantee* for spawn()'d futures, the
lifo_slot
optimization path results in pathological behavior for this workload.*I stand to be corrected, but there are 2 parts of the runtime that are not strict-fifo, and they could be altered to be
fifo
to varying degrees (though, if this PR is accepted, I would be interested in exploring both more concretely):Local
queue is filled, work is pulled off the front half of that queue and added to the globalInject
queue. I can imagine a scheme where this is changed to the back half or something, but upon reading thequeue
module, I think this would be complex to implementspawn_fifo
, but that appears to be per-thread fifo? I admittedly, don't know what I'm talking about here.We also believe that the LIFO optimization creates surprising behavior in systems that have similar expectations of 'mostly-FIFO-ness'. Given that the LIFO optimization is an optimization and not key to the functioning of the runtime, we believe it to be reasonable to empower users who find this behavior pathological for their workflows to disable it at runtime.
Solution
Change the runtime to allow
Core
's to skip thelifo_slot
optimization, and allow this to be configured in the runtimeBuilder