{"thread":{"id":"49760","subject":"[PATCH v1] refresh_index: remove unnecessary calls to preload_index()","startedAt":"2018-11-05T19:28:04Z","lastAt":"2018-11-05T19:44:31Z","messageCount":2,"participants":["Ben Peart","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"362521","messageId":"20181105192751.11948-1-peartben@gmail.com","threadId":"49760","inReplyTo":null,"subject":"[PATCH v1] refresh_index: remove unnecessary calls to preload_index()","fromName":"Ben Peart","fromEmail":"peartben@gmail.com","sentAt":"2018-11-05T19:27:51Z","receivedAt":"2018-11-05T19:28:04Z","isPatch":true,"sender":{"key":"benpeart@microsoft.com","avatar":"https://avatars.githubusercontent.com/u/15252029?v=4"},"body":"From: Ben Peart <benpeart@microsoft.com>\n\nWith refresh_index() learning to utilize preload_index() to speed up its\noperation there is no longer any benefit to having the caller preload the\nindex first. Remove those unneeded calls by calling read_index() instead of\nthe preload variant.\n\nThere is no measurable performance impact of this patch - the 2nd call to\npreload_index() bails out quickly but there is no reason to call it twice.\n\nSigned-off-by: Ben Peart <benpeart@microsoft.com>\n---\n\nNotes:\n    Base Ref:\n    Web-Diff: https://github.com/benpeart/git/commit/384f7fed53\n    Checkout: git fetch https://github.com/benpeart/git no-index-preload-v1 && git checkout 384f7fed53\n\n builtin/commit.c       | 2 +-\n builtin/describe.c     | 2 +-\n builtin/update-index.c | 2 +-\n sequencer.c            | 2 +-\n 4 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 074bd9a551..96d336ec3d 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1363,7 +1363,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tif (status_format != STATUS_FORMAT_PORCELAIN &&\n \t    status_format != STATUS_FORMAT_PORCELAIN_V2)\n \t\tprogress_flag = REFRESH_PROGRESS;\n-\tread_index_preload(&the_index, &s.pathspec, progress_flag);\n+\tread_index(&the_index);\n \trefresh_index(&the_index,\n \t\t      REFRESH_QUIET|REFRESH_UNMERGED|progress_flag,\n \t\t      &s.pathspec, NULL, NULL);\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex c48c34e866..cc118448ee 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -629,7 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t\t\tstruct argv_array args = ARGV_ARRAY_INIT;\n \t\t\tint fd, result;\n \n-\t\t\tread_cache_preload(NULL);\n+\t\t\tread_cache();\n \t\t\trefresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,\n \t\t\t\t      NULL, NULL, NULL);\n \t\t\tfd = hold_locked_index(&index_lock, 0);\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 07c10bcb7d..0e1dcf0438 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -782,7 +782,7 @@ struct refresh_params {\n static int refresh(struct refresh_params *o, unsigned int flag)\n {\n \tsetup_work_tree();\n-\tread_cache_preload(NULL);\n+\tread_cache();\n \t*o->has_errors |= refresh_cache(o->flags | flag);\n \treturn 0;\n }\ndiff --git a/sequencer.c b/sequencer.c\nindex 9e1ab3a2a7..ab2048ac3a 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1919,7 +1919,7 @@ static int read_and_refresh_cache(struct replay_opts *opts)\n {\n \tstruct lock_file index_lock = LOCK_INIT;\n \tint index_fd = hold_locked_index(&index_lock, 0);\n-\tif (read_index_preload(&the_index, NULL, 0) < 0) {\n+\tif (read_index(&the_index) < 0) {\n \t\trollback_lock_file(&index_lock);\n \t\treturn error(_(\"git %s: failed to read the index\"),\n \t\t\t_(action_name(opts)));\n\nbase-commit: 095c8dc8c2a9d61783dbae79a7f6e8d80092696f\n-- \n2.18.0.windows.1\n\n"},{"id":"362522","messageId":"CACsJy8DTNASgBMaoHJM2dXS5KZ7e-t+k5w-1z7Zb_B8UMpSeVw@mail.gmail.com","threadId":"49760","inReplyTo":"20181105192751.11948-1-peartben@gmail.com","subject":"Re: [PATCH v1] refresh_index: remove unnecessary calls to preload_index()","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-11-05T19:44:02Z","receivedAt":"2018-11-05T19:44:31Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Nov 5, 2018 at 8:30 PM Ben Peart <peartben@gmail.com> wrote:\n>\n> From: Ben Peart <benpeart@microsoft.com>\n>\n> With refresh_index() learning to utilize preload_index() to speed up its\n> operation there is no longer any benefit to having the caller preload the\n> index first. Remove those unneeded calls by calling read_index() instead of\n> the preload variant.\n>\n> There is no measurable performance impact of this patch - the 2nd call to\n> preload_index() bails out quickly but there is no reason to call it twice.\n\nObviously correct. It's not shown in the context lines, but there's\nalso a refresh_index() after read_index() in sequencer.c too.\n-- \nDuy\n"}]}