mwindow: set limit on number of open files

There are some cases in which repositories accrue a large number of
packfiles. The existing mwindow limit applies only to the total size of
mmap'd files, not on their number. This leads to a situation in which
having lots of small packfiles could exhaust the allowed number of open
files, particularly on macOS, where the default ulimit is very low
(256).

This change adds a new configuration parameter
(GIT_OPT_SET_MWINDOW_FILE_LIMIT) that sets the maximum number of open
packfiles, with a default of 128. This is low enough so that even macOS
users should not hit it during normal use.

Based on PR #5386, originally written by @josharian.

Fixes: #2758
This commit is contained in:
lhchavez
2020-02-08 20:47:24 +00:00
parent d43d490c38
commit 9679df5736
2060 changed files with 119 additions and 18 deletions

View File

@@ -205,7 +205,9 @@ typedef enum {
GIT_OPT_GET_PACK_MAX_OBJECTS,
GIT_OPT_SET_PACK_MAX_OBJECTS,
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS,
GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE
GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE,
GIT_OPT_GET_MWINDOW_FILE_LIMIT,
GIT_OPT_SET_MWINDOW_FILE_LIMIT
} git_libgit2_opt_t;
/**
@@ -227,8 +229,18 @@ typedef enum {
*
* * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
*
* >Set the maximum amount of memory that can be mapped at any time
* by the library
* > Set the maximum amount of memory that can be mapped at any time
* > by the library
*
* * opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, size_t *):
*
* > Get the maximum number of files that will be mapped at any time by the
* > library
*
* * opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, size_t):
*
* > Set the maximum number of files that can be mapped at any time
* > by the library
*
* * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
*