Skip to content

fiemap: use hint index in get_extent to avoid O(n*m) extent lookups - #399

Open
zorbathut wants to merge 1 commit into
markfasheh:masterfrom
zorbathut:pr_linearextent
Open

fiemap: use hint index in get_extent to avoid O(n*m) extent lookups#399
zorbathut wants to merge 1 commit into
markfasheh:masterfrom
zorbathut:pr_linearextent

Conversation

@zorbathut

Copy link
Copy Markdown

During file scanning, get_extent() was called per-block with a linear scan from index 0. For fragmented files with many extents this made process_blocks and process_extents O(blocks * extents) per file.

Add a cursor hint to get_extent() that lets callers resume the search from where they left off, turning the common forward-scan case into O(blocks + extents). The hint is validated before use so a stale value silently falls back to a full scan.

Co-authored with Claude; improved and verified by me.

During file scanning, get_extent() was called per-block with a linear
scan from index 0. For fragmented files with many extents this made
process_blocks and process_extents O(blocks * extents) per file.

Add a cursor hint to get_extent() that lets callers resume the search
from where they left off, turning the common forward-scan case into
O(blocks + extents). The hint is validated before use so a stale value
silently falls back to a full scan.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

1 participant