Skip to content

Do not close file after mmap - #1017

Merged
prusnak merged 1 commit into
ggml-org:masterfrom
slaren:mmap-close-fix
Apr 16, 2023
Merged

prusnak merged 1 commit into
ggml-org:masterfrom
slaren:mmap-close-fix

Conversation

@slaren

@slaren slaren commented Apr 16, 2023

Copy link
Copy Markdown
Member

Fixes #963

@prusnak prusnak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no harm in not calling the close().

Since the underlying file is opened as read-only, the worst what can happen is that we will run out of file descriptors, which is hardly the case for llama.cpp.

Also, all file descriptors are closed by the kernel when the process exits.

@slaren

slaren commented Apr 16, 2023

Copy link
Copy Markdown
Member Author

The file should still be closed in the llama_file destructor, so I think this shouldn't cause any file descriptor leaks either.

@prusnak

prusnak commented Apr 16, 2023

Copy link
Copy Markdown
Contributor

The file should still be closed in the llama_file destructor, so I think this shouldn't cause any file descriptor leaks either.

Right. I just confirmed that close() in ~llama_file() is called even when mmap() is used.

@prusnak
prusnak merged commit 47f61aa into ggml-org:master Apr 16, 2023
@slaren
slaren deleted the mmap-close-fix branch April 17, 2023 15:52
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
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.

Android port error

2 participants