fangorn/ex_git_objectstore
public
lazy_fetch? reads every want from storage; use a cheap type probe instead #33
Links
No links yet.
Problem
`UploadPackV2.lazy_fetch?/2` calls `ObjectResolver.read/2` on every `want` to detect promisor lazy-fetch requests (where the want points to a blob or tree, not a commit). For a clone with many wants (34 wants on a typical anvil clone), that’s 34 extra storage round-trips before the walk even starts.
Fix plan
Add `ObjectResolver.read_type/2` (or `get_object_type/2`) that reads only the object-header bytes (` \0…`) without decompressing the full content. Use that in `lazy_fetch?/2`.
Cheap variant: for loose objects, read the first ~64 bytes from storage and decompress only that. For pack-stored objects, read the pack entry header (type + size varint) without the body.
Acceptance criteria
- `lazy_fetch?/2` performs zero full-object reads in the common (all-commits) case.
- A before/after microbenchmark shows a ~50% reduction in fetch-setup time on a clone with 30+ wants.
Context
Flagged in the audit of PR #20; tracked to follow-up.