Most database servers have limited RAM to process data. When datasets grow or resources are limited, data systems rely on disk storage (of course for other reasons too). However, disk I/O is far slower than RAM. This makes smart utilization and minimal disk access critical for implementing efficient and effective data management systems.
In this assignment you will design a query execution engine that operates under a strict memory budget, optimizing it for minimal disk I/O and efficient in-memory computations.
┌─────────────────────────────────────────────────────┐
│ Monitor │
│ (spawns processes, sends queries, validates output)│
└──────────────┬──────────────────────┬───────────────┘
│ FD 5 (query in) │ FD 6 (results / commands out)
▼ ▲
┌──────────────────────────────────────────────────────┐
│ Database (YOU) │
│ reads query → accesses disk → outputs result rows │
└──────────────┬──────────────────────┬────────────────┘
│ FD 4 (commands out) │ FD 3 (block data in)
▼ ▲
┌──────────────────────────────────────────────────────┐
│ Disk Simulator │
│ (block storage, tracks I/O for scoring) │
└──────────────────────────────────────────────────────┘
To give you a hands-on experience with building data systems, we’ve designed an in-house system in Rust comprising three components:
You typically need to touch only the database/ directory.
The monitor maps the following file descriptors for your database process at startup:
| FD | Direction | Purpose |
|---|---|---|
| 3 | Read | Receive data from disk simulator |
| 4 | Write | Send commands to disk simulator |
| 5 | Read | Receive data from monitor (query JSON) |
| 6 | Write | Send data to monitor (results/commands) |
These are already wired up in database/src/io_setup.rs — you do not need to open any files or sockets yourself.
The monitor enforces the following hard limits on your database process:
RLIMIT_AS), including the stack
(RLIMIT_STACK). Note, you will not be able to load entire tables into memory as they typically will be of several gigabytes.RLIMIT_NPROC = 1).RLIMIT_FSIZE = 0). Use the disk
simulator’s anonymous space for any scratch storage.