hermit-os / kernel

A Rust-based, lightweight unikernel.
http://hermit-os.org
Apache License 2.0
1.15k stars 84 forks source link

virtio: consider avoiding dynamic dispatch with `enum_dispatch` #989

Open mkroening opened 9 months ago

mkroening commented 9 months ago

Before 02860f2, there was an enum for abstracting over split and packed virtqueues:

pub enum Virtq {
    Packed(PackedVq),
    Split(SplitVq),
}

Currently, we are using a trait via Rc<dyn Virtq> instead of Rc<Virtq>.

We need to consider automating the previous enum-based static dispatch via enum_dispatch for performance. This would be a nice fit because restricting the set of implementors is no problem for us.

This might not have a too much of an impact, depending on how hot these dynamic dispatches are right now.

cagatay-y commented 2 months ago

I think we can close this issue since using a trait and trait objects worked out for SplitVq and PackedVqs.

mkroening commented 2 months ago

I think we can close this issue since using a trait and trait objects worked out for SplitVq and PackedVqs.

This issue is about potential performance improvements, not about whether we need it to work at all. I have reworked the description.

This issue might be interesting for @CarlWachter, who will be working on benchmarking.

CC: @jounathaen