> Jonathan Tan <jonathantanmy@xxxxxxxxxx> writes: > > > My argument is that typically *no* objects are missing, so we should > > delay the prefetch as much as possible in the hope that we don't need it > > at all. I admit that if some objects are missing, I don't know where > > they will be in the to_pack list. > > OK, if the common case we optimize for is where there is no object > missing, then of course "prefetch missing ones upfront" will spend > cycles to ensure all objects we will pack exist before going into > the main loop, so the "delay as much as possible" optimization makes > sense. OK. > >> In any case, the design choice needs to be justified in the log > >> message. I am not sure if the lazy decision to prefetch at the last > >> moment is really worth the code smell. Perhaps it is, if there is a > >> reason to believe that it would save extra work compared to the more > >> naive "if we have promissor remote, prefetch what is missing", but I > >> do not think I've heard that reason yet. > > > > I still think that there is a reason (the extra existence check), but if > > we think that the extra existence check is fast enough (compared to the > > other operations in pack-objects) or that there is a way to avoid > > calling oid_object_info_extended() twice for the same object (even with > > moving the prefetch loop to the beginning), then I agree that we don't > > need the lazy decision. (Or if we want to write the simpler code now and > > only improve the performance if we need it later, that's fine with me > > too.) > > Now I finally have, I think, heard some of the reasoning behind the > design decision made before this patch was written. That should be > written in the proposed log message. > > Thanks. OK - how about: [start] When an object to be packed is noticed to be missing, prefetch all to-be-packed objects in one batch. Most of the time (typically, when serving a fetch or when pushing), packs consist only of objects that the repo has. To maintain the performance in this case, the existing object type read is made to also serve as the object existence check: if the read fails, then we do the prefetch. An alternative design is to loop over all the entries in to_pack, checking the existence of each object, and prefetching if we notice any missing. This would result in clearer code, but would incur some performance degradation in the aforementioned most common case due to the additional object existence checks. Signed-off-by: Jonathan Tan <jonathantanmy@xxxxxxxxxx> [end] The first paragraph is already in the original, and the rest are additions.