Scope split-mode graph mmap to the tensor being loaded. Prevents memory leak#2126
Draft
Farmadupe wants to merge 1 commit into
Draft
Scope split-mode graph mmap to the tensor being loaded. Prevents memory leak#2126Farmadupe wants to merge 1 commit into
Farmadupe wants to merge 1 commit into
Conversation
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.
#2102 introduced a change where staging buffers for tensor reads were swapped from anonymous memory to mmaped memory. For some reason (read: "I failed at devibing the prototype") these allocations were freed using
llama_mmap::dontneed_fragmentwhich delegates to posixMADV_DONTNEEDinstead of just letting them drop out of scopellama_mmap::dontneed_fragment is a no-op on windows and this caused memory pressure and a regression in model load times.
Fix is to let the mmaps drop out of scope. This also removes the need for the windows workaround introduced in #2121, as this fixes the issue at the root cause.
The change is complete but I will flip to ready once I have tested on Windows.