Introduce new config option for mmap limit.
Rather than hardcoding the maximum number of bytes which can be mmapped from pack files we should make this value configurable, allowing the end user to increase or decrease this limit on a per-repository basis depending on the size of the repository and the capabilities of their operating system. In general users should not need to manually tune such a low-level setting within the core code, but being able to artifically limit the number of bytes which we can mmap at once from pack files will make it easier to craft test cases for the new mmap sliding window implementation. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
Dec 23, 2006 at 02:33 UTC
77ccc5bbd1bd403abd5f552be7210073bea856a6
5 files changed
+17
-2
Documentation/config.txt
+9
@@ -118,6 +118,15 @@ core.legacyheaders::
118
database directly (where the "http://" and "rsync://" protocols
119
count as direct access).
120
121
+core.packedGitLimit::
122
+ Maximum number of bytes to map simultaneously into memory
123
+ from pack files. If Git needs to access more than this many
124
+ bytes at once to complete an operation it will unmap existing
125
+ regions to reclaim virtual address space within the process.
126
+ Default is 256 MiB, which should be reasonable for all
127
+ users/operating systems, except on largest Git projects.
128
+ You probably do not need to adjust this value.
129
+
130
alias.*::
131
Command aliases for the gitlink:git[1] command wrapper - e.g.
132
after defining "alias.last = cat-file commit HEAD", the invocation
cache.h
+1
@@ -196,6 +196,7 @@ extern int warn_ambiguous_refs;
196
extern int shared_repository;
197
extern const char *apply_default_whitespace;
198
extern int zlib_compression_level;
199
+extern size_t packed_git_limit;
200
201
#define GIT_REPO_VERSION 0
202
extern int repository_format_version;
config.c
+5
@@ -298,6 +298,11 @@ int git_default_config(const char *var, const char *value)
298
return 0;
299
}
300
301
+ if (!strcmp(var, "core.packedgitlimit")) {
302
+ packed_git_limit = git_config_int(var, value);
303
+ return 0;
304
+ }
305
+
306
if (!strcmp(var, "user.name")) {
307
strlcpy(git_default_name, value, sizeof(git_default_name));
308
return 0;
environment.c
+1
@@ -23,6 +23,7 @@ char *git_log_output_encoding;
23
int shared_repository = PERM_UMASK;
24
const char *apply_default_whitespace;
25
int zlib_compression_level = Z_DEFAULT_COMPRESSION;
26
+size_t packed_git_limit = 256 * 1024 * 1024;
27
int pager_in_use;
28
int pager_use_color = 1;
29
sha1_file.c
+1
-2
@@ -397,7 +397,6 @@ static char *find_sha1_file(const unsigned char *sha1, struct stat *st)
397
return NULL;
398
}
399
400
-#define PACK_MAX_SZ (1<<26)
400
static int pack_used_ctr;
401
static unsigned long pack_mapped;
402
struct packed_git *packed_git;
@@ -490,7 +489,7 @@ int use_packed_git(struct packed_git *p)
489
struct pack_header *hdr;
490
491
pack_mapped += p->pack_size;
493
- while (PACK_MAX_SZ < pack_mapped && unuse_one_packed_git())
492
+ while (packed_git_limit < pack_mapped && unuse_one_packed_git())
493
; /* nothing */
494
fd = open(p->pack_name, O_RDONLY);
495
if (fd < 0)