mishukh/ultra-low-latency-exchange ? reverse-engineered prompt

Reverse engineered prompt

Build me a C++ in memory exchange simulator that matches limit orders as fast as possible.

I want a simple three thread flow, one thread for incoming orders, one thread for the matching engine, and one thread for reading out market data and metrics. Use lock free single producer single consumer queues between the threads, and keep the matching logic single threaded so it stays deterministic. Please avoid heap allocation during normal operation by using a preallocated memory pool, and make order lookups instant with a flat array instead of a map. Also add clear metrics for latency, throughput, accepted orders, rejected orders, matched trades, and any backpressure or pool exhaustion.

Make sure there are tests, and include whatever tuning is needed so the engine stays low latency under large order counts. If you need to check current docs for anything, look them up online.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab