Skip to content

Commit

Permalink
feat(virtio-net): increase max queue size to 512
Browse files Browse the repository at this point in the history
Increase of the queue size helps with keeping both
vmm thread and guest busy at high network load and
improves performance.

Signed-off-by: Egor Lazarchuk <[email protected]>
  • Loading branch information
ShadowCurse committed Oct 29, 2024
1 parent 8a42c2b commit 42aacca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/vmm/src/devices/virtio/net/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use libc::{iovec, EAGAIN};
use log::error;
use vmm_sys_util::eventfd::EventFd;

use super::NET_QUEUE_MAX_SIZE;
use crate::devices::virtio::device::{DeviceState, IrqTrigger, IrqType, VirtioDevice};
use crate::devices::virtio::gen::virtio_blk::VIRTIO_F_VERSION_1;
use crate::devices::virtio::gen::virtio_net::{
Expand Down Expand Up @@ -104,7 +105,7 @@ pub struct RxBuffers {
pub min_buffer_size: u32,
// An [`IoVecBufferMut`] covering all the memory we have available for receiving network
// frames.
pub iovec: IoVecBufferMut,
pub iovec: IoVecBufferMut<NET_QUEUE_MAX_SIZE>,
// A map of which part of the memory belongs to which `DescriptorChain` object
pub parsed_descriptors: VecDeque<ParsedDescriptorChain>,
// Buffers that we have used and they are ready to be given back to the guest.
Expand Down
6 changes: 3 additions & 3 deletions src/vmm/src/devices/virtio/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

use std::io;

use crate::devices::virtio::queue::FIRECRACKER_MAX_QUEUE_SIZE;

/// Maximum size of the queue for network device.
pub const NET_QUEUE_MAX_SIZE: u16 = 512;
/// Maximum size of the frame buffers handled by this device.
pub const MAX_BUFFER_SIZE: usize = 65562;
/// The number of queues of the network device.
pub const NET_NUM_QUEUES: usize = 2;
pub const NET_QUEUE_SIZES: [u16; NET_NUM_QUEUES] = [FIRECRACKER_MAX_QUEUE_SIZE; NET_NUM_QUEUES];
pub const NET_QUEUE_SIZES: [u16; NET_NUM_QUEUES] = [NET_QUEUE_MAX_SIZE; NET_NUM_QUEUES];
/// The index of the rx queue from Net device queues/queues_evts vector.
pub const RX_INDEX: usize = 0;
/// The index of the tx queue from Net device queues/queues_evts vector.
Expand Down
5 changes: 2 additions & 3 deletions src/vmm/src/devices/virtio/net/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ use std::sync::{Arc, Mutex};
use serde::{Deserialize, Serialize};

use super::device::{Net, RxBuffers};
use super::{TapError, NET_NUM_QUEUES, RX_INDEX};
use super::{TapError, NET_NUM_QUEUES, NET_QUEUE_MAX_SIZE, RX_INDEX};
use crate::devices::virtio::device::DeviceState;
use crate::devices::virtio::persist::{PersistError as VirtioStateError, VirtioDeviceState};
use crate::devices::virtio::queue::FIRECRACKER_MAX_QUEUE_SIZE;
use crate::devices::virtio::TYPE_NET;
use crate::mmds::data_store::Mmds;
use crate::mmds::ns::MmdsNetworkStack;
Expand Down Expand Up @@ -147,7 +146,7 @@ impl Persist<'_> for Net {
&constructor_args.mem,
TYPE_NET,
NET_NUM_QUEUES,
FIRECRACKER_MAX_QUEUE_SIZE,
NET_QUEUE_MAX_SIZE,
)?;
net.irq_trigger.irq_status = Arc::new(AtomicU32::new(state.virtio_state.interrupt_status));
net.avail_features = state.virtio_state.avail_features;
Expand Down

0 comments on commit 42aacca

Please sign in to comment.