core: log offset pack data accesses happened
In a workload other than "git log" (without pathspec nor any option that causes us to inspect trees and blobs), the recency pack order is said to cause the access jump around quite a bit. Add a hook to allow us observe how bad it is. "git config core.logpackaccess /var/tmp/pal.txt" will give you the log in the specified file. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 6, 2011 at 19:08 UTC
5f44324d88a6a6699bc30912b26784ac0ade638d
4 files changed
+28
cache.h
+3
@@ -784,6 +784,9 @@ extern int force_object_loose(const unsigned char *sha1, time_t mtime);
784
/* global flag to enable extra checks when accessing packed objects */
785
extern int do_check_packed_object_crc;
786
787
+/* for development: log offset of pack access */
788
+extern const char *log_pack_access;
789
+
790
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
791
792
extern int move_temp_to_file(const char *tmpfile, const char *filename);
config.c
+3
@@ -569,6 +569,9 @@ static int git_default_core_config(const char *var, const char *value)
569
return 0;
570
}
571
572
+ if (!strcmp(var, "core.logpackaccess"))
573
+ return git_config_string(&log_pack_access, var, value);
574
+
575
if (!strcmp(var, "core.autocrlf")) {
576
if (value && !strcasecmp(value, "input")) {
577
if (core_eol == EOL_CRLF)
environment.c
+1
@@ -36,6 +36,7 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
36
size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
37
size_t delta_base_cache_limit = 16 * 1024 * 1024;
38
unsigned long big_file_threshold = 512 * 1024 * 1024;
39
+const char *log_pack_access;
40
const char *pager_program;
41
int pager_use_color = 1;
42
const char *editor_program;
sha1_file.c
+21
@@ -1839,6 +1839,24 @@ static void *unpack_delta_entry(struct packed_git *p,
1839
return result;
1840
}
1841
1842
+static void write_pack_access_log(struct packed_git *p, off_t obj_offset)
1843
+{
1844
+ static FILE *log_file;
1845
+
1846
+ if (!log_file) {
1847
+ log_file = fopen(log_pack_access, "w");
1848
+ if (!log_file) {
1849
+ error("cannot open pack access log '%s' for writing: %s",
1850
+ log_pack_access, strerror(errno));
1851
+ log_pack_access = NULL;
1852
+ return;
1853
+ }
1854
+ }
1855
+ fprintf(log_file, "%s %"PRIuMAX"\n",
1856
+ p->pack_name, (uintmax_t)obj_offset);
1857
+ fflush(log_file);
1858
+}
1859
+
1860
int do_check_packed_object_crc;
1861
1862
void *unpack_entry(struct packed_git *p, off_t obj_offset,
@@ -1848,6 +1866,9 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
1866
off_t curpos = obj_offset;
1867
void *data;
1868
1869
+ if (log_pack_access)
1870
+ write_pack_access_log(p, obj_offset);
1871
+
1872
if (do_check_packed_object_crc && p->index_version > 1) {
1873
struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
1874
unsigned long len = revidx[1].offset - obj_offset;