@matheusbsbs / matheus-bagliano / commits / 78a28df938
Fork 0

sha1_file.c: Round the mmap offset to half the window size.

This ensures that a given area is mapped at most twice, and greatly reduces the virtual address space usage. Signed-off-by: Alexandre Julliard <julliard@winehq.org> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Alexandre Julliard committed Feb 14, 2007 at 18:11 UTC 78a28df9388cccb1ec85aa5642808f0d3392155f
1 file changed +3 -5
sha1_file.c
+3 -5
@@ -407,7 +407,6 @@ static unsigned int peak_pack_open_windows;
407 static unsigned int pack_open_windows;
408 static size_t peak_pack_mapped;
409 static size_t pack_mapped;
410 -static size_t page_size;
410 struct packed_git *packed_git;
411
412 void pack_report()
@@ -416,7 +415,7 @@ void pack_report()
415 "pack_report: getpagesize() = %10" SZ_FMT "\n"
416 "pack_report: core.packedGitWindowSize = %10" SZ_FMT "\n"
417 "pack_report: core.packedGitLimit = %10" SZ_FMT "\n",
419 - page_size,
418 + (size_t) getpagesize(),
419 packed_git_window_size,
420 packed_git_limit);
421 fprintf(stderr,
@@ -662,10 +661,9 @@ unsigned char* use_pack(struct packed_git *p,
661 break;
662 }
663 if (!win) {
665 - if (!page_size)
666 - page_size = getpagesize();
664 + size_t window_align = packed_git_window_size / 2;
665 win = xcalloc(1, sizeof(*win));
668 - win->offset = (offset / page_size) * page_size;
666 + win->offset = (offset / window_align) * window_align;
667 win->len = p->pack_size - win->offset;
668 if (win->len > packed_git_window_size)
669 win->len = packed_git_window_size;