Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fetch_add vs. compare_exchange

Benchmark C++ standard atomic operations fetch_add, fetch_or, and compare_exchange.

Two types of benchmarks:

  • refcount — aggressive concurrent usage of shared_ptr, implemented with:
    • std::atomic_compare_exchange_weak()
    • std::atomic_compare_exchange_strong()
    • std::atomic_fetch_sub()
    • baseline: std::shared_ptr
  • spinlock — aggressive concurrent usage of a spinlock, implemented with:
    • std::atomic_compare_exchange_weak()
    • std::atomic_compare_exchange_weak() + pause
    • std::atomic_compare_exchange_strong()
    • std::atomic_compare_exchange_strong() + pause
    • std::atomic_fetch_add()
    • std::atomic_fetch_or() + pause
    • baseline: std::mutex

Build:

make

Run benchmark (produces docs/result.csv):

make bench

Set up the Python venv for plotting (one-time):

./venv_install.sh

Show charts on screen:

make show

Render charts to PNG files:

make png

See docs/article.md for the full write-up and analysis.

About

Benchmark C++ standard atomic operations fetch_sub/fetch_add vs. compare_exchange

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages