forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
survey: stub in new experimental 'git-survey' command
Start work on a new 'git survey' command to scan the repository for monorepo performance and scaling problems. The goal is to measure the various known "dimensions of scale" and serve as a foundation for adding additional measurements as we learn more about Git monorepo scaling problems. The initial goal is to complement the scanning and analysis performed by the GO-based 'git-sizer' (https://github.com/github/git-sizer) tool. It is hoped that by creating a builtin command, we may be able to take advantage of internal Git data structures and code that is not accessible from GO to gain further insight into potential scaling problems. Co-authored-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Jeff Hostetler <git@jeffhostetler.com> Signed-off-by: Derrick Stolee <stolee@gmail.com>
- Loading branch information
Showing
13 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
survey.*:: | ||
These variables adjust the default behavior of the `git survey` | ||
command. The intention is that this command could be run in the | ||
background with these options. | ||
+ | ||
-- | ||
verbose:: | ||
This boolean value implies the `--[no-]verbose` option. | ||
progress:: | ||
This boolean value implies the `--[no-]progress` option. | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
git-survey(1) | ||
============= | ||
|
||
NAME | ||
---- | ||
git-survey - EXPERIMENTAL: Measure various repository dimensions of scale | ||
|
||
SYNOPSIS | ||
-------- | ||
[verse] | ||
(EXPERIMENTAL!) 'git survey' <options> | ||
|
||
DESCRIPTION | ||
----------- | ||
|
||
Survey the repository and measure various dimensions of scale. | ||
|
||
As repositories grow to "monorepo" size, certain data shapes can cause | ||
performance problems. `git-survey` attempts to measure and report on | ||
known problem areas. | ||
|
||
OPTIONS | ||
------- | ||
|
||
--progress:: | ||
Show progress. This is automatically enabled when interactive. | ||
|
||
OUTPUT | ||
------ | ||
|
||
By default, `git survey` will print information about the repository in a | ||
human-readable format that includes overviews and tables. | ||
|
||
GIT | ||
--- | ||
Part of the linkgit:git[1] suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#define USE_THE_REPOSITORY_VARIABLE | ||
|
||
#include "builtin.h" | ||
#include "config.h" | ||
#include "parse-options.h" | ||
|
||
static const char * const survey_usage[] = { | ||
N_("(EXPERIMENTAL!) git survey <options>"), | ||
NULL, | ||
}; | ||
|
||
struct survey_opts { | ||
int verbose; | ||
int show_progress; | ||
}; | ||
|
||
struct survey_context { | ||
struct repository *repo; | ||
|
||
/* Options that control what is done. */ | ||
struct survey_opts opts; | ||
}; | ||
|
||
static int survey_load_config_cb(const char *var, const char *value, | ||
const struct config_context *cctx, void *pvoid) | ||
{ | ||
struct survey_context *ctx = pvoid; | ||
|
||
if (!strcmp(var, "survey.verbose")) { | ||
ctx->opts.verbose = git_config_bool(var, value); | ||
return 0; | ||
} | ||
if (!strcmp(var, "survey.progress")) { | ||
ctx->opts.show_progress = git_config_bool(var, value); | ||
return 0; | ||
} | ||
|
||
return git_default_config(var, value, cctx, pvoid); | ||
} | ||
|
||
static void survey_load_config(struct survey_context *ctx) | ||
{ | ||
git_config(survey_load_config_cb, ctx); | ||
} | ||
|
||
int cmd_survey(int argc, const char **argv, const char *prefix, struct repository *repo) | ||
{ | ||
static struct survey_context ctx = { | ||
.opts = { | ||
.verbose = 0, | ||
.show_progress = -1, /* defaults to isatty(2) */ | ||
}, | ||
}; | ||
|
||
static struct option survey_options[] = { | ||
OPT__VERBOSE(&ctx.opts.verbose, N_("verbose output")), | ||
OPT_BOOL(0, "progress", &ctx.opts.show_progress, N_("show progress")), | ||
OPT_END(), | ||
}; | ||
|
||
if (argc == 2 && !strcmp(argv[1], "-h")) | ||
usage_with_options(survey_usage, survey_options); | ||
|
||
ctx.repo = repo; | ||
|
||
prepare_repo_settings(ctx.repo); | ||
survey_load_config(&ctx); | ||
|
||
argc = parse_options(argc, argv, prefix, survey_options, survey_usage, 0); | ||
|
||
if (ctx.opts.show_progress < 0) | ||
ctx.opts.show_progress = isatty(2); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
test_description='git survey' | ||
|
||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main | ||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME | ||
|
||
TEST_PASSES_SANITIZE_LEAK=0 | ||
export TEST_PASSES_SANITIZE_LEAK | ||
|
||
. ./test-lib.sh | ||
|
||
test_expect_success 'git survey -h shows experimental warning' ' | ||
test_expect_code 129 git survey -h 2>usage && | ||
grep "EXPERIMENTAL!" usage | ||
' | ||
|
||
test_done |