[UDFS] Implement faster free space search via roving pointer and allocation optimisations#346
[UDFS] Implement faster free space search via roving pointer and allocation optimisations#346Copilot wants to merge 10 commits into
Conversation
…allocation Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/cbd173f2-9a6b-443e-a62f-e23a2b84999f Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…ments Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/cbd173f2-9a6b-443e-a62f-e23a2b84999f Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…aths Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/457d9284-f86a-40a5-8dd6-c34f0c8b8f50 Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…ointer in alloc.c Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/d6dc60b1-2014-42b3-89fd-578ad73aa8ce Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a simple “roving pointer” hint to UDFS free-space allocation so the bitmap scan can start near the last successful allocation (reducing repeated scans from the beginning of a partition), along with additional AdPrint diagnostics to trace hint application, fallback, and persistence.
Changes:
- Introduce
VCB::BitmapSearchHintto remember the next preferred LBA search start for free space allocation. - Update
UDFAllocFreeExtent_to:- apply the hint when it falls within the caller’s
[SearchStart, SearchLim)range, - fall back to a full-range scan when the hint-range yields nothing,
- advance and persist the hint on successful allocation.
- apply the hint when it falls within the caller’s
- Add
AdPrintmessages for hint application, fallback, and updates.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| drivers/filesystems/udfs/udf_info/alloc.cpp | Applies/persists a bitmap search hint during free extent allocation, with debug tracing. |
| drivers/filesystems/udfs/struct.h | Adds BitmapSearchHint to VCB to store the roving-pointer LBA hint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot Is/are there any other code block(s) that can benefit from the same improvement? |
No other code blocks can benefit from the same improvement. |
|
@copilot Does any other code do full disk searching? |
Yes, several functions iterate over all partition blocks, but none of them are doing a free-space search that could benefit from a roving pointer:
All of these must process their entire range by design (initialization, sync, or full export). The roving-pointer hint only applies when searching for the best free extent to satisfy an allocation request, which only |
|
@copilot Can any of the performance improvements from #335 be implemented? |
…tion, dir pre-alloc, coalesced FE write Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/06cc0c82-c9cd-4105-8d76-e0c33424d7bf Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Yes — all three optimizations from PR #335 are now implemented in commit
Additionally, |
|
@copilot How about switching number 1 in the list to use the roving pointer instead? |
… roving pointer Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/3e5c385c-9e82-46b0-b8f3-9a2ff7c4f30d Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…edundant calls Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/3e5c385c-9e82-46b0-b8f3-9a2ff7c4f30d Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Done in commit |
|
@copilot shouldn't the other performance improvements be kept? |
Yes, all the other improvements are still present — only the
|
Implements a roving-pointer bitmap search hint and several allocation optimisations for the UDF filesystem driver to reduce I/O overhead when allocating file entries and creating many files.
Changes
Roving-pointer bitmap search hint (
BitmapSearchHint)BitmapSearchHintfield to the VCB (struct.h)UDFAllocFreeExtent_now starts the bitmap scan at the hint LBA and falls back to a full-range scan when the hint-range yields nothing, advancing and persisting the hint after each successful allocation (alloc.cpp)AdPrintdiagnostics added for hint application, fallback, and persistenceUDFAllocateFESpaceandUDFResizeExtentnow callUDFAllocFreeExtentdirectly for the full partition range — theBitmapSearchHintroving pointer insideUDFAllocFreeExtent_provides locality automatically by starting each scan near the last successful allocation, replacing the previousLastAllocatedFELbawindow-probe mechanism (extent.cpp)Minimum directory pre-allocation (
UDF_DIR_PREALLOC_MIN_SECTORS=8)WriteBlockSize) to amortise per-sector cold-write spikes across many file additions (udf_info.cpp)Coalesced FE sector write (
UDF_FE_FLAG_NEW_SECTOR)UDF_FE_FLAG_NEW_SECTORflag (udf_rel.h)UDFCreateFile__(non-CDR path), the explicit zero-write of the FE sector is skipped and the flag is set insteadUDFFlushFEchecks the flag and writes a single zero-padded full-sector buffer, reducing the previous 2-I/O sequence to 1 I/O per file creation (udf_info.cpp)UDFRecordDirectory__correctness fixUDFFlushFEcall afterUDFIndexDirectoryso the on-disk FE reflects the updatedfileType = DIRECTORYimmediately, preventing a corrupt FE on crash-before-close (udf_info.cpp)