Cache Line Eviction Simulator
What this preview is
Cache Line Eviction Simulator is a hard quant coding problem on computer architecture in Python, asked at Quant.
- Difficulty
- Hard
- Topic
- Computer Architecture
- Discipline
- Quant development
- Language
- Python
Building a set-associative cache simulator with LRU eviction
This hard coding problem is representative of the systems-performance work that high-frequency trading firms like DE Shaw use to squeeze latency out of trading systems. It tests whether you can correctly implement a non-trivial hardware model: a set-associative cache with LRU (Least Recently Used) eviction and dirty-line tracking.
The core challenge is maintaining the invariants: computing set indices and tags from byte addresses, tracking recency order within each set without inefficiency, recognizing hits vs. misses, and crucially, counting writebacks only when a dirty line is evicted. Many candidates slip on the address-to-set/tag mapping, the mechanics of LRU ordering, or the conditions under which a writeback occurs. The problem requires careful bookkeeping across up to 100,000 accesses and tight correctness.
- Set-associative cache architecture and address decomposition
- LRU replacement policy and efficient ordering maintenance
- Hit vs. miss classification and cache state transitions
- Dirty bit tracking and writeback counting
Unlock full access to getcracked
Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.