CA-414627: increase polling duration for tapdisk #6611
Merged
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.
Polling mode is a performance optimization in tapdisk, where it would busy poll the PV ring for the next request, instead of going to sleep and waiting for an event channel to wake it up when the next request arrives. When the guest supplies us with a steady sequence of IO requests this is quicker (it avoids a lot of syscalls), at the expense of consuming more Dom0 CPU.
Once polling mode is entered if there are no requests for polling-duration microseconds, then polling mode is exited.
The wakeup granularity is 4ms on the 4.19 kernel (which also matches CONFIG_HZ=250).
The default polling duration is 1ms, but we may not be able to reliably handle such low timeouts.
On newer kernels we seem to hit the 1ms polling duration timeout all the time, which results in tapdisk entering and exiting polling mode very often. This is in fact a lot slower than just staying in event mode, or permanently staying in polling mode when measured with a Phoronix SQLite benchmark.
Testing showed that a 6ms value results in good benchmark results (~40% faster than the default event based), and a 3ms value in bad benchmark results (50% slower than event based).
Increase the default polling duration to be a multiple of the wakeup granularity on 4.19, which should work with both 4.19 kernels and newer.
Eventually we should measure what is the optimal value where the overhead of entering/exiting polling mode is no longer greater than staying in event mode. (This is similar to how entering and exiting C modes need to take into account enter and latencies, except in this case those latencies are not known).