From patchwork Mon Jun 7 11:58:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12303409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA4C3C47094 for ; Mon, 7 Jun 2021 11:59:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D304C61208 for ; Mon, 7 Jun 2021 11:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbhFGMBk (ORCPT ); Mon, 7 Jun 2021 08:01:40 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:47067 "EHLO mail-wr1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbhFGMBh (ORCPT ); Mon, 7 Jun 2021 08:01:37 -0400 Received: by mail-wr1-f43.google.com with SMTP id a11so15408401wrt.13 for ; Mon, 07 Jun 2021 04:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9SFQVszDfc9jEdSowYFdVPzt+0lUNS6ZXcUUW7YgVck=; b=nLhs/xxDgxYmUsMGmdRS31zsA/+YnlQ8M6UelvchAPpCfBPZGX0KYQEQw6Sux2P4Hn QVfGKuPF6ikRmFGnUXgtmOowR9e160iPIFqH1UfHf/ToaOZMTZ9M7pC2stveAobfkiVR kBL+zd4AH7etajhKtULN735WkqguEXCtke7O1AyC36/R7s6daeq4sZ53CRhBkCLB8YdT FaaR3UIWMte7B4jcOR0YCS68LKddlRmoYvvSrvXgntTgaqrCbB9ZqV4uduv4PktQkJye +J02UVnzD8qOtygM5Hk7L1ycJpwQvUrsWo6BUgZtGAw40lkq2MBX9an1Y5EPGHgit9C7 16yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9SFQVszDfc9jEdSowYFdVPzt+0lUNS6ZXcUUW7YgVck=; b=qTQnTMlTFcPdC/KFjN3Lhs8+cfe3CJkAXSfltmNzFGuig79Z+iBNEILiLk2IyrSV3Y KXImMViiE2uYOCKCjEf6yKpN6nzxjeBFjbGUq1vJIosJbi1ye9tvFNQiSfgIy646tTqk 9d5zfOpN/0y13jQuu4i5G4pMiexdd1PrY//RhLwJlFn0inUN8pD8YezBRn0sMSYZ9R7D mRkxv7aUd8TqBFZYsCft+a3maYK6dMt19vB8xHFYZz7e7Ms39fSc5pDr+kXvUglQdVM7 2+gDMhc1BOaGHzaC3wULm5nplYinX1APvuye8cR4N8bFwXWOrBkDgpnRlHuUffNl49W4 Mekg== X-Gm-Message-State: AOAM532XAtDMp5Mc/TJcSLnyyzJu8cPOzyyX7NQ6HcZE3sRCRgrsM92D EX82jOF/PwnoJ4t6/zlz0qpqaLRyWPW2Qg== X-Google-Smtp-Source: ABdhPJzMHZ/6Gm5UqHhs3V9UyULWa0rNVCavQYSz4sqte9NMFX1SWyAS4KleNaSmUFDrgWdTCeVD2A== X-Received: by 2002:adf:ec43:: with SMTP id w3mr16216859wrn.270.1623067114106; Mon, 07 Jun 2021 04:58:34 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 92sm17215166wrp.88.2021.06.07.04.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:58:33 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 1/4] test-tool: split up test-tool read-cache Date: Mon, 7 Jun 2021 13:58:24 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.rc3.434.gd8aed1f08a7 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since the "test-tool read-cache" was originally added back in 1ecb5ff141 (read-cache: add simple performance test, 2013-06-09) it's been growing all sorts of bells and whistles that aren't very conducive to performance testing the index, e.g. it learned how to read config. Then in recent changes in e2df6c3972 (test-read-cache: print cache entries with --table, 2021-03-30) and 2782db3eed (test-tool: don't force full index, 2021-03-30) we gained even more logic to deal with sparse index testing. I think that having one test tool do so many different things makes it harder to read its code. Let's instead split up the "again" and "perf" uses for it into their own tools. Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 2 ++ t/helper/test-read-cache-again.c | 31 ++++++++++++++++++ t/helper/test-read-cache-perf.c | 21 ++++++++++++ t/helper/test-read-cache.c | 56 +++++++++++++------------------- t/helper/test-tool.c | 2 ++ t/helper/test-tool.h | 2 ++ t/perf/p0002-read-cache.sh | 2 +- t/t7519-status-fsmonitor.sh | 2 +- 8 files changed, 83 insertions(+), 35 deletions(-) create mode 100644 t/helper/test-read-cache-again.c create mode 100644 t/helper/test-read-cache-perf.c diff --git a/Makefile b/Makefile index c3565fc0f8..142303bd17 100644 --- a/Makefile +++ b/Makefile @@ -732,6 +732,8 @@ TEST_BUILTINS_OBJS += test-prio-queue.o TEST_BUILTINS_OBJS += test-proc-receive.o TEST_BUILTINS_OBJS += test-progress.o TEST_BUILTINS_OBJS += test-reach.o +TEST_BUILTINS_OBJS += test-read-cache-again.o +TEST_BUILTINS_OBJS += test-read-cache-perf.o TEST_BUILTINS_OBJS += test-read-cache.o TEST_BUILTINS_OBJS += test-read-graph.o TEST_BUILTINS_OBJS += test-read-midx.o diff --git a/t/helper/test-read-cache-again.c b/t/helper/test-read-cache-again.c new file mode 100644 index 0000000000..707db036cb --- /dev/null +++ b/t/helper/test-read-cache-again.c @@ -0,0 +1,31 @@ +#include "test-tool.h" +#include "cache.h" + +int cmd__read_cache_again(int argc, const char **argv) +{ + struct repository *r = the_repository; + int i, cnt; + const char *name; + + if (argc != 2) + die("usage: test-tool read-cache-again "); + + cnt = strtol(argv[0], NULL, 0); + name = argv[2]; + + setup_git_directory(); + for (i = 0; i < cnt; i++) { + int pos; + repo_read_index(r); + refresh_index(r->index, REFRESH_QUIET, + NULL, NULL, NULL); + pos = index_name_pos(r->index, name, strlen(name)); + if (pos < 0) + die("%s not in index", name); + printf("%s is%s up to date\n", name, + ce_uptodate(r->index->cache[pos]) ? "" : " not"); + write_file(name, "%d\n", cnt); + discard_index(r->index); + } + return 0; +} diff --git a/t/helper/test-read-cache-perf.c b/t/helper/test-read-cache-perf.c new file mode 100644 index 0000000000..90176c010a --- /dev/null +++ b/t/helper/test-read-cache-perf.c @@ -0,0 +1,21 @@ +#include "test-tool.h" +#include "cache.h" + +int cmd__read_cache_perf(int argc, const char **argv) +{ + struct repository *r = the_repository; + int i, cnt = 1; + + if (argc == 2) + cnt = strtol(argv[1], NULL, 0); + else + die("usage: test-tool read-cache-perf []"); + + setup_git_directory(); + for (i = 0; i < cnt; i++) { + repo_read_index(r); + discard_index(r->index); + } + + return 0; +} diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index b52c174acc..ae4b9b70ad 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -5,6 +5,12 @@ #include "commit.h" #include "tree.h" #include "sparse-index.h" +#include "parse-options.h" + +static const char *read_cache_usage[] = { + "test-tool read-cache [...]", + NULL +}; static void print_cache_entry(struct cache_entry *ce) { @@ -34,49 +40,33 @@ static void print_cache(struct index_state *istate) int cmd__read_cache(int argc, const char **argv) { struct repository *r = the_repository; - int i, cnt = 1; - const char *name = NULL; int table = 0, expand = 0; + struct option options[] = { + OPT_BOOL(0, "table", &table, + "print a dump of the cache"), + OPT_BOOL(0, "expand", &expand, + "call ensure_full_index()"), + OPT_END() + }; + + argc = parse_options(argc, argv, "test-tools", options, read_cache_usage, 0); + if (argc > 0) + usage_msg_opt("Too many arguments.", read_cache_usage, options); initialize_the_repository(); prepare_repo_settings(r); r->settings.command_requires_full_index = 0; - for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) { - if (skip_prefix(*argv, "--print-and-refresh=", &name)) - continue; - if (!strcmp(*argv, "--table")) - table = 1; - else if (!strcmp(*argv, "--expand")) - expand = 1; - } - - if (argc == 1) - cnt = strtol(argv[0], NULL, 0); setup_git_directory(); git_config(git_default_config, NULL); + repo_read_index(r); - for (i = 0; i < cnt; i++) { - repo_read_index(r); - - if (expand) - ensure_full_index(r->index); + if (expand) + ensure_full_index(r->index); - if (name) { - int pos; + if (table) + print_cache(r->index); + discard_index(r->index); - refresh_index(r->index, REFRESH_QUIET, - NULL, NULL, NULL); - pos = index_name_pos(r->index, name, strlen(name)); - if (pos < 0) - die("%s not in index", name); - printf("%s is%s up to date\n", name, - ce_uptodate(r->index->cache[pos]) ? "" : " not"); - write_file(name, "%d\n", i); - } - if (table) - print_cache(r->index); - discard_index(r->index); - } return 0; } diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index c5bd0c6d4c..b0300f70c7 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -54,6 +54,8 @@ static struct test_cmd cmds[] = { { "progress", cmd__progress }, { "reach", cmd__reach }, { "read-cache", cmd__read_cache }, + { "read-cache-again", cmd__read_cache_again }, + { "read-cache-perf", cmd__read_cache_perf }, { "read-graph", cmd__read_graph }, { "read-midx", cmd__read_midx }, { "ref-store", cmd__ref_store }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index e8069a3b22..7f451a1eb5 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -43,6 +43,8 @@ int cmd__proc_receive(int argc, const char **argv); int cmd__progress(int argc, const char **argv); int cmd__reach(int argc, const char **argv); int cmd__read_cache(int argc, const char **argv); +int cmd__read_cache_again(int argc, const char **argv); +int cmd__read_cache_perf(int argc, const char **argv); int cmd__read_graph(int argc, const char **argv); int cmd__read_midx(int argc, const char **argv); int cmd__ref_store(int argc, const char **argv); diff --git a/t/perf/p0002-read-cache.sh b/t/perf/p0002-read-cache.sh index cdd105a594..d0ba5173fb 100755 --- a/t/perf/p0002-read-cache.sh +++ b/t/perf/p0002-read-cache.sh @@ -8,7 +8,7 @@ test_perf_default_repo count=1000 test_perf "read_cache/discard_cache $count times" " - test-tool read-cache $count + test-tool read-cache-perf $count " test_done diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 637391c6ce..4c199c16d4 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -359,7 +359,7 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR' test_expect_success 'discard_index() also discards fsmonitor info' ' test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" && test_might_fail git update-index --refresh && - test-tool read-cache --print-and-refresh=tracked 2 >actual && + test-tool read-cache-again 2 tracked >actual && printf "tracked is%s up to date\n" "" " not" >expect && test_cmp expect actual ' From patchwork Mon Jun 7 11:58:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12303407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 680D4C47095 for ; Mon, 7 Jun 2021 11:59:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 542BF61205 for ; Mon, 7 Jun 2021 11:59:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbhFGMBj (ORCPT ); Mon, 7 Jun 2021 08:01:39 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:33313 "EHLO mail-wr1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbhFGMBh (ORCPT ); Mon, 7 Jun 2021 08:01:37 -0400 Received: by mail-wr1-f52.google.com with SMTP id a20so17338460wrc.0 for ; Mon, 07 Jun 2021 04:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z6qQRqJGyPXAUQHByKcD3gHciIzlhof6rBbdttE07Yc=; b=RQ8hf6xzuHKvGk6yDDMOxLEWOY6AibLS5E5nQ7sG1lQRgdUmW9OonpspFBbfQWwpix iOnzDqEJ6EVswiUCBVYwfZ+eP0Z7uGByh2whNoJ/2LGWxC5CL0Bpk79eQSrboKBKazPL X1ryu4EdVaWXDfFvWSEWTWfGNuZvxsmIw001up3QGcL1UqrWGKWNj/NXXWts7QemKHVU h4Cnjw/KZcDexgjy/33+TFdKgPYGoVIdFJbipmEYM1+AkkG6/3S6HDyP+d89gji2xMDd GzPh/7/xrUvbHmny4AHXbvjCjSbx8i/1jLWADy3aMEkVS+XSktqxTcUw8mQXelxKGgWJ nMFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z6qQRqJGyPXAUQHByKcD3gHciIzlhof6rBbdttE07Yc=; b=LFh8XXN9cT4bMxQIyyF/AvdDqRV4wgv0FAXtADruML7wq9/eAs4lA/2UnTnthBprQ/ 4Xkw6lpzydJWOSiKQuEqTeR1OOncAnYYqmYjgc1f5orXOOeCWb9bZS/GYD+yHmBz9xxg 7+7PQ0jRhLjBWzMRHT8mrFrUKDWeYFFE/zOe1rNCQkh197ucdQRLsJOnYiDj1k+Ko1ua ZaaO5fLRMlyfIfbOZtB+FVPei/i2thXWCIfZueyllz/9e1wPOH+pKOcArVw/L4ua+qto okZ+YIlCwzZiu3K+CE3RpYKuUaIbeZ//1K6uVNw8loTon1jtaZhzmC//bGlP049hnZxq wKbg== X-Gm-Message-State: AOAM530nQpsPoAhv1zZvezYZPCEvypYgSvyOewgeCfjAKLme+2FvSbo3 gEgFlm9iLxYHaFNZJClQQyYjr3g5PSddtQ== X-Google-Smtp-Source: ABdhPJxjzbLeGjMoO828lOMPRD+O+LkIu1RvAi/nr6Grpqwd83rycbYFBdmBmn1ChUJIlnq+Ch46Wg== X-Received: by 2002:a5d:47c3:: with SMTP id o3mr8349736wrc.122.1623067115157; Mon, 07 Jun 2021 04:58:35 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 92sm17215166wrp.88.2021.06.07.04.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:58:34 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 2/4] test-tools: migrate read-cache-perf to parse_options() Date: Mon, 7 Jun 2021 13:58:25 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.rc3.434.gd8aed1f08a7 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the newly added (but then mostly copy/pasted) read-cache-perf to use the parse_options() API. This will make things easier as we add new options. Since we check the "cnt = < 1" case now via more idiomatic post-parse_options() assertions we can move from the for-loop to a while-loop and ditch the "i" variable. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-read-cache-perf.c | 26 ++++++++++++++++++++------ t/perf/p0002-read-cache.sh | 2 +- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/t/helper/test-read-cache-perf.c b/t/helper/test-read-cache-perf.c index 90176c010a..54ad0c3135 100644 --- a/t/helper/test-read-cache-perf.c +++ b/t/helper/test-read-cache-perf.c @@ -1,18 +1,32 @@ #include "test-tool.h" #include "cache.h" +#include "parse-options.h" + +static const char *read_cache_perf_usage[] = { + "test-tool read-cache-perf [...]", + NULL +}; int cmd__read_cache_perf(int argc, const char **argv) { struct repository *r = the_repository; - int i, cnt = 1; + int cnt = -1; + struct option options[] = { + OPT_INTEGER(0, "count", &cnt, "number of passes"), + OPT_END() + }; - if (argc == 2) - cnt = strtol(argv[1], NULL, 0); - else - die("usage: test-tool read-cache-perf []"); + argc = parse_options(argc, argv, "test-tools", options, + read_cache_perf_usage, 0); + if (argc > 0) + usage_msg_opt("Too many arguments.", read_cache_perf_usage, + options); + if (cnt < 1) + usage_msg_opt("Need at least one pass.", read_cache_perf_usage, + options); setup_git_directory(); - for (i = 0; i < cnt; i++) { + while (cnt--) { repo_read_index(r); discard_index(r->index); } diff --git a/t/perf/p0002-read-cache.sh b/t/perf/p0002-read-cache.sh index d0ba5173fb..1762b64865 100755 --- a/t/perf/p0002-read-cache.sh +++ b/t/perf/p0002-read-cache.sh @@ -8,7 +8,7 @@ test_perf_default_repo count=1000 test_perf "read_cache/discard_cache $count times" " - test-tool read-cache-perf $count + test-tool read-cache-perf --count=$count " test_done From patchwork Mon Jun 7 11:58:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12303403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B3E7C47082 for ; Mon, 7 Jun 2021 11:59:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C62961205 for ; Mon, 7 Jun 2021 11:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbhFGMB3 (ORCPT ); Mon, 7 Jun 2021 08:01:29 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]:44628 "EHLO mail-wm1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbhFGMB2 (ORCPT ); Mon, 7 Jun 2021 08:01:28 -0400 Received: by mail-wm1-f44.google.com with SMTP id p13-20020a05600c358db029019f44afc845so9955874wmq.3 for ; Mon, 07 Jun 2021 04:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N1mDVaCj1hIb3ucbxdGlCiyCdR6N+Y9CzcBj3RxlkVU=; b=nzZKErh8sjU5VvuBsvpn74Cu3HWnja6ogZ0aH0HXisJY8LvvnojMgVPpG3f65ci5t8 HEbVduFz2Nv8w4I1+s7O1bNses/usVx8DWfYiaYSigTJsGF4JfuDUu/PO+DeWcVfql7S ghePjR6Bjxe5sZ+aAq2+vqbx3A8JMVVoKjFxyTJH/TnQANsSwbbva09czkKMP5ZfI66F g4gaFU68/Cz9jgvyJ6cl9jugSEVj/m8Ucc6uFdpMhJsQSOTUO1sy7MtrPzBd/bZc0mhz r3fOBAl5SGCA6scY9vfJifYXy6FVE0QdjrGTV+7M5RumXD/gjkNH7Fc38cSjbgpixtm9 Rd0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N1mDVaCj1hIb3ucbxdGlCiyCdR6N+Y9CzcBj3RxlkVU=; b=ejvVSxZA1l57rqV1hmQsHT48rm0kXfygxsrAp7uLhfoDyVJpwhZ5Qpv6hSPnkJ55Wv zEQzCtDS+VsOast0WlY18SyDx11/DAFOh4qBNkSj5/BOIU+HcRqG8gFSFI8ic32n8EjR 76Jho4oJbc1GqbKU24XlNjXQbc+XDiFkjFTrLZjeB6Jk9onnYtVMTSHISGSAMp7I/bg9 Xd0DDX9W2g4eRtxG3zXl39n33eCPNlwUjZETZkD11rT9KJbqjxwbjq38uCKSdByd7GMD 0lNnS0dxW/UtaCYLuqVmUky1n3pKoEWKM3o2gf8pG1ObTWoEVDi+AvQ9Xs4PeUdvV5YN kKQg== X-Gm-Message-State: AOAM530EfgsDdHWtgbdtkOJ/2OAbFyjIZmGq+eLkXCiSLJR0K9ikmgaT d62UHdb7VpHc1VnO6f9vfUfqwJoNoabaiA== X-Google-Smtp-Source: ABdhPJzHjlHLkktgAvfOVbl4hdoQPmf/OmlD718/dm9Sn2PcHTWhdKv/2QV2p8/Ir/2VoBQbqO/0ag== X-Received: by 2002:a1c:7907:: with SMTP id l7mr16684505wme.147.1623067116219; Mon, 07 Jun 2021 04:58:36 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 92sm17215166wrp.88.2021.06.07.04.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:58:35 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 3/4] test-tools: migrate read-cache-again to parse_options() Date: Mon, 7 Jun 2021 13:58:26 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.rc3.434.gd8aed1f08a7 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the newly added (but then mostly copy/pasted) read-cache-perf to use the parse_options() API. I have no plans to further modify read-cache-again, but making these commands consistent has a value in and of itself. Since we check the "cnt = < 1" case now via more idiomatic post-parse_options() assertions we can move from the for-loop to a while-loop and ditch the "i" variable. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-read-cache-again.c | 28 ++++++++++++++++++++++------ t/t7519-status-fsmonitor.sh | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/t/helper/test-read-cache-again.c b/t/helper/test-read-cache-again.c index 707db036cb..8487f79d04 100644 --- a/t/helper/test-read-cache-again.c +++ b/t/helper/test-read-cache-again.c @@ -1,20 +1,36 @@ #include "test-tool.h" #include "cache.h" +#include "parse-options.h" + +static const char *read_cache_again_usage[] = { + "test-tool read-cache-again [...] ", + NULL +}; int cmd__read_cache_again(int argc, const char **argv) { struct repository *r = the_repository; - int i, cnt; + int cnt = -1; const char *name; + struct option options[] = { + OPT_INTEGER(0, "count", &cnt, "number of passes"), + OPT_END() + }; - if (argc != 2) - die("usage: test-tool read-cache-again "); - - cnt = strtol(argv[0], NULL, 0); + argc = parse_options(argc, argv, "test-tools", options, + read_cache_again_usage, 0); + if (argc != 1) + usage_msg_opt("Too many arguments.", read_cache_again_usage, + options); + if (cnt == -1) + cnt = 2; + else if (cnt < 1) + usage_msg_opt("Need at least one pass.", read_cache_again_usage, + options); name = argv[2]; setup_git_directory(); - for (i = 0; i < cnt; i++) { + while (cnt--) { int pos; repo_read_index(r); refresh_index(r->index, REFRESH_QUIET, diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 4c199c16d4..fd0815f6b7 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -359,7 +359,7 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR' test_expect_success 'discard_index() also discards fsmonitor info' ' test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" && test_might_fail git update-index --refresh && - test-tool read-cache-again 2 tracked >actual && + test-tool read-cache-again --count=2 tracked >actual && printf "tracked is%s up to date\n" "" " not" >expect && test_cmp expect actual ' From patchwork Mon Jun 7 11:58:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12303401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1D7AC47082 for ; Mon, 7 Jun 2021 11:58:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B13A0611AD for ; Mon, 7 Jun 2021 11:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbhFGMAt (ORCPT ); Mon, 7 Jun 2021 08:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbhFGMAs (ORCPT ); Mon, 7 Jun 2021 08:00:48 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F32C061766 for ; Mon, 7 Jun 2021 04:58:42 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id i94so12238111wri.4 for ; Mon, 07 Jun 2021 04:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r0xzgf6LNlsk/SR2IcsJ4Oq1MWb1y0CfBT5f0JgiEPQ=; b=BvEFbfFu331pRFhvSE0LVWciXyk6rw4x3ZtRUKg4OqbXLc3oXCztZLRo9GPdvEvo4Z 4BNAfcg/fnUSN5EKIAvHaGumLaB8z5foWe545U6cWvSDv3YoFEC2wL72COqENWphW5JF gVvr0cNp9imFpdpo0Mh8Z7lw/mxKAVwwhkrIMO+kJZyzCiN51EId8MPMYj+tMyNaSRly X6QGdXC0PtIt7OElAnreaC8ktK4spcHR/0ohaQdgfqYVkme/EElOt7H01MtZZvtAOZVj CT0OlqMr8jiwo7/AzNyL89xZc9nrLEXR0il0OIjFZLu7MXJsqPlBWtLwrvEojBbvHLxj 3S0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r0xzgf6LNlsk/SR2IcsJ4Oq1MWb1y0CfBT5f0JgiEPQ=; b=ktlaIYwXaEEP50FOHiX7qNGCsXNoDRrimb0dOzHApuyIwa9uWDAbzjOeCHPV1zVoVf f6QFTHJIpvxE04B2vuRuqhJYpyzjxCTEdWMAcHt6AoGX74Cgd+7FXwqGE3/DuHIsI0Pv ruS0oyD+sf8zujXZP1DIRYApCn26325rBI1NuUK+gLq26GkKgD0FO96HGxkhmcMidnV5 d1LoO6ujbaRksiHgLwdeDh1Sxf1KsbWaJ/6gMb6yKzD5e9Pk2LZQ5BJWojZHUINfGKRh /j4TrJ3Mv9P76TE3PbVjwtK86UzHV6D8MokSL1SDvtHMkJply5FFRtEK3q9HmiXLJzP3 yTAw== X-Gm-Message-State: AOAM530cLmyLc9U7nt8Auj1P92WkLIHt8Qw4ZfgKlWiob5R7Y7FMBqN/ HWZjuSWhqaUpQhSSVDpRG2JCOzPLdVR6KA== X-Google-Smtp-Source: ABdhPJwae+bqE/jz/efp7Mpa5SKNX/YLUL986nnA17xxtyE1QKUFOMnzW8U8YMR9cQOMuDlMPDzXqg== X-Received: by 2002:adf:eb82:: with SMTP id t2mr16692758wrn.337.1623067117095; Mon, 07 Jun 2021 04:58:37 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id 92sm17215166wrp.88.2021.06.07.04.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 04:58:36 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Derrick Stolee , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 4/4] read-cache perf: add a perf test for refresh_index() Date: Mon, 7 Jun 2021 13:58:27 +0200 Message-Id: X-Mailer: git-send-email 2.32.0.rc3.434.gd8aed1f08a7 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a perf test for the refresh_index() function to compliment the existing read()/discard() in a loop perf test added in 1ecb5ff141f (read-cache: add simple performance test, 2013-06-09). Since this test is much slower (around 10x) than the previous read()/discard() test let's run it 100 times instead of the 1000 time the first one runs. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/helper/test-read-cache-perf.c | 12 ++++++++++++ t/perf/p0002-read-cache.sh | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/t/helper/test-read-cache-perf.c b/t/helper/test-read-cache-perf.c index 54ad0c3135..a2802559a5 100644 --- a/t/helper/test-read-cache-perf.c +++ b/t/helper/test-read-cache-perf.c @@ -11,8 +11,11 @@ int cmd__read_cache_perf(int argc, const char **argv) { struct repository *r = the_repository; int cnt = -1; + int refresh = 0; struct option options[] = { OPT_INTEGER(0, "count", &cnt, "number of passes"), + OPT_BOOL(0, "refresh", &refresh, + "call refresh_index() in a loop, not read()/discard()"), OPT_END() }; @@ -26,10 +29,19 @@ int cmd__read_cache_perf(int argc, const char **argv) options); setup_git_directory(); + if (refresh) + repo_read_index(r); while (cnt--) { + if (refresh) { + unsigned int flags = REFRESH_QUIET|REFRESH_PROGRESS; + refresh_index(r->index, flags, NULL, NULL, NULL); + continue; + } repo_read_index(r); discard_index(r->index); } + if (refresh) + discard_index(r->index); return 0; } diff --git a/t/perf/p0002-read-cache.sh b/t/perf/p0002-read-cache.sh index 1762b64865..cbccc5ace9 100755 --- a/t/perf/p0002-read-cache.sh +++ b/t/perf/p0002-read-cache.sh @@ -11,4 +11,9 @@ test_perf "read_cache/discard_cache $count times" " test-tool read-cache-perf --count=$count " +count=100 +test_perf "refresh_index() $count times" " + test-tool read-cache-perf --count=$count --refresh +" + test_done