refactor(common): extract gguf_mmap RAII wrapper as standalone PR#243
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
No issues found across 140 files
Note: This PR contains a large number of files. cubic only reviews up to 100 files per PR, so some files may not have been reviewed. cubic prioritizes the most important files to review.
On a pro plan you can use ultrareview for larger PRs.
Re-trigger cubic
Per @howard0su's review on Luce-Org#237: gguf_mmap.h/.cpp are platform abstraction (POSIX mmap / Windows MapViewOfFile) that will be reused by multiple loaders. Extracting into a standalone PR ahead of the loader refactor (target/draft/MTP heads all benefit). Includes the cubic P1 fixes from f6e8e94: - open() is now idempotent (releases prior mapping before re-opening, leaves object in default state on any failure path) - Windows release() now calls CloseHandle() before clearing handle_ New: test_gguf_mmap unit test covers open/close, idempotency, missing-file path, RAII destructor. Stacked on Luce-Org#241 (uses dflash::common namespace from the start).
daeaa17 to
80e06a4
Compare
Contributor
There was a problem hiding this comment.
1 issue found across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Per cubic P3 on PR Luce-Org#243: T2's success check was tautological and didn't verify that the error string is empty after a successful open(). Replaced with assert(err.empty()).
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.
Summary
Per @howard0su's review on #237 ("this worth a separate PR"): the gguf_mmap RAII wrapper for platform-conditional mmap of GGUF files is platform abstraction reusable by multiple loaders (target, draft, MTP head). Pulling it out of #237 into its own PR ahead of the loader refactor sequence.
Logically stacked on #241 (namespace rename) so this PR uses
dflash::commonfrom the start. Will diff cleanly againstmainonce #241 merges; until then, the diff also includes the namespace rename commit.What's in
dflash/src/common/gguf_mmap.h(219 lines, header-only, post cubic-P1 fixes from f6e8e94)dflash/test/test_gguf_mmap.cpp— new unit test (5 cases, all passing)Cubic P1 fixes preserved
open()is now idempotent: releases any prior mapping before re-opening, leaves the object in its default empty state on any failure pathrelease()now callsCloseHandle()before clearinghandle_(was leaking the file-mapping HANDLE)Test coverage
What's not in
No consumers in this PR. The MTP / target / draft loaders that will use it land in later PRs of the sequence. This PR is the pure abstraction.