A guest's previews make one short video session after another, each with
buffers of its own, and each size's video-processing context went with its
last import. So every session's first run was a new context's first run in
the driver, a few milliseconds on radeonsi. Measured before, on the Radeon
780M (Mesa 26.2.6, m3-max-83333): a 400x258 HEVC thumbnail's frame took 5.54
to 6.83 ms from its take to its signal across 12 sessions of one size, its
run's vaEndPicture 4.83 to 6.14 ms of that.
The imports' table now keeps the contexts of the 4 sizes imported last
(KEPT_CONTEXTS) past their last import, at most 4 at once beside those live
imports hold, and holds no surface: a context is made on none. A size
imported again moves to the back; a size imported past the 4 pushes out the
one imported longest ago, destroyed once no import holds it; the rest go with
the table, which the VA-API arm holds, so at the arm's teardown. No time
bounds it: the decoder cache's idle epoch is Windows' alone, where no dma-buf
is lent and so no import or processing context is made. A unit test fills
the table past its cap, and the 780M's hardware test pushes a kept context
out with 4 other sizes.
What 4 kept contexts, each run once, freed as they went, by the driver's
fdinfo for the process: nothing on the Radeon 780M (radeonsi, m3-max-83634),
and 7,244 KiB of drm-total-system0, 28 KiB of it resident, on the Iris Xe
(i915, intel-media-driver 26.3.5, m3-max-83635), about 1.8 MiB a context.
Measured after, the same thumbnail on the same 780M, in one job alternating
A (this change) and B (the tree without it), each arm a boot of 6 sessions 4
s apart and 6 back to back (m3-max-83795): with it, every session but a
boot's first took 1.11 to 1.97 ms from its take to its signal (median 1.55
ms, 22 sessions), against 5.29 to 6.83 ms without it (median 6.12 ms); a
boot's first session of the size, on a new context, took 5.8 to 6.8 ms in
both. The guest's warm qlmanage thumbnail took 0.072 to 0.081 s with it and
0.075 to 0.090 s without.