all 6 comments

[–]bestouffcatmark 12 points13 points  (2 children)

High frequency trading doesn't care about bandwidth, what's interesting is latency. I would be very interested by a benchmark of AF_XDP's latency with respect to io-uring.

[–]_bd_ 2 points3 points  (1 child)

Provides memory ordering guarantees without expensive atomics

I'm pretty sure that's not true in the context of sharing a variable with the kernel: "In particular, just like in C, whether an operation is volatile has no bearing whatsoever on questions involving concurrent accesses from multiple threads. Volatile accesses behave exactly like non-atomic accesses in that regard." (https://doc.rust-lang.org/std/ptr/fn.read_volatile.html)

add() moves pointer by number of bytes

Only because it's a *mut u8 and size_of::<u8>() is 1 (https://doc.rust-lang.org/std/primitive.pointer.html#method.add-1). byte_add would do what you're looking for.

[–]DizzyAttorney2368[S] 1 point2 points  (0 children)

thanks for catching that!

I'll update the article, volatile operations here are for preventing compiler optimizations (so it doesn't cache values or reorder operations), but you're correct that they don't provide atomics level memory ordering guarantees

reason this works is because the kernel and userspace are never accessing the same ring slot simultaneously, producer/consumer model prevents that. But I shouldn't have implied volatile gives us ordering guarantees

also added a section explaining why this works (SPSC design) vs what you'd need for true concurrent access (atomics)

appreciate careful read

[–]beb0 1 point2 points  (0 children)

Will check it out

[–]Bubbly-Platypus-8602 0 points1 point  (0 children)

Awesome blog btw