On 12/17/24 12:22 PM, Bart Van Assche wrote: > On 12/16/24 8:16 PM, Christoph Hellwig wrote: >> On Mon, Dec 16, 2024 at 12:19:00PM -0800, Bart Van Assche wrote: >>> Help the CPU branch predictor in case of a cache hit by handling the cache >>> hit scenario first. >> >> Numbers, please. > > For a single CPU core and with the brd driver and fio and the io_uring > I/O engine, I see the following performance in a VM (three test runs for > each test case): > > Without this patch: 1619K, 1641K, 1638K IOPS or 1633 K +/- 10 K. > With this patch applied: 1650K, 1633K, 1635K IOPS or 1639 K +/- 8 K. > > So there is a small performance improvement but the improvement is > smaller than the measurement error. Is this sufficient data to proceed > with this patch? I think it's fine, it's going to be very hard to reliably measure. I tend to prefer the expected case to be the one checked for, eg: rq = get_cached(); if (rq) ... anyway, as then the expected outcome is what you're reading next anyway. Either that or rq = get_cached(); if (unlikely(!rq)) goto some_failure_path; If you really wanted to measure it, you'd probably skip the IOPS part and just look at branch misprediction in perf. -- Jens Axboe