Skip to contentSkip to conversation

why does the tx virtqueue have a timer?

Qemu-devel Vasile Catalin-B50542 2 participants 2 messages Mar 3, 2015

lore
Share & tools
lore
#0 lore raw

1. Why does virtio-net have a timer to handle tx virtqueue?
2. Why isn't the virtqueue kick enough? (I see that both are set to handle jobs from virtqueue.)
3. What is the difference between regular timers and bh (bottom halves)? Why would you choose one over another?

#1 lore raw
Quoted 1 line · On Tue, Mar 03, 2015 at 11:21:32AM +0200, Vasile Catalin-B50542 wrote:

1. Why does virtio-net have a timer to handle tx virtqueue?

It's a performance optimization. By delaying tx virtqueue processing by 150 microseconds and turning guest->host virtqueue notifications off, QEMU is able to batch transmit.

Quoted 2 lines

2. Why isn't the virtqueue kick enough? (I see that both are set to handle jobs from virtqueue.)

It is enough. The timer is not for functionality or correctness, it is purely a performance optimization. The optimization is a gamble, there are workloads where the extra 150 microseconds of latency causes worse performance.

Quoted 2 lines

3. What is the difference between regular timers and bh (bottom halves)? Why would you choose one over another?

A bottom half is scheduled in the main loop "as soon as possible". A timer has a specific duration (150 microseconds by default in this case).

150 is a magic number. BH is another magic number, essentially. This is just a bet that performance will be better if we delay a bit to allow batching.

Hope this helps,
Stefan