Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faster lock than pthreads

We are building an extremely latency sensitive application. Our full application takes about 2500 clock cycles in a process apart from locking, and there are two locks that need to be acquired and released. We expect no contention 99.98% of the time. Using pthread lock and unlock takes about 1800 additional cycles. Any pointers in faster formulations ? Writing locks based on atomic operations might be tricky. We would prefer using standard code as in Linux headers or boost headers if possible.

like image 242
Humble Debugger Avatar asked Aug 07 '26 19:08

Humble Debugger


1 Answers

As a suggestion, try spin_mutex from Intel's Threading Building Blocks library. It's open-source (GPLv2), so you can also inspect sources for implementation details.

Also you may look at this: Is my spin lock implementation correct and optimal?

like image 152
Alexey Kukanov Avatar answered Aug 10 '26 15:08

Alexey Kukanov