Execution — Storage Primitives

Prerequisites

You've completed the toolchain setup in ../../TOOLS.md. To confirm:

rustc --version      # ≥ 1.78
go version           # ≥ 1.22
clang++ --version    # ≥ 16  (or g++ ≥ 13)
cmake --version      # ≥ 3.28

Quick Start — All Three Languages

From the lab root:

# Rust
( cd src/rust && cargo build --release )
./src/rust/target/release/pagealloc write /tmp/lab01.bin 0 "hello, disk"
./src/rust/target/release/pagealloc read  /tmp/lab01.bin 0
./src/rust/target/release/pagealloc hexdump /tmp/lab01.bin

# Go
( cd src/go && go build -o /tmp/pagealloc-go ./cmd/pagealloc )
/tmp/pagealloc-go write /tmp/lab01.bin 0 "hello, disk"
/tmp/pagealloc-go read  /tmp/lab01.bin 0
/tmp/pagealloc-go hexdump /tmp/lab01.bin

# C++
( cd src/cpp && cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build build )
./src/cpp/build/pagealloc write /tmp/lab01.bin 0 "hello, disk"
./src/cpp/build/pagealloc read  /tmp/lab01.bin 0
./src/cpp/build/pagealloc hexdump /tmp/lab01.bin

All three binaries are byte-compatible — write with one, read with another, get the same bytes.

CLI Reference (all three implementations)

CommandEffect
pagealloc write <file> <page_no> <ascii_string>Write the ASCII bytes (zero-padded to 4 KiB) into page page_no. Calls fsync before returning.
pagealloc read <file> <page_no>pread page page_no (4 KiB), print bytes up to first null.
pagealloc hexdump <file>Walk the whole file 4 KiB at a time and print a canonical hex dump (16 bytes/line).
pagealloc bench <file> <pages> <iters>Random pread benchmark: file is preallocated to pages pages, then iters random reads are timed.

Tests

# Rust
( cd src/rust && cargo test )

# Go
( cd src/go && go test ./... )

# C++
( cd src/cpp && cmake --build build && ctest --test-dir build --output-on-failure )

Each test suite covers:

  1. Round-trip: write then read returns the same bytes.
  2. Cross-implementation: a file written by Rust must read correctly with the Go and C++ binaries (run by scripts/cross_test.sh).
  3. fsync is called on write (verified by strace -e fsync in the cross_test script on Linux).
  4. Endianness sanity: the page header uses little-endian and is identical across implementations.

Environment Variables

VariableDefaultEffect
DSE_PAGE_SIZE4096Override page size (must be a power of two). Only consume in the pagealloc bench subcommand.
DSE_FSYNC1If 0, skip fsync on write. Only for benchmarking — never in production.