pack: move pack_report()
[git/git.git] / packfile.c
1 #include "cache.h"
2 #include "mru.h"
3
4 char *odb_pack_name(struct strbuf *buf,
5 const unsigned char *sha1,
6 const char *ext)
7 {
8 strbuf_reset(buf);
9 strbuf_addf(buf, "%s/pack/pack-%s.%s", get_object_directory(),
10 sha1_to_hex(sha1), ext);
11 return buf->buf;
12 }
13
14 char *sha1_pack_name(const unsigned char *sha1)
15 {
16 static struct strbuf buf = STRBUF_INIT;
17 return odb_pack_name(&buf, sha1, "pack");
18 }
19
20 char *sha1_pack_index_name(const unsigned char *sha1)
21 {
22 static struct strbuf buf = STRBUF_INIT;
23 return odb_pack_name(&buf, sha1, "idx");
24 }
25
26 unsigned int pack_used_ctr;
27 unsigned int pack_mmap_calls;
28 unsigned int peak_pack_open_windows;
29 unsigned int pack_open_windows;
30 unsigned int pack_open_fds;
31 unsigned int pack_max_fds;
32 size_t peak_pack_mapped;
33 size_t pack_mapped;
34 struct packed_git *packed_git;
35
36 static struct mru packed_git_mru_storage;
37 struct mru *packed_git_mru = &packed_git_mru_storage;
38
39 #define SZ_FMT PRIuMAX
40 static inline uintmax_t sz_fmt(size_t s) { return s; }
41
42 void pack_report(void)
43 {
44 fprintf(stderr,
45 "pack_report: getpagesize() = %10" SZ_FMT "\n"
46 "pack_report: core.packedGitWindowSize = %10" SZ_FMT "\n"
47 "pack_report: core.packedGitLimit = %10" SZ_FMT "\n",
48 sz_fmt(getpagesize()),
49 sz_fmt(packed_git_window_size),
50 sz_fmt(packed_git_limit));
51 fprintf(stderr,
52 "pack_report: pack_used_ctr = %10u\n"
53 "pack_report: pack_mmap_calls = %10u\n"
54 "pack_report: pack_open_windows = %10u / %10u\n"
55 "pack_report: pack_mapped = "
56 "%10" SZ_FMT " / %10" SZ_FMT "\n",
57 pack_used_ctr,
58 pack_mmap_calls,
59 pack_open_windows, peak_pack_open_windows,
60 sz_fmt(pack_mapped), sz_fmt(peak_pack_mapped));
61 }