michaelmelanson / michaelmelanson/panda-os

Block I/O: Write coalescing for batched virtio requests

Open
#38 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

drivers enhancement performance
Dominant language
Rust
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Summary

Implement write coalescing in the block layer to batch multiple small writes into single larger virtio requests, reducing virtio overhead. This will be important once ext2 write support (#38) is implemented.

## Current state

- The virtio block driver submits one request per write operation
- Each request has fixed overhead: descriptor allocation, queue notification, interrupt handling
- Many small writes (e.g., updating metadata blocks) each incur this full overhead

## Desired behaviour

- Buffer small writes and flush them as a single larger request
- Coalesce adjacent sector writes into contiguous ranges
- Configurable flush policy: flush on buffer full, explicit sync, or timer
- Maintain write ordering guarantees where required (e.g., metadata before data for crash consistency)

## Key files

- `panda-kernel/src/drivers/virtio_block/` — write coalescing buffer
- New write buffer layer between VFS and block driver
- Pairs with scatter-gather (#36) for efficient batched submission

## Implementation notes

- Write buffer tracks dirty sectors with their data
- On flush: sort by sector, merge adjacent ranges, submit as scatter-gather requests
- Need a flush-on-sync path for `fsync`-like operations
- Consider write barriers for filesystem consistency (metadata ordering)
- The buffer size should be bounded to limit memory usage

## Testing

- Kernel test: multiple small writes followed by read-back, verify data integrity
- Kernel test: verify writes are actually coalesced (fewer virtio submissions than write calls)
- Test explicit flush/sync triggers write-out
- Test write ordering: metadata writes before data writes when barriers are used
- Stress test: many concurrent small writes, verify no data loss

## Documentation

- Document the write coalescing algorithm and flush policies
- Document write ordering guarantees and barrier semantics
- Document buffer size limits and configuration

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in panda-kernel/src/drivers/virtio_block/ and trace the write path from the VFS to the virtio block driver. Define the bounded write buffer, flush and ordering behavior described in the issue, then add kernel tests for read-back integrity, coalescing, explicit sync, barriers, and concurrent writes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.