Hi everyone,
I am new to Rust, and I am working on rewriting Open vSwitch's flow extracting logic using Rust to take advantage of Rust's memory safety feature. Basically, the flow extraction logic is used in the fast path packet processing to parse the packet headers. The rust implementation is build as a shared library, and it is used with the FFI to link with the rest of the Open vSwitch's C implementation.
When I am comparing the performance between the original and Rust implementations, I found that my Rust implementation is much slower on the packet forwarding performance. I then use the Linux perf tools to do some profiling. From the perf report as below, it looks most of the time consuming parts are the BitVec processing which is used to mark if a particular field in the packet header is set or not.
I am wondering if there are some faster bit vector crate for this use case? I found a couple of them from crate.io, such as Vector of Bits (Vob), bitvector, etc.., but not sure which one will be the best fit. I would appreciate any comment and feedback.
Thanks!
16.23% pmd-c06/id:6 libovsflowrust.so [.] bitvec::pointer::BitPtr<T>::from_bitslice
5.10% pmd-c06/id:6 libovsflowrust.so [.] bitvec::store::BitIdx::offset
3.40% pmd-c06/id:6 libovsflowrust.so [.] bitvec::slice::BitSlice<C,T>::bitptr
2.84% pmd-c06/id:6 libovsflowrust.so [.] <T as core::convert::Into<U>>::into
2.79% pmd-c06/id:6 libovsflowrust.so [.] bitvec::slice::BitSlice<C,T>::get_unchecked
2.70% pmd-c06/id:6 libovsflowrust.so [.] core::num::<impl isize>::overflowing_add
2.69% pmd-c06/id:6 libovsflowrust.so [.] core::ptr::<impl *mut T>::is_null
2.29% pmd-c06/id:6 libovsflowrust.so [.] bitvec::slice::BitSlice<C,T>::len
2.16% pmd-c06/id:6 libovsflowrust.so [.] bitvec::store::BitStore::get_at
1.84% pmd-c06/id:6 libovsflowrust.so [.] bitvec::pointer::BitPtr<T>::head
1.69% pmd-c06/id:6 libovsflowrust.so [.] core::ptr::non_null::NonNull<T>::new_unchecked
1.58% pmd-c06/id:6 libovsflowrust.so [.] <bitvec::store::BitIdx as core::convert::From<u8>>::from
1.56% pmd-c06/id:6 libovsflowrust.so [.] ovsflowrust::miniflow::mf_ctx::assert_bv_map_not_set
1.56% pmd-c06/id:6 libovsflowrust.so [.] <bitvec::cursor::LittleEndian as bitvec::cursor::Cursor>::at
1.49% pmd-c06/id:6 libovsflowrust.so [.] bitvec::slice::BitSlice<C,T>::as_ptr
1.48% pmd-c06/id:6 libovsflowrust.so [.] <bitvec::slice::BitSlice<C,T> as core::ops::index::Index<usize>>::index
1.48% pmd-c06/id:6 libovsflowrust.so [.] bitvec::slice::BitSlice<C,T>::set_unchecked
1.46% pmd-c06/id:6 libovsflowrust.so [.] core::slice::<impl [T]>::len
1.45% pmd-c06/id:6 libovsflowrust.so [.] <bitvec::pointer::Pointer<T> as core::convert::From<*const T>>::from
1.41% pmd-c06/id:6 libovsflowrust.so [.] bitvec::pointer::Pointer<T>::w
1.39% pmd-c06/id:6 libovsflowrust.so [.] bitvec::store::BitIdx::is_valid
1.28% pmd-c06/id:6 libovsflowrust.so [.] bitvec::pointer::BitPtr<T>::pointer
1.22% pmd-c06/id:6 libovsflowrust.so [.] core::slice::<impl [T]>::as_ptr
1.11% pmd-c06/id:6 libovsflowrust.so [.] <bitvec::store::BitIdx as core::ops::deref::Deref>::deref