firecracker icon indicating copy to clipboard operation
firecracker copied to clipboard

Optimize event subscriber process implementation in virtio

Open andreeaflorescu opened this issue 5 years ago • 0 comments

After switching to the event-manager implementation from rust-vmm, we can optimize the process function that is called when events for virtio devices become available. As this code is on the critical path, we might get a noticeable performance improvement (finger crossed) on device emulation.

The optimization can be done by using Events::with_data when registering events for block/network/vsock devices and associating a u32 const data with each event. Then, in the process function, instead of using if to see what process_* function to call, we can do a match on consecutive u32 values which is going to be optimized by the compiler into a jump table.

One example of how this can be done can be found here: https://github.com/andreeaflorescu/event-manager/blob/design_doc/docs/DESIGN.md#using-events-with-custom-data

andreeaflorescu avatar May 21 '20 15:05 andreeaflorescu