Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Orderbook Implementations

Testing different orderbook implementations with live market data.

  1. Map - std::map
  2. Vector - sorted vector with binary search
  3. Vector (reversed) - reversed for better access patterns
  4. Vector (branchless) - branchless binary search
  5. Vector (likely) - compiler hints
  6. Vector (linear) - linear search

Results

Benchmarked on live BTC-USD data from Coinbase (100K warmup, 500K test):

Implementation P50 P90 P99 P99.9 Mean
Map 46 ns 99 ns 181 ns 306 ns 51 ns
Vector 10 ns 17 ns 25 ns 70 ns 11 ns
Vector (reversed) 11 ns 18 ns 27 ns 57 ns 12 ns
Vector (branchless) 10 ns 17 ns 33 ns 51 ns 12 ns
Vector (likely) 10 ns 15 ns 33 ns 42 ns 11 ns
Vector (linear) 80 ns 93 ns 100 ns 167 ns 84 ns

Branch Prediction

perf stat results on 50K modify operations:

Standard Binary Search:

  • Branches: 36.5B
  • Branch misses: 44.1M (0.12%)
  • Cycles: 70.1B
  • Instructions: 165.5B

Branchless Binary Search:

  • Branches: 19.3B (47% fewer)
  • Branch misses: 28.7M (0.15%)
  • Cycles: 37.3B (47% fewer)
  • Instructions: 87.6B (47% fewer)

Branchless doesn't predict branches better, it just removes them entirely.

Structure

src/             orderbook implementations + coinbase client
include/         headers
bench/           benchmarks (coinbase_live_bench, branch_test)
tests/           unit tests

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages