Skip to content

Add unit tests and architecture doc for page allocation and random I/O#4

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/analyze-64kb-page-allocation
Draft

Add unit tests and architecture doc for page allocation and random I/O#4
Copilot wants to merge 3 commits into
mainfrom
copilot/analyze-64kb-page-allocation

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 4, 2026

The repo had zero test coverage and no design documentation explaining how the 64KB page pool and random read/write mechanism work.

Tests (52 total)

  • PagePoolTests (16) — lazy vs pre-allocation, CAS capacity enforcement, batch rent/return via TryPopRange/PushRange, zeroed-on-return guarantee, concurrent rent/return correctness
  • PagedFileContentTests (21) — random read/write at arbitrary offsets, cross-page spanning writes, sparse page reads (unallocated → zeroes), three-phase write protocol under contention, truncation freeing pages + zeroing partial pages, capacity exhaustion returning -1
  • RamFileSystemTests (15) — file/directory CRUD, case-insensitive lookup, page lifecycle through delete, move preserving content, capacity tracking via pool delegation

Documentation

  • docs/page-allocation-and-random-io.md — explains the offset→pageIndex mapping (offset / pageSize), the three-phase write protocol (read-lock scan → lock-free batch allocate → write-lock memcpy), sparse file semantics, per-file ReaderWriterLockSlim vs global structure lock, and ConcurrentStack + CAS loop for lock-free page pool

Project

  • Enabled AllowUnsafeBlocks in test project (one test verifies pages are zeroed via raw pointer)

Copilot AI and others added 2 commits April 4, 2026 10:23
…itecture doc

- PagePoolTests: 16 tests covering 64KB page allocation, batch rent/return,
  capacity enforcement, CAS-based thread safety, pre-allocation, zeroed memory
- PagedFileContentTests: 21 tests covering random read/write at arbitrary
  offsets, cross-page I/O, sparse pages, truncation, concurrent access
- RamFileSystemTests: 15 tests covering file/directory CRUD, page-backed I/O,
  capacity tracking, move/rename
- docs/page-allocation-and-random-io.md: detailed architecture document
  explaining the page table design and three-phase write protocol

Agent-Logs-Url: https://github.com/hooyao/RamDrive/sessions/3ed842f7-01d0-43bb-81cd-292a29cfbcfa

Co-authored-by: hooyao <659145+hooyao@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate 64KB page allocation for random read/write support Add unit tests and architecture doc for page allocation and random I/O Apr 4, 2026
Copilot AI requested a review from hooyao April 4, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants