low latency tunning

一些资料

1. Hardware tuning

1.1 Disable hyper-threading

减少对CPU竞争,也减少对cache的竞争

1.2 Enable Turbo Boost

开启超频,但是需要好的冷却设备

2. Kernel tuning

2.1 Use the performance CPU frequency scaling governor

通过内核设置CPU性能模式。

2.2 Isolate cores

绑定核, 关闭swap

3. programming tricks

3.1 branch

考虑使用 likely / unlikely,在编译器层面上优化,intel已经没有static branch hints。

在stable rust中可以使用#[cold],标记在函数上,提示llvm这个函数很少被调用,llvm可能因此做一些编译上的调整。

const generics

对于rust,可以考虑将函数入参移到const generics位置,可以减少分支,详见 https://blog.cocl2.com/posts/const-currying-rs/

还包括大页(减少TLB cache miss),合理使用cache,避免false sharing,减少锁竞争,合理使用SIMD,网络参数设置等等,还是要看实际情况。