{"thread":{"id":"23116","subject":"[PATCH] Speed up commands that use rev-list when max-count is specified.","startedAt":"2010-03-21T03:31:07Z","lastAt":"2010-03-21T16:57:30Z","messageCount":4,"participants":["Benjamin C Meyer","Sverre Rabbelier","Mark Lodato","Benjamin Meyer"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"137406","messageId":"1269142267-17127-1-git-send-email-bmeyer@rim.com","threadId":"23116","inReplyTo":null,"subject":"[PATCH] Speed up commands that use rev-list when max-count is specified.","fromName":"Benjamin C Meyer","fromEmail":"bmeyer@rim.com","sentAt":"2010-03-21T03:31:07Z","receivedAt":"2010-03-21T03:31:07Z","isPatch":true,"sender":{"key":"bmeyer@rim.com","avatar":null},"body":"Many command have code similar to the following:\n\nwhile ((commit = get_revision(rev)) != NULL) { ... }\n\nThis results in and extra call to get_revision that first finds the next\nrevision and then notices max-count is 0 and returns NULL.  Adding\na max-count check before any expensive work reduces the runtime of all\nof the commands the have this pattern.\n\nDepending on the use case this can have a big impact on the running time.\n\nSigned-off-by: Benjamin C Meyer <bmeyer@rim.com>\n---\n revision.c |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 490b484..4673d70 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -2058,6 +2058,9 @@ static struct commit *get_revision_internal(struct rev_info *revs)\n \n struct commit *get_revision(struct rev_info *revs)\n {\n+\tif (revs->max_count == 0)\n+\t\treturn NULL;\n+\n \tstruct commit *c;\n \tstruct commit_list *reversed;\n \n-- \n1.7.0.2\n"},{"id":"137437","messageId":"fabb9a1e1003210412n58a3b951x1de4543f11b888c4@mail.gmail.com","threadId":"23116","inReplyTo":"1269142267-17127-1-git-send-email-bmeyer@rim.com","subject":"Re: [PATCH] Speed up commands that use rev-list when max-count is specified.","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-03-21T11:12:49Z","receivedAt":"2010-03-21T11:12:49Z","isPatch":true,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sun, Mar 21, 2010 at 04:31, Benjamin C Meyer <bmeyer@rim.com> wrote:\n> Depending on the use case this can have a big impact on the running time.\n\nSounds promising, do you have any numbers?\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"137447","messageId":"ca433831003210709k1da46c8docfdac358253625e@mail.gmail.com","threadId":"23116","inReplyTo":"1269142267-17127-1-git-send-email-bmeyer@rim.com","subject":"Re: [PATCH] Speed up commands that use rev-list when max-count is specified.","fromName":"Mark Lodato","fromEmail":"lodatom@gmail.com","sentAt":"2010-03-21T14:09:20Z","receivedAt":"2010-03-21T14:09:20Z","isPatch":true,"sender":{"key":"lodatom@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58860?v=4"},"body":"On Sat, Mar 20, 2010 at 11:31 PM, Benjamin C Meyer <bmeyer@rim.com> wrote:\n>  struct commit *get_revision(struct rev_info *revs)\n>  {\n> +       if (revs->max_count == 0)\n> +               return NULL;\n> +\n>        struct commit *c;\n>        struct commit_list *reversed;\n\nDeclaring variables in the middle of a function is a C99 feature (and\na GNU extension in C89 mode).  I don't know if this is allowed in git\ncode, but it would be easy enough to make this ANSI C89 compatible by\nputting your new statement after the variable declarations.\n"},{"id":"137453","messageId":"10BD5DAD-16FB-40FB-A77B-955EA0ECD4CB@meyerhome.net","threadId":"23116","inReplyTo":"fabb9a1e1003210412n58a3b951x1de4543f11b888c4@mail.gmail.com","subject":"Re: [PATCH] Speed up commands that use rev-list when max-count is specified.","fromName":"Benjamin Meyer","fromEmail":"ben@meyerhome.net","sentAt":"2010-03-21T16:57:30Z","receivedAt":"2010-03-21T16:57:30Z","isPatch":true,"sender":{"key":"ben@meyerhome.net","avatar":null},"body":"In the git repo a more extreme case doing something like git log -1 copy.c the patch will reduce the runtime by 70%.  Running it on every top level file in git ('for f in *; log -1 $f; done') goes from 9 minutes to 8:30.\n\n-Benjamin Meyer\n\nOn Mar 21, 2010, at 7:12 AM, Sverre Rabbelier wrote:\n\n> Heya,\n> \n> On Sun, Mar 21, 2010 at 04:31, Benjamin C Meyer <bmeyer@rim.com> wrote:\n>> Depending on the use case this can have a big impact on the running time.\n> \n> Sounds promising, do you have any numbers?\n> \n> -- \n> Cheers,\n> \n> Sverre Rabbelier\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}