[PATCH v3 2/6] odb/source-files: fix performance when streaming objects with alternates
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Oct 15, 2026, 05:27 UTC
- Message-ID
- <20261015-pks-odb-files-alternates-cleanups-v3-2-bfc62fd780eb@pks.im>
- In-Reply-To
- <20261015-pks-odb-files-alternates-cleanups-v3-0-bfc62fd780eb@pks.im>
This patch is essentially the equivalent to the preceding patch, but for streaming objects instead of just reading them directly.
Exercising performance is a bit more complicated here as streaming only really kicks in for large objects. Furthermore, I expect that the impact is not as big as with the last commit, either, because for large objects the time to stat the file will probably be dwarfed by the time it takes to read the object itself.
But even though this is probably not as impactful, it makes sense anyway to do this change to align behaviour across both of these functions.
Signed-off-by: Patrick Steinhardt <ps@pks.im> --- odb/source-files.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/odb/source-files.c b/odb/source-files.c index 9268f5aa9a..54235821d5 100644 --- a/odb/source-files.c +++ b/odb/source-files.c @@ -462,8 +462,10 @@ static int odb_source_files_read_object_stream(struct odb_stream **out, struct odb_source_files *files = odb_source_files_downcast(source); for (struct odb_files_dir *dir = files->dirs; dir; dir = dir->next) - if (!odb_source_read_object_stream(out, &dir->packed->base, oid) || - !odb_source_read_object_stream(out, &dir->loose->base, oid)) + if (!odb_source_read_object_stream(out, &dir->packed->base, oid)) + return 0; + for (struct odb_files_dir *dir = files->dirs; dir; dir = dir->next) + if (!odb_source_read_object_stream(out, &dir->loose->base, oid)) return 0; return -1;
-- 2.56.0.212.g129ede20d9.dirty