With N of the guest's 16 MiB pool pieces in, one add cost QEMU 21 ms of BQL
under KVM at N = 2,000 (13.5 ms under HVF, 43 ms under WHPX), most of it
work that walked every RAM block or flat range: a probe device doing the
add's calls, paused, measured each part. vendor/qemu moves to six cuts, each
its own commit with its measurement:
- set a piece unmergeable inside its add's transaction, so an add commits
once, not twice;
- place a RAM block in one pass over the blocks sorted by offset, not by
comparing each block with every other;
- carry out a run of queued asks of one kind in one transaction, answering
each add once its run has committed;
- render a flat view with a gap at the last insert and a binary search,
not by moving every later range, with the same views (20,162 compared);
- put a RAM block in the list by its run of one size, with the list's order
unchanged (4,398 compared);
- find a pool piece by binary search over the pieces sorted by address.
After them one ask at N = 2,000 costs 745 / 779 us (add / removal) under
KVM, 584 / 565 us under HVF and 376 / 370 us under WHPX, and a run of 8
119 / 121, 81 / 70 and 63 / 47 us an ask. What the guest observes does not
change: its pieces, their addresses and the order of the device's answers
are as before. Between free gaps of one size a new RAM block now takes the
lowest offset, an offset of this process's own that no guest sees.
docs/qemu.md gives the before and after per host, with the job ids; what
one ask costs at the 131 pieces a recorded session reached, set beside what
the runtime's own 16 MiB block costs on each host; the rule that a piece
the runtime holds for reuse keeps its region, with what a removal and
re-add would cost; and HVF's costs with many blocks resident and the counts
it maps without a refusal.