{"thread":{"id":"45102","subject":"[PATCH] preload-index: avoid lstat for skip-worktree items","startedAt":"2017-02-10T15:17:38Z","lastAt":"2017-02-10T22:44:05Z","messageCount":2,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"311267","messageId":"a1297b9426e7980f41e9e662fc0f30717c576c3e.1486739428.git.johannes.schindelin@gmx.de","threadId":"45102","inReplyTo":null,"subject":"[PATCH] preload-index: avoid lstat for skip-worktree items","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-02-10T15:10:39Z","receivedAt":"2017-02-10T15:17:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Jeff Hostetler <jeffhost@microsoft.com>\n\nTeach preload-index to avoid lstat() calls for index-entries\nwith skip-worktree bit set.  This is a performance optimization.\n\nDuring a sparse-checkout, the skip-worktree bit is set on items\nthat were not populated and therefore are not present in the\nworktree.  The per-thread preload-index loop performs a series\nof tests on each index-entry as it attempts to compare the\nworktree version with the index and mark them up-to-date.\nThis patch short-cuts that work.\n\nOn a Windows 10 system with a very large repo (450MB index)\nand various levels of sparseness, performance was improved\nin the {preloadindex=true, fscache=false} case by 80% and\nin the {preloadindex=true, fscache=true} case by 20% for various\ncommands.\n\nSigned-off-by: Jeff Hostetler <jeffhost@microsoft.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\nPublished-As: https://github.com/dscho/git/releases/tag/preload-index-sparse-v1\nFetch-It-Via: git fetch https://github.com/dscho/git preload-index-sparse-v1\n\n preload-index.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/preload-index.c b/preload-index.c\nindex c1fe3a3ef9c..70a4c808783 100644\n--- a/preload-index.c\n+++ b/preload-index.c\n@@ -53,6 +53,8 @@ static void *preload_thread(void *_data)\n \t\t\tcontinue;\n \t\tif (ce_uptodate(ce))\n \t\t\tcontinue;\n+\t\tif (ce_skip_worktree(ce))\n+\t\t\tcontinue;\n \t\tif (!ce_path_match(ce, &p->pathspec, NULL))\n \t\t\tcontinue;\n \t\tif (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))\n\nbase-commit: 6e3a7b3398559305c7a239a42e447c21a8f39ff8\n-- \n2.11.1.windows.1\n"},{"id":"311324","messageId":"xmqqpoipis42.fsf@gitster.mtv.corp.google.com","threadId":"45102","inReplyTo":"a1297b9426e7980f41e9e662fc0f30717c576c3e.1486739428.git.johannes.schindelin@gmx.de","subject":"Re: [PATCH] preload-index: avoid lstat for skip-worktree items","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-02-10T22:43:57Z","receivedAt":"2017-02-10T22:44:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <johannes.schindelin@gmx.de> writes:\n\n> Teach preload-index to avoid lstat() calls for index-entries\n> with skip-worktree bit set.  This is a performance optimization.\n> ...\n> diff --git a/preload-index.c b/preload-index.c\n> index c1fe3a3ef9c..70a4c808783 100644\n> --- a/preload-index.c\n> +++ b/preload-index.c\n> @@ -53,6 +53,8 @@ static void *preload_thread(void *_data)\n>  \t\t\tcontinue;\n>  \t\tif (ce_uptodate(ce))\n>  \t\t\tcontinue;\n> +\t\tif (ce_skip_worktree(ce))\n> +\t\t\tcontinue;\n>  \t\tif (!ce_path_match(ce, &p->pathspec, NULL))\n>  \t\t\tcontinue;\n>  \t\tif (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))\n\nBecause we are only interested in marking the ones that match\nbetween the index and the working tree as \"up-to-date\", and we are\nnot doing the opposite (i.e. toggle \"up-to-date\" bit off by noticing\nthat things are now different) in this codepath, this change does\nmake sense.  The ones marked as \"skip\", even if there were an\nunrelated file or directory at the path where the index expects a\nregular file, can be safely ignored.\n\nThanks.\n\n"}]}