feat: add sector-aligned mmap flush#3
Open
jgwesterlund wants to merge 1 commit intofeat/write-coalescingfrom
Open
feat: add sector-aligned mmap flush#3jgwesterlund wants to merge 1 commit intofeat/write-coalescingfrom
jgwesterlund wants to merge 1 commit intofeat/write-coalescingfrom
Conversation
Add sector_size parameter to flush only aligned mmap regions covering written data instead of the entire mapping. Integrates with both direct writes and wrap marker writes. Falls back to full flush when sector_size=0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
What does this change do?
Adds a
sector_sizeparameter to flush only the sector-aligned mmap regions covering written data, instead of flushing the entire mapping. Integrates with both direct writes and wrap marker writes.Why is this needed?
On block devices with specific sector sizes (e.g., SD cards with 512 or 4096-byte sectors), full-mapping flushes are expensive. Sector-aligned flushing targets only the modified sectors, improving write performance on constrained devices.
Type of change
How was this tested?
4 new tests in
tests/test_extended.py:sector_size=0falls back to normal flushAll 47 tests pass, 98% coverage, ruff clean, mypy clean.
Checklist
Notes for reviewers
This PR is based on
feat/write-coalescing(PR #2) since sector-aligned flush integrates with the coalesced flush path.The flush alignment uses
max(sector_size, mmap.PAGESIZE)to satisfy macOS page-alignment requirements for msync.Docs updated:
usage.md,api.md.