Junio C Hamano writes: > Justin Tobler 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.