Skip to content

Do not close file after mmap#1017

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

Do not close file after mmap#1017
prusnak merged 1 commit intoggml-org:masterfrom
slaren:mmap-close-fix

Conversation

@slaren
Copy link
Copy Markdown
Member

@slaren slaren commented Apr 16, 2023

Fixes #963

Copy link
Copy Markdown
Contributor

@prusnak prusnak left a comment

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
Copy link
Copy Markdown
Member Author

slaren commented Apr 16, 2023

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

@prusnak
Copy link
Copy Markdown
Contributor

prusnak commented Apr 16, 2023

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
Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
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