vm: reduce lock contention when processing vm batchqueues
authorAndrew Gallatin <gallatin@FreeBSD.org>
Wed, 14 Dec 2022 19:34:07 +0000 (14:34 -0500)
committerAndrew Gallatin <gallatin@FreeBSD.org>
Wed, 14 Dec 2022 19:34:07 +0000 (14:34 -0500)
commit1cac76c93fb7f627fd9e304cbd99e8c8a2b8fce8
tree478ab936c759d5b0ac77c1c066319635d63eeb70
parentc4a4b2633d975bd0813afca6b8e23ead29d80e82
vm: reduce lock contention when processing vm batchqueues

Rather than waiting until the batchqueue is full to acquire the lock &
process the queue, we now start trying to acquire the lock using trylocks
when the batchqueue is 1/2 full. This removes almost all contention on the
vm pagequeue mutex for for our busy sendfile() based web workload.
It also greadly reduces the amount of time a network driver ithread
remains blocked on a mutex, and eliminates some packet drops under
heavy load.

So that the system does not loose the benefit of processing large
batchqueues, I've doubled the size of the batchqueues. This way, when
there is no contention, we process the same batch size as before.

This has been run for several months on a busy Netflix server, as well
as on my personal desktop.

Reviewed by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37305
sys/amd64/include/vmparam.h
sys/powerpc/include/vmparam.h
sys/vm/vm_page.c
sys/vm/vm_pageout.c
sys/vm/vm_pagequeue.h