Byte-Bounded LRU Cache for Memory-Mapped Market Data Blocks

Last updated: November 29, 2026

Quick Overview

Research jobs repeatedly read fixed-date blocks of a large stock-by-date data matrix from disk. Implement a cache that keeps recently used blocks in memory under a total byte budget, evicting least recently used blocks, and discuss where this design breaks.

Trexquant
Software Engineering Fundamentals
Software Engineer
Trexquant
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Research jobs repeatedly read fixed-date blocks of a large stock-by-date data matrix from disk. Implement a cache that keeps recently used blocks in memory under a total byte budget, evicting least recently used blocks, and discuss where this design breaks.

Research infrastructure at a quant fund spends much of its time moving large arrays between disk and memory, and C++ and Python infrastructure engineers are expected to reason about caching, memory budgets and access patterns. The interviewer checks a correct O(1) LRU and judgment about sizing by bytes, oversized items and scan-heavy workloads.

What the Interviewer Expects
  • Uses a hash map plus recency order for O(1) get and evict
  • Bounds by total bytes and evicts until the new block fits
  • Handles a block larger than the whole budget without thrashing
  • Tracks hits and misses for tuning
  • Discusses scan resistance and thread safety
Key Topics to Cover
LRU cache
memory management
hash map and linked list
cache eviction
data layout
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • A backtest scans every date once per run; how does plain LRU behave and what would you use instead?
  • How would you make this safe for many threads in one process?
  • When would you rely on the OS page cache through mmap instead of an application cache?
  • How would you lay out the matrix on disk for per-date versus per-stock access?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

get(key) returns the block for a key such as (field, date range), loading it with a supplied loader on a miss. Total cached bytes must never exceed capacity_bytes. Both hit and miss paths should...

High-Level Design

An OrderedDict gives a hash map with a doubly linked recency list: move_to_end on hit, popitem(last=False) to evict the least recently used entry. Keep a running used byte count. In C++ the sa...


Submit Your Answer
Markdown supported

Related Questions