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

Re: [PATCH v2 6/7] maintenance: recommended schedule in register/start

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Sep 29, 2020, 19:48 UTC
Message-ID
<CAN0heSqkJoqXKP5ccaGMA1_ppd0bcQ7G0ozUH+H7tBMonhcrjQ@mail.gmail.com>
In-Reply-To
<f609c1bde27558db2a9601ac34f8a51ce86f0e2c.1599846561.git.gitgitgadget@gmail.com>
Hi Stolee,

On Fri, 11 Sep 2020 at 19:53, Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 8 quoted lines
> If a user sets any 'maintenance.<task>.schedule' config value, then
> they have chosen a specific schedule for themselves and Git should
> respect that.
>
> However, in an effort to recommend a good schedule for repositories of
> all sizes, set new config values for recommended tasks that are safe to
> run in the background while users run foreground Git commands. These
> commands are generally everything but the 'gc' task.

If there aren't any "schedule" configurations, we'll go ahead and sprinkle in quite a few of them. I suppose that another approach would be that later, much later, when we go look for these configuration items, we could go "there is not a single one set, let's act as if *these* were configured".

The advantage there would be that we can tweak those defaults over time. Whereas with the approach of this patch, v2.29.0 will give the user a snapshot of 2020's best practices. If they want to catch up, they will need to drop all their "schedule" config and re-"register", or use a future `git maintenance reregister`. ;-)

Anyway, this is a convenience thing. There's a chance that "convenience" interferes with "perfect" and "optimal". I guess that's to be expected.

> +If your repository has no 'maintenance.<task>.schedule' configuration

Thank you for going above and beyond with marking config items et cetera for rendering in `monospace`. I just noticed that this is slightly mis-marked-upped. If you end up rerolling this patch series for some reason, you might want to switch from 'single quotes' to `backticks` in this particular instance.

While I'm commenting anyway...
Show 24 quoted lines
> +static int has_schedule_config(void)
> +{
> +       int i, found = 0;
> +       struct strbuf config_name = STRBUF_INIT;
> +       size_t prefix;
> +
> +       strbuf_addstr(&config_name, "maintenance.");
> +       prefix = config_name.len;
> +
> +       for (i = 0; !found && i < TASK__COUNT; i++) {
> +               char *value;
> +
> +               strbuf_setlen(&config_name, prefix);
> +               strbuf_addf(&config_name, "%s.schedule", tasks[i].name);
> +
> +               if (!git_config_get_string(config_name.buf, &value)) {
> +                       found = 1;
> +                       FREE_AND_NULL(value);
> +               }
> +       }
> +
> +       strbuf_release(&config_name);
> +       return found;
> +}

That `FREE_AND_NULL()` caught me off-guard. The pointer is on the stack. I suppose it doesn't *hurt*, but being careful to set it to NULL made me go "huh".

I suppose you could drop the `!found` check in favour of `break`-ing precisely when you get a hit.

And I do wonder how much the reuse of the "maintenance." part of the buffer helps performance.

In the end, you could use something like the following (not compiled):
  static int has_schedule_config(void)
  {
         int i, found = 0;
         struct strbuf config_name = STRBUF_INIT;
         for (i = 0; i < TASK__COUNT; i++) {
                 const char *value;
                 strbuf_reset(&config_name);
                 strbuf_addf(&config_name, "maintenance.%s.schedule",
tasks[i].name);
                 if (!git_config_get_value(config_name.buf, &value)) {
                         found = 1;
                         break;
                 }
         }
         strbuf_release(&config_name);
         return found;
  }

Anyway, that's just microniting, obviously, but maybe in the sum it has some value.

