Re: [PATCH 2/5] reftable/stack: add function to check if optimization is required
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 31, 2025, 18:17 UTC
- Message-ID
- <xmqqseez0wcs.fsf@gitster.g>
- In-Reply-To
- <tdgxvocyp2armupgbti2wnbjphdvidooddbdyrynmdokjgqr3o@tzrbu5lcgipt>
Justin Tobler <jltobler@gmail.com> writes:
Show 16 quoted lines
>> + 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.