{"thread":{"id":"36973","subject":"[PATCH v6 00/11] add performance tracing facility","startedAt":"2014-06-20T21:03:17Z","lastAt":"2014-06-21T00:33:47Z","messageCount":17,"participants":["Karsten Blees","Junio C Hamano","Philip Oakley"],"isPatch":true,"patchVersion":6,"patchTotal":11},"messages":[{"id":"244806","messageId":"53A4A195.1070502@gmail.com","threadId":"36973","inReplyTo":null,"subject":"[PATCH v6 00/11] add performance tracing facility","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:03:17Z","receivedAt":"2014-06-20T21:03:17Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Changes since v5:\n[05/11]: GIT_TRACE_BARE=1 disables 'timestamp file:line' output for\n         unit tests that rely on trace output (t1510 and t5503)\n[08/11]: Align original trace output at col 40\n[09/11]: Dropped '(div 10e9)' from the commit message.\n[10/11]: Dropped trace_performance[_since]() return value and the\n         respective usage example. Renamed trace_performance_vfl to\n         trace_performance_vprintf_fl.\n\nThe other patches are the versions from pu.\n\nKarsten Blees (11):\n  trace: move trace declarations from cache.h to new trace.h\n  trace: consistently name the format parameter\n  trace: remove redundant printf format attribute\n  trace: factor out printing to the trace file\n  trace: add infrastructure to augment trace output with additional info\n  trace: add current timestamp to all trace output\n  trace: move code around, in preparation to file:line output\n  trace: add 'file:line' to all trace output\n  trace: add high resolution timer function to debug performance issues\n  trace: add trace_performance facility to debug performance issues\n  git: add performance tracing for git's main() function to debug\n    scripts\n\n Makefile              |   7 ++\n cache.h               |  13 +--\n config.mak.uname      |   1 +\n git-compat-util.h     |   4 +\n git.c                 |   2 +\n t/t1510-repo-setup.sh |   2 +-\n t/t5503-tagfollow.sh  |   8 +-\n trace.c               | 313 ++++++++++++++++++++++++++++++++++++++++++++------\n trace.h               |  90 +++++++++++++++\n 9 files changed, 387 insertions(+), 53 deletions(-)\n create mode 100644 trace.h\n\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244807","messageId":"53A4A1C6.3060307@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 01/11] trace: move trace declarations from cache.h to new trace.h","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:04:06Z","receivedAt":"2014-06-20T21:04:06Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Also include direct dependencies (strbuf.h and git-compat-util.h for\n__attribute__) so that trace.h can be used independently of cache.h, e.g.\nin test programs.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n cache.h | 13 ++-----------\n trace.h | 17 +++++++++++++++++\n 2 files changed, 19 insertions(+), 11 deletions(-)\n create mode 100644 trace.h\n\ndiff --git a/cache.h b/cache.h\nindex cbe1935..466f6b3 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -7,6 +7,7 @@\n #include \"advice.h\"\n #include \"gettext.h\"\n #include \"convert.h\"\n+#include \"trace.h\"\n \n #include SHA1_HEADER\n #ifndef git_SHA_CTX\n@@ -1377,17 +1378,7 @@ extern void *alloc_tag_node(void);\n extern void *alloc_object_node(void);\n extern void alloc_report(void);\n \n-/* trace.c */\n-__attribute__((format (printf, 1, 2)))\n-extern void trace_printf(const char *format, ...);\n-__attribute__((format (printf, 2, 3)))\n-extern void trace_argv_printf(const char **argv, const char *format, ...);\n-extern void trace_repo_setup(const char *prefix);\n-extern int trace_want(const char *key);\n-__attribute__((format (printf, 2, 3)))\n-extern void trace_printf_key(const char *key, const char *fmt, ...);\n-extern void trace_strbuf(const char *key, const struct strbuf *buf);\n-\n+/* pkt-line.c */\n void packet_trace_identity(const char *prog);\n \n /* add */\ndiff --git a/trace.h b/trace.h\nnew file mode 100644\nindex 0000000..6cc4541\n--- /dev/null\n+++ b/trace.h\n@@ -0,0 +1,17 @@\n+#ifndef TRACE_H\n+#define TRACE_H\n+\n+#include \"git-compat-util.h\"\n+#include \"strbuf.h\"\n+\n+__attribute__((format (printf, 1, 2)))\n+extern void trace_printf(const char *format, ...);\n+__attribute__((format (printf, 2, 3)))\n+extern void trace_argv_printf(const char **argv, const char *format, ...);\n+extern void trace_repo_setup(const char *prefix);\n+extern int trace_want(const char *key);\n+__attribute__((format (printf, 2, 3)))\n+extern void trace_printf_key(const char *key, const char *fmt, ...);\n+extern void trace_strbuf(const char *key, const struct strbuf *buf);\n+\n+#endif /* TRACE_H */\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244808","messageId":"53A4A1E0.5020208@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 02/11] trace: consistently name the format parameter","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:04:32Z","receivedAt":"2014-06-20T21:04:32Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"The format parameter to trace_printf functions is sometimes abbreviated\n'fmt'. Rename to 'format' everywhere (consistent with POSIX' printf\nspecification).\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n trace.c | 22 +++++++++++-----------\n trace.h |  2 +-\n 2 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/trace.c b/trace.c\nindex 08180a9..37a7fa9 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -62,7 +62,7 @@ static int get_trace_fd(const char *key, int *need_close)\n static const char err_msg[] = \"Could not trace into fd given by \"\n \t\"GIT_TRACE environment variable\";\n \n-static void trace_vprintf(const char *key, const char *fmt, va_list ap)\n+static void trace_vprintf(const char *key, const char *format, va_list ap)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \n@@ -70,25 +70,25 @@ static void trace_vprintf(const char *key, const char *fmt, va_list ap)\n \t\treturn;\n \n \tset_try_to_free_routine(NULL);\t/* is never reset */\n-\tstrbuf_vaddf(&buf, fmt, ap);\n+\tstrbuf_vaddf(&buf, format, ap);\n \ttrace_strbuf(key, &buf);\n \tstrbuf_release(&buf);\n }\n \n __attribute__((format (printf, 2, 3)))\n-void trace_printf_key(const char *key, const char *fmt, ...)\n+void trace_printf_key(const char *key, const char *format, ...)\n {\n \tva_list ap;\n-\tva_start(ap, fmt);\n-\ttrace_vprintf(key, fmt, ap);\n+\tva_start(ap, format);\n+\ttrace_vprintf(key, format, ap);\n \tva_end(ap);\n }\n \n-void trace_printf(const char *fmt, ...)\n+void trace_printf(const char *format, ...)\n {\n \tva_list ap;\n-\tva_start(ap, fmt);\n-\ttrace_vprintf(\"GIT_TRACE\", fmt, ap);\n+\tva_start(ap, format);\n+\ttrace_vprintf(\"GIT_TRACE\", format, ap);\n \tva_end(ap);\n }\n \n@@ -106,7 +106,7 @@ void trace_strbuf(const char *key, const struct strbuf *buf)\n \t\tclose(fd);\n }\n \n-void trace_argv_printf(const char **argv, const char *fmt, ...)\n+void trace_argv_printf(const char **argv, const char *format, ...)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tva_list ap;\n@@ -117,8 +117,8 @@ void trace_argv_printf(const char **argv, const char *fmt, ...)\n \t\treturn;\n \n \tset_try_to_free_routine(NULL);\t/* is never reset */\n-\tva_start(ap, fmt);\n-\tstrbuf_vaddf(&buf, fmt, ap);\n+\tva_start(ap, format);\n+\tstrbuf_vaddf(&buf, format, ap);\n \tva_end(ap);\n \n \tsq_quote_argv(&buf, argv, 0);\ndiff --git a/trace.h b/trace.h\nindex 6cc4541..8fea50b 100644\n--- a/trace.h\n+++ b/trace.h\n@@ -11,7 +11,7 @@ extern void trace_argv_printf(const char **argv, const char *format, ...);\n extern void trace_repo_setup(const char *prefix);\n extern int trace_want(const char *key);\n __attribute__((format (printf, 2, 3)))\n-extern void trace_printf_key(const char *key, const char *fmt, ...);\n+extern void trace_printf_key(const char *key, const char *format, ...);\n extern void trace_strbuf(const char *key, const struct strbuf *buf);\n \n #endif /* TRACE_H */\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244809","messageId":"53A4A206.8070905@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 03/11] trace: remove redundant printf format attribute","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:05:10Z","receivedAt":"2014-06-20T21:05:10Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"trace_printf_key() is the only non-static function that duplicates the\nprintf format attribute in the .c file, remove it for consistency.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n trace.c | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/trace.c b/trace.c\nindex 37a7fa9..3e31558 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -75,7 +75,6 @@ static void trace_vprintf(const char *key, const char *format, va_list ap)\n \tstrbuf_release(&buf);\n }\n \n-__attribute__((format (printf, 2, 3)))\n void trace_printf_key(const char *key, const char *format, ...)\n {\n \tva_list ap;\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244810","messageId":"53A4A228.5090500@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 04/11] trace: factor out printing to the trace file","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:05:44Z","receivedAt":"2014-06-20T21:05:44Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Opening and writing to the trace file is currently duplicated in\ntrace_strbuf() and trace_argv_printf(). Factor out this logic to prepare\nfor adding timestamp and file:line to trace output.\n\nIn case of trace_argv_printf(), this adds an additional trace_want() check\nto prevent unnecessary string formatting.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n trace.c | 37 +++++++++++++++++++------------------\n 1 file changed, 19 insertions(+), 18 deletions(-)\n\ndiff --git a/trace.c b/trace.c\nindex 3e31558..b7ca51b 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -62,6 +62,21 @@ static int get_trace_fd(const char *key, int *need_close)\n static const char err_msg[] = \"Could not trace into fd given by \"\n \t\"GIT_TRACE environment variable\";\n \n+/* Print 'buf' verbatim to trace file designated by env var 'key' */\n+static void do_trace_print(const char *key, const struct strbuf *buf)\n+{\n+\tint fd, need_close = 0;\n+\n+\tfd = get_trace_fd(key, &need_close);\n+\tif (!fd)\n+\t\treturn;\n+\n+\twrite_or_whine_pipe(fd, buf->buf, buf->len, err_msg);\n+\n+\tif (need_close)\n+\t\tclose(fd);\n+}\n+\n static void trace_vprintf(const char *key, const char *format, va_list ap)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n@@ -71,7 +86,7 @@ static void trace_vprintf(const char *key, const char *format, va_list ap)\n \n \tset_try_to_free_routine(NULL);\t/* is never reset */\n \tstrbuf_vaddf(&buf, format, ap);\n-\ttrace_strbuf(key, &buf);\n+\tdo_trace_print(key, &buf);\n \tstrbuf_release(&buf);\n }\n \n@@ -93,26 +108,15 @@ void trace_printf(const char *format, ...)\n \n void trace_strbuf(const char *key, const struct strbuf *buf)\n {\n-\tint fd, need_close = 0;\n-\n-\tfd = get_trace_fd(key, &need_close);\n-\tif (!fd)\n-\t\treturn;\n-\n-\twrite_or_whine_pipe(fd, buf->buf, buf->len, err_msg);\n-\n-\tif (need_close)\n-\t\tclose(fd);\n+\tdo_trace_print(key, buf);\n }\n \n void trace_argv_printf(const char **argv, const char *format, ...)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tva_list ap;\n-\tint fd, need_close = 0;\n \n-\tfd = get_trace_fd(\"GIT_TRACE\", &need_close);\n-\tif (!fd)\n+\tif (!trace_want(\"GIT_TRACE\"))\n \t\treturn;\n \n \tset_try_to_free_routine(NULL);\t/* is never reset */\n@@ -122,11 +126,8 @@ void trace_argv_printf(const char **argv, const char *format, ...)\n \n \tsq_quote_argv(&buf, argv, 0);\n \tstrbuf_addch(&buf, '\\n');\n-\twrite_or_whine_pipe(fd, buf.buf, buf.len, err_msg);\n+\tdo_trace_print(\"GIT_TRACE\", &buf);\n \tstrbuf_release(&buf);\n-\n-\tif (need_close)\n-\t\tclose(fd);\n }\n \n static const char *quote_crnl(const char *path)\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244811","messageId":"53A4A267.2060907@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 05/11] trace: add infrastructure to augment trace output with additional info","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:06:47Z","receivedAt":"2014-06-20T21:06:47Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"To be able to add a common prefix or suffix to all trace output (e.g.\na timestamp or file:line of the caller), factor out common setup and\ncleanup tasks of the trace* functions.\n\nSome unit-tests use trace output to verify internal state, and variable\noutput such as timestamps and line numbers are not useful there. Disable\nadditional trace output if GIT_TRACE_BARE is set.\n\nWhen adding a common prefix, it makes sense that the output of each trace\ncall starts on a new line. Add '\\n' in case the caller forgot.\n\nNote that this explicitly limits trace output to line-by-line, it is no\nlonger possible to trace-print just part of a line. Until now, this was\njust an implicit assumption (trace-printing part of a line worked, but\nmessed up the trace file if multiple threads or processes were involved).\n\nThread-safety / inter-process-safety is also the reason why we need to do\nthe prefixing and suffixing in memory rather than issuing multiple write()\ncalls. Write_or_whine_pipe() / xwrite() is atomic unless the size exceeds\nMAX_IO_SIZE (8MB, see wrapper.c). In case of trace_strbuf, this costs an\nadditional string copy (which should be irrelevant for performance in light\nof actual file IO).\n\nWhile we're at it, rename trace_strbuf's 'buf' argument, which suggests\nthat the function is modifying the buffer. Trace_strbuf() currently is the\nonly trace API that can print arbitrary binary data (without barfing on\n'%' or stopping at '\\0'), so 'data' seems more appropriate.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n t/t1510-repo-setup.sh |  2 +-\n t/t5503-tagfollow.sh  |  8 ++++----\n trace.c               | 53 ++++++++++++++++++++++++++++++++++++++++-----------\n trace.h               |  2 +-\n 4 files changed, 48 insertions(+), 17 deletions(-)\n\ndiff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh\nindex e1b2a99..8db8d68 100755\n--- a/t/t1510-repo-setup.sh\n+++ b/t/t1510-repo-setup.sh\n@@ -57,7 +57,7 @@ test_repo () {\n \t\t\texport GIT_WORK_TREE\n \t\tfi &&\n \t\trm -f trace &&\n-\t\tGIT_TRACE_SETUP=\"$(pwd)/trace\" git symbolic-ref HEAD >/dev/null &&\n+\t\tGIT_TRACE_BARE=1 GIT_TRACE_SETUP=\"$(pwd)/trace\" git symbolic-ref HEAD >/dev/null &&\n \t\tgrep '^setup: ' trace >result &&\n \t\ttest_cmp expected result\n \t)\ndiff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh\nindex f30c038..dc10143 100755\n--- a/t/t5503-tagfollow.sh\n+++ b/t/t5503-tagfollow.sh\n@@ -56,7 +56,7 @@ test_expect_success 'fetch A (new commit : 1 connection)' '\n \trm -f $U &&\n \t(\n \t\tcd cloned &&\n-\t\tGIT_TRACE_PACKET=$UPATH git fetch &&\n+\t\tGIT_TRACE_BARE=1 GIT_TRACE_PACKET=$UPATH git fetch &&\n \t\ttest $A = $(git rev-parse --verify origin/master)\n \t) &&\n \tget_needs $U >actual &&\n@@ -86,7 +86,7 @@ test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '\n \trm -f $U &&\n \t(\n \t\tcd cloned &&\n-\t\tGIT_TRACE_PACKET=$UPATH git fetch &&\n+\t\tGIT_TRACE_BARE=1 GIT_TRACE_PACKET=$UPATH git fetch &&\n \t\ttest $C = $(git rev-parse --verify origin/cat) &&\n \t\ttest $T = $(git rev-parse --verify tag1) &&\n \t\ttest $A = $(git rev-parse --verify tag1^0)\n@@ -122,7 +122,7 @@ test_expect_success 'fetch B, S (commit and tag : 1 connection)' '\n \trm -f $U &&\n \t(\n \t\tcd cloned &&\n-\t\tGIT_TRACE_PACKET=$UPATH git fetch &&\n+\t\tGIT_TRACE_BARE=1 GIT_TRACE_PACKET=$UPATH git fetch &&\n \t\ttest $B = $(git rev-parse --verify origin/master) &&\n \t\ttest $B = $(git rev-parse --verify tag2^0) &&\n \t\ttest $S = $(git rev-parse --verify tag2)\n@@ -146,7 +146,7 @@ test_expect_success 'new clone fetch master and tags' '\n \t\tcd clone2 &&\n \t\tgit init &&\n \t\tgit remote add origin .. &&\n-\t\tGIT_TRACE_PACKET=$UPATH git fetch &&\n+\t\tGIT_TRACE_BARE=1 GIT_TRACE_PACKET=$UPATH git fetch &&\n \t\ttest $B = $(git rev-parse --verify origin/master) &&\n \t\ttest $S = $(git rev-parse --verify tag2) &&\n \t\ttest $B = $(git rev-parse --verify tag2^0) &&\ndiff --git a/trace.c b/trace.c\nindex b7ca51b..9fa406e 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -77,17 +77,45 @@ static void do_trace_print(const char *key, const struct strbuf *buf)\n \t\tclose(fd);\n }\n \n+static int trace_bare = -1;\n+\n+static int prepare_trace_line(const char *key, struct strbuf *buf)\n+{\n+\tif (!trace_want(key))\n+\t\treturn 0;\n+\n+\tset_try_to_free_routine(NULL);\t/* is never reset */\n+\n+\t/* unit tests may want to disable additional trace output */\n+\tif (trace_bare < 0)\n+\t\ttrace_bare = trace_want(\"GIT_TRACE_BARE\");\n+\tif (trace_bare)\n+\t\treturn 1;\n+\n+\t/* add line prefix here */\n+\n+\treturn 1;\n+}\n+\n+static void print_trace_line(const char *key, struct strbuf *buf)\n+{\n+\t/* append newline if missing */\n+\tif (buf->len && buf->buf[buf->len - 1] != '\\n')\n+\t\tstrbuf_addch(buf, '\\n');\n+\n+\tdo_trace_print(key, buf);\n+\tstrbuf_release(buf);\n+}\n+\n static void trace_vprintf(const char *key, const char *format, va_list ap)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tif (!trace_want(key))\n+\tif (!prepare_trace_line(key, &buf))\n \t\treturn;\n \n-\tset_try_to_free_routine(NULL);\t/* is never reset */\n \tstrbuf_vaddf(&buf, format, ap);\n-\tdo_trace_print(key, &buf);\n-\tstrbuf_release(&buf);\n+\tprint_trace_line(key, &buf);\n }\n \n void trace_printf_key(const char *key, const char *format, ...)\n@@ -106,9 +134,15 @@ void trace_printf(const char *format, ...)\n \tva_end(ap);\n }\n \n-void trace_strbuf(const char *key, const struct strbuf *buf)\n+void trace_strbuf(const char *key, const struct strbuf *data)\n {\n-\tdo_trace_print(key, buf);\n+\tstruct strbuf buf = STRBUF_INIT;\n+\n+\tif (!prepare_trace_line(key, &buf))\n+\t\treturn;\n+\n+\tstrbuf_addbuf(&buf, data);\n+\tprint_trace_line(key, &buf);\n }\n \n void trace_argv_printf(const char **argv, const char *format, ...)\n@@ -116,18 +150,15 @@ void trace_argv_printf(const char **argv, const char *format, ...)\n \tstruct strbuf buf = STRBUF_INIT;\n \tva_list ap;\n \n-\tif (!trace_want(\"GIT_TRACE\"))\n+\tif (!prepare_trace_line(\"GIT_TRACE\", &buf))\n \t\treturn;\n \n-\tset_try_to_free_routine(NULL);\t/* is never reset */\n \tva_start(ap, format);\n \tstrbuf_vaddf(&buf, format, ap);\n \tva_end(ap);\n \n \tsq_quote_argv(&buf, argv, 0);\n-\tstrbuf_addch(&buf, '\\n');\n-\tdo_trace_print(\"GIT_TRACE\", &buf);\n-\tstrbuf_release(&buf);\n+\tprint_trace_line(\"GIT_TRACE\", &buf);\n }\n \n static const char *quote_crnl(const char *path)\ndiff --git a/trace.h b/trace.h\nindex 8fea50b..e03db2f 100644\n--- a/trace.h\n+++ b/trace.h\n@@ -12,6 +12,6 @@ extern void trace_repo_setup(const char *prefix);\n extern int trace_want(const char *key);\n __attribute__((format (printf, 2, 3)))\n extern void trace_printf_key(const char *key, const char *format, ...);\n-extern void trace_strbuf(const char *key, const struct strbuf *buf);\n+extern void trace_strbuf(const char *key, const struct strbuf *data);\n \n #endif /* TRACE_H */\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244812","messageId":"53A4A282.20209@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 06/11] trace: add current timestamp to all trace output","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:07:14Z","receivedAt":"2014-06-20T21:07:14Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"This is useful to tell apart trace output of separate test runs.\n\nIt can also be used for basic, coarse-grained performance analysis. Note\nthat the accuracy is tainted by writing to the trace file, and you have to\ncalculate the deltas yourself (which is next to impossible if multiple\nthreads or processes are involved).\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n trace.c | 11 ++++++++++-\n 1 file changed, 10 insertions(+), 1 deletion(-)\n\ndiff --git a/trace.c b/trace.c\nindex 9fa406e..9fa6cc7 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -81,6 +81,10 @@ static int trace_bare = -1;\n \n static int prepare_trace_line(const char *key, struct strbuf *buf)\n {\n+\tstruct timeval tv;\n+\tstruct tm tm;\n+\ttime_t secs;\n+\n \tif (!trace_want(key))\n \t\treturn 0;\n \n@@ -92,7 +96,12 @@ static int prepare_trace_line(const char *key, struct strbuf *buf)\n \tif (trace_bare)\n \t\treturn 1;\n \n-\t/* add line prefix here */\n+\t/* print current timestamp */\n+\tgettimeofday(&tv, NULL);\n+\tsecs = tv.tv_sec;\n+\tlocaltime_r(&secs, &tm);\n+\tstrbuf_addf(buf, \"%02d:%02d:%02d.%06ld \", tm.tm_hour, tm.tm_min,\n+\t\t    tm.tm_sec, tv.tv_usec);\n \n \treturn 1;\n }\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244813","messageId":"53A4A2A4.9050906@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 07/11] trace: move code around, in preparation to file:line output","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:07:48Z","receivedAt":"2014-06-20T21:07:48Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"No functional changes, just move stuff around so that the next patch isn't\nthat ugly...\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n trace.c | 36 ++++++++++++++++++------------------\n trace.h | 12 ++++++++----\n 2 files changed, 26 insertions(+), 22 deletions(-)\n\ndiff --git a/trace.c b/trace.c\nindex 9fa6cc7..869fb7b 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -127,20 +127,20 @@ static void trace_vprintf(const char *key, const char *format, va_list ap)\n \tprint_trace_line(key, &buf);\n }\n \n-void trace_printf_key(const char *key, const char *format, ...)\n+void trace_argv_printf(const char **argv, const char *format, ...)\n {\n+\tstruct strbuf buf = STRBUF_INIT;\n \tva_list ap;\n-\tva_start(ap, format);\n-\ttrace_vprintf(key, format, ap);\n-\tva_end(ap);\n-}\n \n-void trace_printf(const char *format, ...)\n-{\n-\tva_list ap;\n+\tif (!prepare_trace_line(\"GIT_TRACE\", &buf))\n+\t\treturn;\n+\n \tva_start(ap, format);\n-\ttrace_vprintf(\"GIT_TRACE\", format, ap);\n+\tstrbuf_vaddf(&buf, format, ap);\n \tva_end(ap);\n+\n+\tsq_quote_argv(&buf, argv, 0);\n+\tprint_trace_line(\"GIT_TRACE\", &buf);\n }\n \n void trace_strbuf(const char *key, const struct strbuf *data)\n@@ -154,20 +154,20 @@ void trace_strbuf(const char *key, const struct strbuf *data)\n \tprint_trace_line(key, &buf);\n }\n \n-void trace_argv_printf(const char **argv, const char *format, ...)\n+void trace_printf(const char *format, ...)\n {\n-\tstruct strbuf buf = STRBUF_INIT;\n \tva_list ap;\n-\n-\tif (!prepare_trace_line(\"GIT_TRACE\", &buf))\n-\t\treturn;\n-\n \tva_start(ap, format);\n-\tstrbuf_vaddf(&buf, format, ap);\n+\ttrace_vprintf(\"GIT_TRACE\", format, ap);\n \tva_end(ap);\n+}\n \n-\tsq_quote_argv(&buf, argv, 0);\n-\tprint_trace_line(\"GIT_TRACE\", &buf);\n+void trace_printf_key(const char *key, const char *format, ...)\n+{\n+\tva_list ap;\n+\tva_start(ap, format);\n+\ttrace_vprintf(key, format, ap);\n+\tva_end(ap);\n }\n \n static const char *quote_crnl(const char *path)\ndiff --git a/trace.h b/trace.h\nindex e03db2f..5c7f2dc 100644\n--- a/trace.h\n+++ b/trace.h\n@@ -4,14 +4,18 @@\n #include \"git-compat-util.h\"\n #include \"strbuf.h\"\n \n-__attribute__((format (printf, 1, 2)))\n-extern void trace_printf(const char *format, ...);\n-__attribute__((format (printf, 2, 3)))\n-extern void trace_argv_printf(const char **argv, const char *format, ...);\n extern void trace_repo_setup(const char *prefix);\n extern int trace_want(const char *key);\n+\n+__attribute__((format (printf, 1, 2)))\n+extern void trace_printf(const char *format, ...);\n+\n __attribute__((format (printf, 2, 3)))\n extern void trace_printf_key(const char *key, const char *format, ...);\n+\n+__attribute__((format (printf, 2, 3)))\n+extern void trace_argv_printf(const char **argv, const char *format, ...);\n+\n extern void trace_strbuf(const char *key, const struct strbuf *data);\n \n #endif /* TRACE_H */\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244814","messageId":"53A4A2CD.8010003@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 08/11] trace: add 'file:line' to all trace output","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:08:29Z","receivedAt":"2014-06-20T21:08:29Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"This is useful to see where trace output came from.\n\nAdd 'const char *file, int line' parameters to the printing functions and\nrename them to *_fl.\n\nAdd trace_printf* and trace_strbuf macros resolving to the *_fl functions\nand let the preprocessor fill in __FILE__ and __LINE__.\n\nAs the trace_printf* functions take a variable number of arguments, this\nrequires variadic macros (i.e. '#define foo(...) foo_impl(__VA_ARGS__)'.\nThough part of C99, it is unclear whether older compilers support this.\nThus keep the old functions and only enable variadic macros for GNUC and\nMSVC 2005+ (_MSC_VER 1400). This has the nice side effect that the old\nC-style declarations serve as documentation how the macros are to be used.\n\nPrint 'file:line ' as prefix to each trace line. Align the remaining trace\noutput at column 40 to accommodate 18 char file names + 4 digit line\nnumber (currently there are 30 *.c files of length 18 and just 11 of 19).\nTrace output from longer source files (e.g. builtin/receive-pack.c) will\nnot be aligned.\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n git-compat-util.h |  4 ++++\n trace.c           | 72 +++++++++++++++++++++++++++++++++++++++++++++----------\n trace.h           | 49 +++++++++++++++++++++++++++++++++++++\n 3 files changed, 113 insertions(+), 12 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex b6f03b3..4dd065d 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -704,6 +704,10 @@ void git_qsort(void *base, size_t nmemb, size_t size,\n #endif\n #endif\n \n+#if defined(__GNUC__) || (_MSC_VER >= 1400)\n+#define HAVE_VARIADIC_MACROS 1\n+#endif\n+\n /*\n  * Preserves errno, prints a message, but gives no warning for ENOENT.\n  * Always returns the return value of unlink(2).\ndiff --git a/trace.c b/trace.c\nindex 869fb7b..5844f31 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -79,7 +79,8 @@ static void do_trace_print(const char *key, const struct strbuf *buf)\n \n static int trace_bare = -1;\n \n-static int prepare_trace_line(const char *key, struct strbuf *buf)\n+static int prepare_trace_line(const char *file, int line, const char *key,\n+\t\t\t      struct strbuf *buf)\n {\n \tstruct timeval tv;\n \tstruct tm tm;\n@@ -103,6 +104,14 @@ static int prepare_trace_line(const char *key, struct strbuf *buf)\n \tstrbuf_addf(buf, \"%02d:%02d:%02d.%06ld \", tm.tm_hour, tm.tm_min,\n \t\t    tm.tm_sec, tv.tv_usec);\n \n+#ifdef HAVE_VARIADIC_MACROS\n+\t/* print file:line */\n+\tstrbuf_addf(buf, \"%s:%d \", file, line);\n+\t/* align trace output (column 40 catches most files names in git) */\n+\twhile (buf->len < 40)\n+\t\tstrbuf_addch(buf, ' ');\n+#endif\n+\n \treturn 1;\n }\n \n@@ -116,49 +125,52 @@ static void print_trace_line(const char *key, struct strbuf *buf)\n \tstrbuf_release(buf);\n }\n \n-static void trace_vprintf(const char *key, const char *format, va_list ap)\n+static void trace_vprintf_fl(const char *file, int line, const char *key,\n+\t\t\t     const char *format, va_list ap)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tif (!prepare_trace_line(key, &buf))\n+\tif (!prepare_trace_line(file, line, key, &buf))\n \t\treturn;\n \n \tstrbuf_vaddf(&buf, format, ap);\n \tprint_trace_line(key, &buf);\n }\n \n-void trace_argv_printf(const char **argv, const char *format, ...)\n+static void trace_argv_vprintf_fl(const char *file, int line,\n+\t\t\t\t  const char **argv, const char *format,\n+\t\t\t\t  va_list ap)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n-\tva_list ap;\n \n-\tif (!prepare_trace_line(\"GIT_TRACE\", &buf))\n+\tif (!prepare_trace_line(file, line, \"GIT_TRACE\", &buf))\n \t\treturn;\n \n-\tva_start(ap, format);\n \tstrbuf_vaddf(&buf, format, ap);\n-\tva_end(ap);\n \n \tsq_quote_argv(&buf, argv, 0);\n \tprint_trace_line(\"GIT_TRACE\", &buf);\n }\n \n-void trace_strbuf(const char *key, const struct strbuf *data)\n+void trace_strbuf_fl(const char *file, int line, const char *key,\n+\t\t     const struct strbuf *data)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tif (!prepare_trace_line(key, &buf))\n+\tif (!prepare_trace_line(file, line, key, &buf))\n \t\treturn;\n \n \tstrbuf_addbuf(&buf, data);\n \tprint_trace_line(key, &buf);\n }\n \n+#ifndef HAVE_VARIADIC_MACROS\n+\n void trace_printf(const char *format, ...)\n {\n \tva_list ap;\n \tva_start(ap, format);\n-\ttrace_vprintf(\"GIT_TRACE\", format, ap);\n+\ttrace_vprintf_fl(NULL, 0, \"GIT_TRACE\", format, ap);\n \tva_end(ap);\n }\n \n@@ -166,10 +178,46 @@ void trace_printf_key(const char *key, const char *format, ...)\n {\n \tva_list ap;\n \tva_start(ap, format);\n-\ttrace_vprintf(key, format, ap);\n+\ttrace_vprintf_fl(NULL, 0, key, format, ap);\n \tva_end(ap);\n }\n \n+void trace_argv_printf(const char **argv, const char *format, ...)\n+{\n+\tva_list ap;\n+\tva_start(ap, format);\n+\ttrace_argv_vprintf_fl(NULL, 0, argv, format, ap);\n+\tva_end(ap);\n+}\n+\n+void trace_strbuf(const char *key, const struct strbuf *data)\n+{\n+\ttrace_strbuf_fl(NULL, 0, key, data);\n+}\n+\n+#else\n+\n+void trace_printf_key_fl(const char *file, int line, const char *key,\n+\t\t\t const char *format, ...)\n+{\n+\tva_list ap;\n+\tva_start(ap, format);\n+\ttrace_vprintf_fl(file, line, key, format, ap);\n+\tva_end(ap);\n+}\n+\n+void trace_argv_printf_fl(const char *file, int line, const char **argv,\n+\t\t\t  const char *format, ...)\n+{\n+\tva_list ap;\n+\tva_start(ap, format);\n+\ttrace_argv_vprintf_fl(file, line, argv, format, ap);\n+\tva_end(ap);\n+}\n+\n+#endif /* HAVE_VARIADIC_MACROS */\n+\n+\n static const char *quote_crnl(const char *path)\n {\n \tstatic char new_path[PATH_MAX];\ndiff --git a/trace.h b/trace.h\nindex 5c7f2dc..916dc2b 100644\n--- a/trace.h\n+++ b/trace.h\n@@ -7,6 +7,8 @@\n extern void trace_repo_setup(const char *prefix);\n extern int trace_want(const char *key);\n \n+#ifndef HAVE_VARIADIC_MACROS\n+\n __attribute__((format (printf, 1, 2)))\n extern void trace_printf(const char *format, ...);\n \n@@ -18,4 +20,51 @@ extern void trace_argv_printf(const char **argv, const char *format, ...);\n \n extern void trace_strbuf(const char *key, const struct strbuf *data);\n \n+#else\n+\n+/*\n+ * Macros to add file:line - see above for C-style declarations of how these\n+ * should be used.\n+ */\n+\n+/*\n+ * Note: with C99 variadic macros, __VA_ARGS__ must include the last fixed\n+ * parameter ('format' in this case). Otherwise, a call without variable\n+ * arguments will have a surplus ','. E.g.:\n+ *\n+ *  #define foo(format, ...) bar(format, __VA_ARGS__)\n+ *  foo(\"test\");\n+ *\n+ * will expand to\n+ *\n+ *  bar(\"test\",);\n+ *\n+ * which is invalid (note the ',)'). With GNUC, '##__VA_ARGS__' drops the\n+ * comma, but this is non-standard.\n+ */\n+\n+#define trace_printf(...) \\\n+\ttrace_printf_key_fl(__FILE__, __LINE__, \"GIT_TRACE\", __VA_ARGS__)\n+\n+#define trace_printf_key(key, ...) \\\n+\ttrace_printf_key_fl(__FILE__, __LINE__, key, __VA_ARGS__)\n+\n+#define trace_argv_printf(argv, ...) \\\n+\ttrace_argv_printf_fl(__FILE__, __LINE__, argv, __VA_ARGS__)\n+\n+#define trace_strbuf(key, data) \\\n+\ttrace_strbuf_fl(__FILE__, __LINE__, key, data)\n+\n+/* backend functions, use non-*fl macros instead */\n+__attribute__((format (printf, 4, 5)))\n+extern void trace_printf_key_fl(const char *file, int line, const char *key,\n+\t\t\t\tconst char *format, ...);\n+__attribute__((format (printf, 4, 5)))\n+extern void trace_argv_printf_fl(const char *file, int line, const char **argv,\n+\t\t\t\t const char *format, ...);\n+extern void trace_strbuf_fl(const char *file, int line, const char *key,\n+\t\t\t    const struct strbuf *data);\n+\n+#endif /* HAVE_VARIADIC_MACROS */\n+\n #endif /* TRACE_H */\n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244815","messageId":"53A4A307.2050103@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 09/11] trace: add high resolution timer function to debug performance issues","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:09:27Z","receivedAt":"2014-06-20T21:09:27Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Add a getnanotime() function that returns nanoseconds since 01/01/1970 as\nunsigned 64-bit integer (i.e. overflows in july 2554). This is easier to\nwork with than e.g. struct timeval or struct timespec. Basing the timer on\nthe epoch allows using the results with other time-related APIs.\n\nTo simplify adaption to different platforms, split the implementation into\na common getnanotime() and a platform-specific highres_nanos() function.\n\nThe common getnanotime() function handles errors, falling back to\ngettimeofday() if highres_nanos() isn't implemented or doesn't work.\n\ngetnanotime() is also responsible for normalizing to the epoch. The offset\nto the system clock is calculated only once on initialization, i.e.\nmanually setting the system clock has no impact on the timer (except if\nthe fallback gettimeofday() is in use). Git processes are typically short\nlived, so we don't need to handle clock drift.\n\nThe highres_nanos() function returns monotonically increasing nanoseconds\nrelative to some arbitrary point in time (e.g. system boot), or 0 on\nfailure. Providing platform-specific implementations should be relatively\neasy, e.g. adapting to clock_gettime() as defined by the POSIX realtime\nextensions is seven lines of code.\n\nThis version includes highres_nanos() implementations for:\n * Linux: using clock_gettime(CLOCK_MONOTONIC)\n * Windows: using QueryPerformanceCounter()\n\nTodo:\n * enable clock_gettime() on more platforms\n * add Mac OSX version, e.g. using mach_absolute_time + mach_timebase_info\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Makefile         |  7 +++++\n config.mak.uname |  1 +\n trace.c          | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n trace.h          |  1 +\n 4 files changed, 91 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 07ea105..80f4390 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -340,6 +340,8 @@ all::\n #\n # Define GMTIME_UNRELIABLE_ERRORS if your gmtime() function does not\n # return NULL when it receives a bogus time_t.\n+#\n+# Define HAVE_CLOCK_GETTIME if your platform has clock_gettime in librt.\n \n GIT-VERSION-FILE: FORCE\n \t@$(SHELL_PATH) ./GIT-VERSION-GEN\n@@ -1497,6 +1499,11 @@ ifdef GMTIME_UNRELIABLE_ERRORS\n \tBASIC_CFLAGS += -DGMTIME_UNRELIABLE_ERRORS\n endif\n \n+ifdef HAVE_CLOCK_GETTIME\n+\tBASIC_CFLAGS += -DHAVE_CLOCK_GETTIME\n+\tEXTLIBS += -lrt\n+endif\n+\n ifeq ($(TCLTK_PATH),)\n NO_TCLTK = NoThanks\n endif\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 1ae675b..dad2618 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -34,6 +34,7 @@ ifeq ($(uname_S),Linux)\n \tHAVE_PATHS_H = YesPlease\n \tLIBC_CONTAINS_LIBINTL = YesPlease\n \tHAVE_DEV_TTY = YesPlease\n+\tHAVE_CLOCK_GETTIME = YesPlease\n endif\n ifeq ($(uname_S),GNU/kFreeBSD)\n \tHAVE_ALLOCA_H = YesPlease\ndiff --git a/trace.c b/trace.c\nindex 5844f31..88e05b9 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -275,3 +275,85 @@ int trace_want(const char *key)\n \t\treturn 0;\n \treturn 1;\n }\n+\n+#ifdef HAVE_CLOCK_GETTIME\n+\n+static inline uint64_t highres_nanos(void)\n+{\n+\tstruct timespec ts;\n+\tif (clock_gettime(CLOCK_MONOTONIC, &ts))\n+\t\treturn 0;\n+\treturn (uint64_t) ts.tv_sec * 1000000000 + ts.tv_nsec;\n+}\n+\n+#elif defined (GIT_WINDOWS_NATIVE)\n+\n+static inline uint64_t highres_nanos(void)\n+{\n+\tstatic uint64_t high_ns, scaled_low_ns;\n+\tstatic int scale;\n+\tLARGE_INTEGER cnt;\n+\n+\tif (!scale) {\n+\t\tif (!QueryPerformanceFrequency(&cnt))\n+\t\t\treturn 0;\n+\n+\t\t/* high_ns = number of ns per cnt.HighPart */\n+\t\thigh_ns = (1000000000LL << 32) / (uint64_t) cnt.QuadPart;\n+\n+\t\t/*\n+\t\t * Number of ns per cnt.LowPart is 10^9 / frequency (or\n+\t\t * high_ns >> 32). For maximum precision, we scale this factor\n+\t\t * so that it just fits within 32 bit (i.e. won't overflow if\n+\t\t * multiplied with cnt.LowPart).\n+\t\t */\n+\t\tscaled_low_ns = high_ns;\n+\t\tscale = 32;\n+\t\twhile (scaled_low_ns >= 0x100000000LL) {\n+\t\t\tscaled_low_ns >>= 1;\n+\t\t\tscale--;\n+\t\t}\n+\t}\n+\n+\t/* if QPF worked on initialization, we expect QPC to work as well */\n+\tQueryPerformanceCounter(&cnt);\n+\n+\treturn (high_ns * cnt.HighPart) +\n+\t       ((scaled_low_ns * cnt.LowPart) >> scale);\n+}\n+\n+#else\n+# define highres_nanos() 0\n+#endif\n+\n+static inline uint64_t gettimeofday_nanos(void)\n+{\n+\tstruct timeval tv;\n+\tgettimeofday(&tv, NULL);\n+\treturn (uint64_t) tv.tv_sec * 1000000000 + tv.tv_usec * 1000;\n+}\n+\n+/*\n+ * Returns nanoseconds since the epoch (01/01/1970), for performance tracing\n+ * (i.e. favoring high precision over wall clock time accuracy).\n+ */\n+inline uint64_t getnanotime(void)\n+{\n+\tstatic uint64_t offset;\n+\tif (offset > 1) {\n+\t\t/* initialization succeeded, return offset + high res time */\n+\t\treturn offset + highres_nanos();\n+\t} else if (offset == 1) {\n+\t\t/* initialization failed, fall back to gettimeofday */\n+\t\treturn gettimeofday_nanos();\n+\t} else {\n+\t\t/* initialize offset if high resolution timer works */\n+\t\tuint64_t now = gettimeofday_nanos();\n+\t\tuint64_t highres = highres_nanos();\n+\t\tif (highres)\n+\t\t\toffset = now - highres;\n+\t\telse\n+\t\t\toffset = 1;\n+\t\treturn now;\n+\t}\n+}\ndiff --git a/trace.h b/trace.h\nindex 916dc2b..c4964aa 100644\n--- a/trace.h\n+++ b/trace.h\n@@ -6,6 +6,7 @@\n \n extern void trace_repo_setup(const char *prefix);\n extern int trace_want(const char *key);\n+extern uint64_t getnanotime(void);\n \n #ifndef HAVE_VARIADIC_MACROS\n \n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244816","messageId":"53A4A32F.40502@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 10/11] trace: add trace_performance facility to debug performance issues","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:10:07Z","receivedAt":"2014-06-20T21:10:07Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Add trace_performance and trace_performance_since macros that print a\nduration and an optional printf-formatted text to the file specified in\nenvironment variable GIT_TRACE_PERFORMANCE.\n\nThese macros, in conjunction with getnanotime(), are intended to simplify\nperformance measurements from within the application (i.e. profiling via\nmanual instrumentation, rather than using an external profiling tool).\n\nUnless enabled via GIT_TRACE_PERFORMANCE, these macros have no noticeable\nimpact on performance, so that test code for well known time killers may\nbe shipped in release builds. Alternatively, a developer could provide an\nadditional performance patch (not meant for master) that allows reviewers\nto reproduce performance tests more easily, e.g. on other platforms or\nusing their own repositories.\n\nUsage examples:\n\nSimple use case (measure one code section):\n\n  uint64_t start = getnanotime();\n  /* code section to measure */\n  trace_performance_since(start, \"foobar\");\n\nComplex use case (measure repetitive code sections):\n\n  uint64_t t = 0;\n  for (;;) {\n    /* ignore */\n    t -= getnanotime();\n    /* code section to measure */\n    t += getnanotime();\n    /* ignore */\n  }\n  trace_performance(t, \"frotz\");\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\n---\n trace.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++\n trace.h | 18 ++++++++++++++++++\n 2 files changed, 65 insertions(+)\n\ndiff --git a/trace.c b/trace.c\nindex 88e05b9..65cd887 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -164,6 +164,27 @@ void trace_strbuf_fl(const char *file, int line, const char *key,\n \tprint_trace_line(key, &buf);\n }\n \n+static const char *GIT_TRACE_PERFORMANCE = \"GIT_TRACE_PERFORMANCE\";\n+\n+static void trace_performance_vprintf_fl(const char *file, int line,\n+\t\t\t\t\t uint64_t nanos, const char *format,\n+\t\t\t\t\t va_list ap)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\n+\tif (!prepare_trace_line(file, line, GIT_TRACE_PERFORMANCE, &buf))\n+\t\treturn;\n+\n+\tstrbuf_addf(&buf, \"performance: %.9f s\", (double) nanos / 1000000000);\n+\n+\tif (format && *format) {\n+\t\tstrbuf_addstr(&buf, \": \");\n+\t\tstrbuf_vaddf(&buf, format, ap);\n+\t}\n+\n+\tprint_trace_line(GIT_TRACE_PERFORMANCE, &buf);\n+}\n+\n #ifndef HAVE_VARIADIC_MACROS\n \n void trace_printf(const char *format, ...)\n@@ -195,6 +216,23 @@ void trace_strbuf(const char *key, const struct strbuf *data)\n \ttrace_strbuf_fl(NULL, 0, key, data);\n }\n \n+void trace_performance(uint64_t nanos, const char *format, ...)\n+{\n+\tva_list ap;\n+\tva_start(ap, format);\n+\ttrace_performance_vprintf_fl(NULL, 0, nanos, format, ap);\n+\tva_end(ap);\n+}\n+\n+void trace_performance_since(uint64_t start, const char *format, ...)\n+{\n+\tva_list ap;\n+\tva_start(ap, format);\n+\ttrace_performance_vprintf_fl(NULL, 0, getnanotime() - start,\n+\t\t\t\t     format, ap);\n+\tva_end(ap);\n+}\n+\n #else\n \n void trace_printf_key_fl(const char *file, int line, const char *key,\n@@ -215,6 +253,15 @@ void trace_argv_printf_fl(const char *file, int line, const char **argv,\n \tva_end(ap);\n }\n \n+void trace_performance_fl(const char *file, int line, uint64_t nanos,\n+\t\t\t      const char *format, ...)\n+{\n+\tva_list ap;\n+\tva_start(ap, format);\n+\ttrace_performance_vprintf_fl(file, line, nanos, format, ap);\n+\tva_end(ap);\n+}\n+\n #endif /* HAVE_VARIADIC_MACROS */\n \n \ndiff --git a/trace.h b/trace.h\nindex c4964aa..f491471 100644\n--- a/trace.h\n+++ b/trace.h\n@@ -21,6 +21,14 @@ extern void trace_argv_printf(const char **argv, const char *format, ...);\n \n extern void trace_strbuf(const char *key, const struct strbuf *data);\n \n+/* Prints elapsed time (in nanoseconds) if GIT_TRACE_PERFORMANCE is enabled. */\n+__attribute__((format (printf, 2, 3)))\n+extern void trace_performance(uint64_t nanos, const char *format, ...);\n+\n+/* Prints elapsed time since 'start' if GIT_TRACE_PERFORMANCE is enabled. */\n+__attribute__((format (printf, 2, 3)))\n+extern void trace_performance_since(uint64_t start, const char *format, ...);\n+\n #else\n \n /*\n@@ -56,6 +64,13 @@ extern void trace_strbuf(const char *key, const struct strbuf *data);\n #define trace_strbuf(key, data) \\\n \ttrace_strbuf_fl(__FILE__, __LINE__, key, data)\n \n+#define trace_performance(nanos, ...) \\\n+\ttrace_performance_fl(__FILE__, __LINE__, nanos, __VA_ARGS__)\n+\n+#define trace_performance_since(start, ...) \\\n+\ttrace_performance_fl(__FILE__, __LINE__, getnanotime() - (start), \\\n+\t\t\t     __VA_ARGS__)\n+\n /* backend functions, use non-*fl macros instead */\n __attribute__((format (printf, 4, 5)))\n extern void trace_printf_key_fl(const char *file, int line, const char *key,\n@@ -65,6 +80,9 @@ extern void trace_argv_printf_fl(const char *file, int line, const char **argv,\n \t\t\t\t const char *format, ...);\n extern void trace_strbuf_fl(const char *file, int line, const char *key,\n \t\t\t    const struct strbuf *data);\n+__attribute__((format (printf, 4, 5)))\n+extern void trace_performance_fl(const char *file, int line,\n+\t\t\t\t uint64_t nanos, const char *fmt, ...);\n \n #endif /* HAVE_VARIADIC_MACROS */\n \n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244817","messageId":"53A4A352.2050308@gmail.com","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"[PATCH v6 11/11] git: add performance tracing for git's main() function to debug scripts","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T21:10:42Z","receivedAt":"2014-06-20T21:10:42Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Use trace_performance to measure and print execution time and command line\narguments of the entire main() function. In constrast to the shell's 'time'\nutility, which measures total time of the parent process, this logs all\ninvolved git commands recursively. This is particularly useful to debug\nperformance issues of scripted commands (i.e. which git commands were\ncalled with which parameters, and how long did they execute).\n\nDue to git's deliberate use of exit(), the implementation uses an atexit\nroutine rather than just adding trace_performance_since() at the end of\nmain().\n\nUsage example: > GIT_TRACE_PERFORMANCE=~/git-trace.log git stash list\n\nCreates a log file like this:\n23:57:38.638765 trace.c:405 performance: 0.000310107 s: git command: 'git' 'rev-parse' '--git-dir'\n23:57:38.644387 trace.c:405 performance: 0.000261759 s: git command: 'git' 'rev-parse' '--show-toplevel'\n23:57:38.646207 trace.c:405 performance: 0.000304468 s: git command: 'git' 'config' '--get-colorbool' 'color.interactive'\n23:57:38.648491 trace.c:405 performance: 0.000241667 s: git command: 'git' 'config' '--get-color' 'color.interactive.help' 'red bold'\n23:57:38.650465 trace.c:405 performance: 0.000243063 s: git command: 'git' 'config' '--get-color' '' 'reset'\n23:57:38.654850 trace.c:405 performance: 0.025126313 s: git command: 'git' 'stash' 'list'\n\nSigned-off-by: Karsten Blees <blees@dcon.de>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git.c   |  2 ++\n trace.c | 22 ++++++++++++++++++++++\n trace.h |  1 +\n 3 files changed, 25 insertions(+)\n\ndiff --git a/git.c b/git.c\nindex 7780572..d4daeb8 100644\n--- a/git.c\n+++ b/git.c\n@@ -568,6 +568,8 @@ int main(int argc, char **av)\n \n \tgit_setup_gettext();\n \n+\ttrace_command_performance(argv);\n+\n \t/*\n \t * \"git-xxxx\" is the same as \"git xxxx\", but we obviously:\n \t *\ndiff --git a/trace.c b/trace.c\nindex 65cd887..dcd2685 100644\n--- a/trace.c\n+++ b/trace.c\n@@ -404,3 +404,25 @@ inline uint64_t getnanotime(void)\n \t\treturn now;\n \t}\n }\n+\n+static uint64_t command_start_time;\n+static struct strbuf command_line = STRBUF_INIT;\n+\n+static void print_command_performance_atexit(void)\n+{\n+\ttrace_performance_since(command_start_time, \"git command:%s\",\n+\t\t\t\tcommand_line.buf);\n+}\n+\n+void trace_command_performance(const char **argv)\n+{\n+\tif (!trace_want(GIT_TRACE_PERFORMANCE))\n+\t\treturn;\n+\n+\tif (!command_start_time)\n+\t\tatexit(print_command_performance_atexit);\n+\n+\tstrbuf_reset(&command_line);\n+\tsq_quote_argv(&command_line, argv, 0);\n+\tcommand_start_time = getnanotime();\n+}\ndiff --git a/trace.h b/trace.h\nindex f491471..5d1f174 100644\n--- a/trace.h\n+++ b/trace.h\n@@ -7,6 +7,7 @@\n extern void trace_repo_setup(const char *prefix);\n extern int trace_want(const char *key);\n extern uint64_t getnanotime(void);\n+extern void trace_command_performance(const char **argv);\n \n #ifndef HAVE_VARIADIC_MACROS\n \n-- \n2.0.0.402.g13b8b25\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244821","messageId":"xmqqmwd7citp.fsf@gitster.dls.corp.google.com","threadId":"36973","inReplyTo":"53A4A267.2060907@gmail.com","subject":"Re: [PATCH v6 05/11] trace: add infrastructure to augment trace output with additional info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-20T22:33:22Z","receivedAt":"2014-06-20T22:33:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karsten Blees <karsten.blees@gmail.com> writes:\n\n> To be able to add a common prefix or suffix to all trace output (e.g.\n> a timestamp or file:line of the caller), factor out common setup and\n> cleanup tasks of the trace* functions.\n>\n> Some unit-tests use trace output to verify internal state, and variable\n> output such as timestamps and line numbers are not useful there. Disable\n> additional trace output if GIT_TRACE_BARE is set.\n\nHmph, this makes me wonder if we are better off making these\nadditional trace output optional, i.e. not disabling with\nGIT_TRACE_BARE like this, but show the new output only when\nexplicitly asked for by setting GIT_TRACE_PERF or something.\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244822","messageId":"CEA564C177884D1D86D69200A9A43AC8@PhilipOakley","threadId":"36973","inReplyTo":"53A4A195.1070502@gmail.com","subject":"Re: [PATCH v6 00/11] add performance tracing facility","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2014-06-20T22:49:56Z","receivedAt":"2014-06-20T22:49:56Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"Karsten Blees\" <karsten.blees@gmail.com>\n> Changes since v5:\n> [05/11]: GIT_TRACE_BARE=1 disables 'timestamp file:line' output for\n>         unit tests that rely on trace output (t1510 and t5503)\n> [08/11]: Align original trace output at col 40\n> [09/11]: Dropped '(div 10e9)' from the commit message.\n> [10/11]: Dropped trace_performance[_since]() return value and the\n>         respective usage example. Renamed trace_performance_vfl to\n>         trace_performance_vprintf_fl.\n>\n> The other patches are the versions from pu.\n>\n> Karsten Blees (11):\n>  trace: move trace declarations from cache.h to new trace.h\n>  trace: consistently name the format parameter\n>  trace: remove redundant printf format attribute\n>  trace: factor out printing to the trace file\n>  trace: add infrastructure to augment trace output with additional \n> info\n>  trace: add current timestamp to all trace output\n>  trace: move code around, in preparation to file:line output\n>  trace: add 'file:line' to all trace output\n>  trace: add high resolution timer function to debug performance issues\n>  trace: add trace_performance facility to debug performance issues\n>  git: add performance tracing for git's main() function to debug\n>    scripts\n>\n> Makefile              |   7 ++\n> cache.h               |  13 +--\n> config.mak.uname      |   1 +\n> git-compat-util.h     |   4 +\n> git.c                 |   2 +\n> t/t1510-repo-setup.sh |   2 +-\n> t/t5503-tagfollow.sh  |   8 +-\n> trace.c               | 313 \n> ++++++++++++++++++++++++++++++++++++++++++++------\n> trace.h               |  90 +++++++++++++++\n> 9 files changed, 387 insertions(+), 53 deletions(-)\n\nShould there be some documentation as well? Perhaps in t/README, or in\nDocumentation/howto.\n\n\n> create mode 100644 trace.h\n>\n> -- \nPhilip \n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244823","messageId":"53A4C47D.609@gmail.com","threadId":"36973","inReplyTo":"xmqqmwd7citp.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v6 05/11] trace: add infrastructure to augment trace output with additional info","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T23:32:13Z","receivedAt":"2014-06-20T23:32:13Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 21.06.2014 00:33, schrieb Junio C Hamano:\n> Karsten Blees <karsten.blees@gmail.com> writes:\n> \n>> To be able to add a common prefix or suffix to all trace output (e.g.\n>> a timestamp or file:line of the caller), factor out common setup and\n>> cleanup tasks of the trace* functions.\n>>\n>> Some unit-tests use trace output to verify internal state, and variable\n>> output such as timestamps and line numbers are not useful there. Disable\n>> additional trace output if GIT_TRACE_BARE is set.\n> \n> Hmph, this makes me wonder if we are better off making these\n> additional trace output optional, i.e. not disabling with\n> GIT_TRACE_BARE like this, but show the new output only when\n> explicitly asked for by setting GIT_TRACE_PERF or something.\n> \n\nGIT_TRACE_VERBOSE perhaps? It affects all trace output, not just\nGIT_TRACE_PERFORMANCE. The tests would still have to disable it\nexplicitly, though, in case someone sets it in their profile.\n\nHowever, IIRC conclusion of v4 discussion was that this would be\nuseful for all trace output [1], so I think it should be the default.\n\n[1] https://groups.google.com/forum/#!topic/msysgit/UMKTvmZX5aI\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244824","messageId":"53A4C6FB.5040005@gmail.com","threadId":"36973","inReplyTo":"CEA564C177884D1D86D69200A9A43AC8@PhilipOakley","subject":"Re: [PATCH v6 00/11] add performance tracing facility","fromName":"Karsten Blees","fromEmail":"karsten.blees@gmail.com","sentAt":"2014-06-20T23:42:51Z","receivedAt":"2014-06-20T23:42:51Z","isPatch":true,"sender":{"key":"karsten.blees@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1111200?v=4"},"body":"Am 21.06.2014 00:49, schrieb Philip Oakley:\n> Should there be some documentation as well? Perhaps in t/README, or in\n> Documentation/howto.\n\nI'll add Documentation/technical/api-trace.txt when I find the time.\nBut lets settle on the final API first.\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"},{"id":"244826","messageId":"CAPc5daV=vbJz90X9K85DzJZ0PjyzF_xfSi9Cy9XZ+TX0YdEkeg@mail.gmail.com","threadId":"36973","inReplyTo":"53A4C47D.609@gmail.com","subject":"Re: [PATCH v6 05/11] trace: add infrastructure to augment trace output with additional info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-06-21T00:33:47Z","receivedAt":"2014-06-21T00:33:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Fri, Jun 20, 2014 at 4:32 PM, Karsten Blees <karsten.blees@gmail.com> wrote:\n> Am 21.06.2014 00:33, schrieb Junio C Hamano:\n>> Karsten Blees <karsten.blees@gmail.com> writes:\n>\n> GIT_TRACE_VERBOSE perhaps? It affects all trace output, not just\n> GIT_TRACE_PERFORMANCE. The tests would still have to disable it\n> explicitly, though, in case someone sets it in their profile.\n>\n> However, IIRC conclusion of v4 discussion was that this would be\n> useful for all trace output [1], so I think it should be the default.\n>\n> [1] https://groups.google.com/forum/#!topic/msysgit/UMKTvmZX5aI\n\nHmph, after re-reading of that thread, I recall that I thought Peff's\n\n>> Would it make\n>> sense to just tie this to regular trace_* calls, and if\n>> GIT_TRACE_PERFORMANCE is set, add a timestamp to each line?\n\nwas the conclusion (i.e. by default no change, ask with GIT_TRACE_PERFORMANCE),\nand that I found that reasonable back then.\n\nAs to the need to disable in the tests, yes, you are right. Just like\nwe give predictiable\nenvironment to tests by setting EDITOR, HOME, etc. in test-lib.sh, we\nshould do the\nsame for these new settings there.\n\nThanks.\n\n-- \n-- \n*** Please reply-to-all at all times ***\n*** (do not pretend to know who is subscribed and who is not) ***\n*** Please avoid top-posting. ***\nThe msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.\n\nYou received this message because you are subscribed to the Google\nGroups \"msysGit\" group.\nTo post to this group, send email to msysgit@googlegroups.com\nTo unsubscribe from this group, send email to\nmsysgit+unsubscribe@googlegroups.com\nFor more options, and view previous threads, visit this group at\nhttp://groups.google.com/group/msysgit?hl=en_US?hl=en\n\n--- \nYou received this message because you are subscribed to the Google Groups \"msysGit\" group.\nTo unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.\nFor more options, visit https://groups.google.com/d/optout.\n"}]}