Martin
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee
Message 23 of 62 in “Maintenance III: Background maintenance”
  1. 0/7 Maintenance III: Background maintenanceDerrick Stolee via GitGitGadget, Sep 4, 2020
  2. 4/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Sep 4, 2020
  3. 3/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Sep 4, 2020
  4. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Sep 4, 2020
  5. 7/7 maintenance: add troubleshooting guide to docsDerrick Stolee via GitGitGadget, Sep 4, 2020
  6. 5/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Sep 4, 2020
  7. SZEDER GáborSep 8, 2020
  8. Derrick StoleeSep 8, 2020
  9. Junio C HamanoSep 8, 2020
  10. 2/7 maintenance: add --schedule option and configDerrick Stolee via GitGitGadget, Sep 4, 2020
  11. Đoàn Trần Công DanhSep 8, 2020
  12. Derrick StoleeSep 9, 2020
  13. 6/7 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Sep 4, 2020
  14. 0/7 Maintenance III: Background maintenanceDerrick Stolee via GitGitGadget, Sep 11, 2020
  15. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Sep 11, 2020
  16. 2/7 maintenance: add --schedule option and configDerrick Stolee via GitGitGadget, Sep 11, 2020
  17. 3/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Sep 11, 2020
  18. 4/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Sep 11, 2020
  19. Đoàn Trần Công DanhSep 17, 2020
  20. 5/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Sep 11, 2020
  21. 7/7 maintenance: add troubleshooting guide to docsDerrick Stolee via GitGitGadget, Sep 11, 2020
  22. 6/7 maintenance: recommended schedule in register/startDerrick Stolee via GitGitGadget, Sep 11, 2020
  23. Martin ÅgrenSep 29, 2020
  24. Derrick StoleeSep 30, 2020
  25. Derrick StoleeOct 1, 2020
  26. Đoàn Trần Công DanhOct 2, 2020
  27. Derrick StoleeOct 2, 2020
  28. Đoàn Trần Công DanhOct 5, 2020
  29. Derrick StoleeOct 5, 2020
  30. 0/7 Maintenance III: Background maintenanceDerrick Stolee via GitGitGadget, Oct 5, 2020
  31. 3/7 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Oct 5, 2020
  32. 2/7 maintenance: add --schedule option and configDerrick Stolee via GitGitGadget, Oct 5, 2020
  33. 6/7 maintenance: use default schedule if not configuredDerrick Stolee via GitGitGadget, Oct 5, 2020
  34. Martin ÅgrenOct 5, 2020
  35. Derrick StoleeOct 8, 2020
  36. 5/7 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Oct 5, 2020
  37. 4/7 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Oct 5, 2020
  38. 7/7 maintenance: add troubleshooting guide to docsDerrick Stolee via GitGitGadget, Oct 5, 2020
  39. 1/7 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Oct 5, 2020
  40. 0/8 Maintenance III: Background maintenanceDerrick Stolee via GitGitGadget, Oct 15, 2020
  41. 1/8 maintenance: optionally skip --auto processDerrick Stolee via GitGitGadget, Oct 15, 2020
  42. 3/8 for-each-repo: run subcommands on configured reposDerrick Stolee via GitGitGadget, Oct 15, 2020
  43. Andrzej HuntMay 3, 2021
  44. Eric SunshineMay 3, 2021
  45. Eric SunshineMay 3, 2021
  46. Derrick StoleeMay 3, 2021
  47. 5/8 maintenance: add start/stop subcommandsDerrick Stolee via GitGitGadget, Oct 15, 2020
  48. Josh SteadmonDec 9, 2020
  49. Josh SteadmonDec 9, 2020
  50. Derrick StoleeDec 9, 2020
  51. Junio C HamanoDec 10, 2020
  52. Derrick StoleeDec 10, 2020
  53. Junio C HamanoDec 10, 2020
  54. 7/8 maintenance: use 'incremental' strategy by defaultDerrick Stolee via GitGitGadget, Oct 15, 2020
  55. 2/8 maintenance: add --schedule option and configDerrick Stolee via GitGitGadget, Oct 15, 2020
  56. Ævar Arnfjörð BjarmasonFeb 9, 2021
  57. Derrick StoleeFeb 9, 2021
  58. Ævar Arnfjörð BjarmasonMay 10, 2021
  59. Junio C HamanoMay 10, 2021
  60. 6/8 maintenance: create maintenance.strategy configDerrick Stolee via GitGitGadget, Oct 15, 2020
  61. 4/8 maintenance: add [un]register subcommandsDerrick Stolee via GitGitGadget, Oct 15, 2020
  62. 8/8 maintenance: add troubleshooting guide to docsDerrick Stolee via GitGitGadget, Oct 15, 2020

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.