Create pack_report() as a debugging aid.
Much like the alloc_report() function can be useful to report on object allocation statistics while debugging the new pack_report() function can be useful to report on the behavior of the mmap window code used for packfile access. 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:34 UTC
a53128b60162d7a84adca4206540df5b8e3d9dc8
2 files changed
+32
cache.h
+1
@@ -398,6 +398,7 @@ extern void install_packed_git(struct packed_git *pack);
398
extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
399
struct packed_git *packs);
400
401
+extern void pack_report();
402
extern unsigned char* use_pack(struct packed_git *, struct pack_window **, unsigned long, unsigned int *);
403
extern void unuse_pack(struct pack_window **);
404
extern struct packed_git *add_packed_git(char *, int, int);
sha1_file.c
+31
@@ -398,10 +398,34 @@ static char *find_sha1_file(const unsigned char *sha1, struct stat *st)
398
}
399
400
static unsigned int pack_used_ctr;
401
+static unsigned int pack_mmap_calls;
402
+static unsigned int peak_pack_open_windows;
403
+static unsigned int pack_open_windows;
404
+static size_t peak_pack_mapped;
405
static size_t pack_mapped;
406
static size_t page_size;
407
struct packed_git *packed_git;
408
409
+void pack_report()
410
+{
411
+ fprintf(stderr,
412
+ "pack_report: getpagesize() = %10lu\n"
413
+ "pack_report: core.packedGitWindowSize = %10lu\n"
414
+ "pack_report: core.packedGitLimit = %10lu\n",
415
+ page_size,
416
+ packed_git_window_size,
417
+ packed_git_limit);
418
+ fprintf(stderr,
419
+ "pack_report: pack_used_ctr = %10u\n"
420
+ "pack_report: pack_mmap_calls = %10u\n"
421
+ "pack_report: pack_open_windows = %10u / %10u\n"
422
+ "pack_report: pack_mapped = %10lu / %10lu\n",
423
+ pack_used_ctr,
424
+ pack_mmap_calls,
425
+ pack_open_windows, peak_pack_open_windows,
426
+ pack_mapped, peak_pack_mapped);
427
+}
428
+
429
static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
430
void **idx_map_)
431
{
@@ -492,6 +516,7 @@ static int unuse_one_window(struct packed_git *current)
516
}
517
}
518
free(lru_w);
519
+ pack_open_windows--;
520
return 1;
521
}
522
return 0;
@@ -605,6 +630,12 @@ unsigned char* use_pack(struct packed_git *p,
630
die("packfile %s cannot be mapped: %s",
631
p->pack_name,
632
strerror(errno));
633
+ pack_mmap_calls++;
634
+ pack_open_windows++;
635
+ if (pack_mapped > peak_pack_mapped)
636
+ peak_pack_mapped = pack_mapped;
637
+ if (pack_open_windows > peak_pack_open_windows)
638
+ peak_pack_open_windows = pack_open_windows;
639
win->next = p->windows;
640
p->windows = win;
641
}