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

Re: [PATCH 2/5] reftable/stack: add function to check if optimization is required

From
Justin Tobler <jltobler@gmail.com>
Date
Nov 3, 2025, 17:59 UTC
Message-ID
<6b45z4xnzwzfi4ll5bintxqsrdwpaeb2mhozlujufalgrgfys7@6bw4z2ukplkn>
In-Reply-To
<CAOLa=ZRzLviMkc8C8617L48NwJPvi7F1Qsozezm9gUQ0_dRU4A@mail.gmail.com>
On 25/11/03 07:51AM, Karthik Nayak wrote:
Show 26 quoted lines
> Justin Tobler <jltobler@gmail.com> writes:
> 
> >> +int reftable_stack_compaction_required(struct reftable_stack *st,
> >> +				       bool use_heuristics,
> >> +				       bool *required)
> >> +{
> >> +	struct segment seg;
> >> +	int err = 0;
> >> +
> >> +	if (st->merged->tables_len < 2) {
> >> +		*required = false;
> >> +		return 0;
> >> +	}
> >
> > Both `reftable_stack_auto_compact()` and `suggest_compaction_segement()`
> > already check if the stack has less than two tables. I wonder if we can
> > avoid having multiple of these checks by instead having a single one at
> > the start of `stack_segements_for_compaction()`?
> >
> 
> Well we can't for two reasons:
> 1. We want to perform this check independent of whether `use_heuristics`
>    is set or not.
> 2. Currently `stack_segements_for_compaction()` does one thing only,
>    which is stack the segments. I wouldn't want to introduce another
>    responsibility to it.

That's fair. From my understanding, `stack_segements_for_compaction()` populates a segment which defines the range of tables that should be compacted to restore the geometric sequence. Since we want to ultimately know whether compaction needs to occur, my thought process was we could maybe have a single function ("check_compaction_needed()") that effectively returns a boolean and maybe be able to reuse that. I don't think it matters much though and as you mention we also want to consider `use_heuristics`.

Show 12 quoted lines
> >> +	if (!use_heuristics) {
> >> +		*required = true;
> >> +		return 0;
> >> +	}
> >
> > Is there a reason we would want to skip validating the geometric
> > sequence and just assume it compaction is required?
> >
> 
> This is the difference between running 'git refs optimize' with and
> without '--auto'. With '--auto' we will use heuristics to do a geometric
> progression. Without, we simply compact all tables into one.

That's for the clarification. So without --auto, instead of following a geometric sequence, a different maintenance strategy is used and we compact all the tables into one. Makes sense.

-Justin
Previous: Karthik NayakNext: Patrick Steinhardt
Message 11 of 57 in “maintenance: add an 'is-needed' subcommand”
  1. 0/5 maintenance: add an 'is-needed' subcommandKarthik Nayak, Oct 31, 2025
  2. 1/5 reftable/stack: return stack segments directlyKarthik Nayak, Oct 31, 2025
  3. Justin ToblerOct 31, 2025
  4. Karthik NayakNov 3, 2025
  5. Justin ToblerNov 3, 2025
  6. 2/5 reftable/stack: add function to check if optimization is requiredKarthik Nayak, Oct 31, 2025
  7. Justin ToblerOct 31, 2025
  8. Junio C HamanoOct 31, 2025
  9. Karthik NayakNov 3, 2025
  10. Karthik NayakNov 3, 2025
  11. Justin ToblerNov 3, 2025
  12. Patrick SteinhardtNov 3, 2025
  13. Karthik NayakNov 3, 2025
  14. 3/5 refs: add a `optimize_required` field to `struct ref_storage_be`Karthik Nayak, Oct 31, 2025
  15. 4/5 maintenance: add checking logic in `pack_refs_condition()`Karthik Nayak, Oct 31, 2025
  16. Patrick SteinhardtNov 3, 2025
  17. Karthik NayakNov 3, 2025
  18. 5/5 maintenance: add 'is-needed' subcommandKarthik Nayak, Oct 31, 2025
  19. Patrick SteinhardtNov 3, 2025
  20. Karthik NayakNov 3, 2025
  21. Patrick SteinhardtNov 4, 2025
  22. Karthik NayakNov 4, 2025
  23. 0/5 maintenance: add an 'is-needed' subcommandKarthik Nayak, Nov 4, 2025
  24. 1/5 reftable/stack: return stack segments directlyKarthik Nayak, Nov 4, 2025
  25. 3/5 refs: add a `optimize_required` field to `struct ref_storage_be`Karthik Nayak, Nov 4, 2025
  26. 2/5 reftable/stack: add function to check if optimization is requiredKarthik Nayak, Nov 4, 2025
  27. Junio C HamanoNov 4, 2025
  28. Karthik NayakNov 5, 2025
  29. Junio C HamanoNov 5, 2025
  30. Karthik NayakNov 6, 2025
  31. 4/5 maintenance: add checking logic in `pack_refs_condition()`Karthik Nayak, Nov 4, 2025
  32. 5/5 maintenance: add 'is-needed' subcommandKarthik Nayak, Nov 4, 2025
  33. Junio C HamanoNov 4, 2025
  34. Karthik NayakNov 5, 2025
  35. 0/5 maintenance: add an 'is-needed' subcommandKarthik Nayak, Nov 6, 2025
  36. 1/5 reftable/stack: return stack segments directlyKarthik Nayak, Nov 6, 2025
  37. 2/5 reftable/stack: add function to check if optimization is requiredKarthik Nayak, Nov 6, 2025
  38. Junio C HamanoNov 6, 2025
  39. Patrick SteinhardtNov 7, 2025
  40. 3/5 refs: add a `optimize_required` field to `struct ref_storage_be`Karthik Nayak, Nov 6, 2025
  41. 4/5 maintenance: add checking logic in `pack_refs_condition()`Karthik Nayak, Nov 6, 2025
  42. Patrick SteinhardtNov 6, 2025
  43. Karthik NayakNov 6, 2025
  44. Junio C HamanoNov 6, 2025
  45. Karthik NayakNov 7, 2025
  46. Junio C HamanoNov 7, 2025
  47. Karthik NayakNov 7, 2025
  48. 5/5 maintenance: add 'is-needed' subcommandKarthik Nayak, Nov 6, 2025
  49. Patrick SteinhardtNov 6, 2025
  50. Karthik NayakNov 6, 2025
  51. 0/5 maintenance: add an 'is-needed' subcommandKarthik Nayak, Nov 8, 2025
  52. 1/5 reftable/stack: return stack segments directlyKarthik Nayak, Nov 8, 2025
  53. 2/5 reftable/stack: add function to check if optimization is requiredKarthik Nayak, Nov 8, 2025
  54. 3/5 refs: add a `optimize_required` field to `struct ref_storage_be`Karthik Nayak, Nov 8, 2025
  55. 4/5 maintenance: add checking logic in `pack_refs_condition()`Karthik Nayak, Nov 8, 2025
  56. 5/5 maintenance: add 'is-needed' subcommandKarthik Nayak, Nov 8, 2025
  57. Patrick SteinhardtNov 10, 2025

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.