Re: [PATCH 2/5] reftable/stack: add function to check if optimization is required
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Nov 3, 2025, 16:20 UTC
- Message-ID
- <CAOLa=ZRywiKbsdAZYzVqGUKO1NBPz3iBhcjch9KFq72eZvUoPw@mail.gmail.com>
- In-Reply-To
- <xmqqseez0wcs.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 24 quoted lines
> Justin Tobler <jltobler@gmail.com> writes: > >>> + err = stack_segments_for_compaction(st, &seg); >>> + if (err) >>> + return err; >>> + >>> + *required = segment_size(&seg) > 0; >> >> As mentioned on the previous patch, I wonder if we could just return the >> number of tables in the compaction segment as part of >> `stack_segments_for_compaction()`. A negative value could indicate an >> error. All other values would reflect the number of tables to be >> compacted. >> >> This way callers interested in whether compaction should be performed >> could just do: stack_segments_for_compaction > 0. We could maybe avoid >> having a separate function like we do here and just expose >> `stack_segments_for_compaction()`. > > Is the cost of compacting a single table expected to be roughly the > same across tables? The number of tables to be compacted would not > be a useful information to help making a better decision otherwise, > so I am guessing that it is the underlying assumption the above > suggestion comes from.
It would be sufficient information to know whether or not we can compact. But only when in 'git refs optimize --auto' mode.