izard: (Default)
[personal profile] izard
Here is a simple patch I made at work last week (the code below is not real):


int insert_packet_hdr_to_ring_buffer(ring_buffer *buf, packet_hdr *pkt)
{
// here goes a complex logic for lock-free ringbuffer,
// in the end we have ringbuffer pointers updated and in *pkt_ptr there is a pointer
// to store the packet header
- *pkt_ptr = *pkt;
+ memcpy(pkt_ptr, pkt, packet_len);

return 0;
}

This change brought ~5% speedup to the benchmark, replacing copying structure that spans on 2 cache lines element by element to SIMD copy from libc.

Profile

izard: (Default)
izard

July 2025

S M T W T F S
  12345
67 8 91011 12
13141516171819
20212223242526
2728293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 20th, 2025 03:53 am
Powered by Dreamwidth Studios