git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/5] cache-tree: add perf test comparing update and prime

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Nov 10, 2022, 07:23 UTC
Message-ID
<20221110072342.GA1159673@szeder.dev>
In-Reply-To
<45c198c629da1627eabf0e63539f50aaa50381bf.1667947465.git.gitgitgadget@gmail.com>
On Tue, Nov 08, 2022 at 10:44:21PM +0000, Victoria Dye via GitGitGadget wrote:
Show 14 quoted lines
> diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c
> new file mode 100644
> index 00000000000..2fad6d06d30
> --- /dev/null
> +++ b/t/helper/test-cache-tree.c
> @@ -0,0 +1,52 @@
> +#include "test-tool.h"
> +#include "cache.h"
> +#include "tree.h"
> +#include "cache-tree.h"
> +#include "parse-options.h"
> +
> +static char const * const test_cache_tree_usage[] = {
> +	N_("test-tool cache-tree <options> (prime|repair)"),

The code looking at 'argv[0]' below only handles "prime" and "update", but not "repair".

Show 22 quoted lines
> +	NULL
> +};
> +
> +int cmd__cache_tree(int argc, const char **argv)
> +{
> +	struct object_id oid;
> +	struct tree *tree;
> +	int fresh = 0;
> +	int count = 1;
> +	int i;
> +
> +	struct option options[] = {
> +		OPT_BOOL(0, "fresh", &fresh,
> +			 N_("clear the cache tree before each repetition")),
> +		OPT_INTEGER_F(0, "count", &count, N_("number of times to repeat the operation"),
> +			      PARSE_OPT_NONEG),
> +		OPT_END()
> +	};
> +
> +	setup_git_directory();
> +
> +	parse_options(argc, argv, NULL, options, test_cache_tree_usage, 0);

Here 'argc' must be updated with the return value of parse_options(), otherwise the 'if (!argc)' condition doesn't catch what it's supposed to, and the subsequent 'else if' segfaults when passes the NULL argv[0] to strcmp().

Show 11 quoted lines
> +
> +	if (read_cache() < 0)
> +		die("unable to read index file");
> +
> +	get_oid("HEAD", &oid);
> +	tree = parse_tree_indirect(&oid);
> +	for (i = 0; i < count; i++) {
> +		if (fresh)
> +			cache_tree_free(&the_index.cache_tree);
> +
> +		if (!argc)
What if argc > 1?
> +			die("Must specify subcommand");
I think it would be nice to show usage here ...
Show 6 quoted lines
> +		else if (!strcmp(argv[0], "prime"))
> +			prime_cache_tree(the_repository, &the_index, tree);
> +		else if (!strcmp(argv[0], "update"))
> +			cache_tree_update(&the_index, WRITE_TREE_SILENT | WRITE_TREE_REPAIR);
> +		else
> +			die("Unknown command %s", argv[0]);
... and here as well.
> +	}
> +
> +	return 0;
> +}
Previous: Victoria Dye via GitGitGadgetNext: Victoria Dye via GitGitGadget
Message 3 of 31 in “Skip 'cache_tree_update()' when 'prime_cache_tree()' is called immediate after”
  1. 0/5 Skip 'cache_tree_update()' when 'prime_cache_tree()' is called immediate afterVictoria Dye via GitGitGadget, Nov 8, 2022
  2. 1/5 cache-tree: add perf test comparing update and primeVictoria Dye via GitGitGadget, Nov 8, 2022
  3. SZEDER GáborNov 10, 2022
  4. 3/5 reset: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 8, 2022
  5. 2/5 unpack-trees: add 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 8, 2022
  6. 5/5 rebase: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 8, 2022
  7. 4/5 read-tree: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 8, 2022
  8. Derrick StoleeNov 9, 2022
  9. Victoria DyeNov 9, 2022
  10. Derrick StoleeNov 10, 2022
  11. Taylor BlauNov 9, 2022
  12. 0/5 Skip 'cache_tree_update()' when 'prime_cache_tree()' is called immediate afterVictoria Dye via GitGitGadget, Nov 10, 2022
  13. 3/5 reset: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 10, 2022
  14. 2/5 unpack-trees: add 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 10, 2022
  15. 1/5 cache-tree: add perf test comparing update and primeVictoria Dye via GitGitGadget, Nov 10, 2022
  16. 5/5 rebase: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 10, 2022
  17. Phillip WoodNov 10, 2022
  18. Victoria DyeNov 10, 2022
  19. 4/5 read-tree: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 10, 2022
  20. Taylor BlauNov 10, 2022
  21. Derrick StoleeNov 10, 2022
  22. 0/5 Skip 'cache_tree_update()' when 'prime_cache_tree()' is called immediate afterVictoria Dye via GitGitGadget, Nov 10, 2022
  23. 1/5 cache-tree: add perf test comparing update and primeVictoria Dye via GitGitGadget, Nov 10, 2022
  24. 2/5 unpack-trees: add 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 10, 2022
  25. 3/5 reset: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 10, 2022
  26. 5/5 rebase: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 10, 2022
  27. 4/5 read-tree: use 'skip_cache_tree_update' optionVictoria Dye via GitGitGadget, Nov 10, 2022
  28. SZEDER GáborNov 10, 2022
  29. Victoria DyeNov 10, 2022
  30. Taylor BlauNov 11, 2022
  31. Derrick StoleeNov 14, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.