pv list lock is the main bottleneck during poudriere -j 104 and pmap_remove_pages is the most impactful consumer. It frees chunks with the lock held even though it plays no role in correctness. Moreover chunks are often freed in groups, sample counts during buildkernel (0-sized frees removed):
value ------------- Distribution ------------- count 0 | 0 1 | 8 2 |@@@@@@@ 19329 4 |@@@@@@@@@@@@@@@@@@@@@@ 58517 8 | 1085 16 | 71 32 |@@@@@@@@@@ 24919 64 | 899 128 | 7 256 | 2 512 | 0
- batch freeing
- move it past unlocking pv list
I did not bother benchmarking this change in isolation, see another review for details.