Bug 578550 - JGit should avoid scanning all refs when fetching HEAD
Summary: JGit should avoid scanning all refs when fetching HEAD
Status: NEW
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 6.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-02 20:29 EST by Luca Milanesio CLA
Modified: 2023-11-12 08:38 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luca Milanesio CLA 2022-02-02 20:29:20 EST
The Git protocol v2 allows a client to request the fetching of a single symbolic refs, like HEAD.

The RefDatabase and RefDirectory implementations do not consider the case of a symbolic ref, causing the full scanning of all refs and post-scan filtering by the symbolic name.

When a repository contains millions of refs, performing a full scan isn't a good idea and produces unwanted memory utilisation and I/O.

RefDatabase and RefDirectory should manage the special case of HEAD and perform a single scan instead of scanning and loading all refs in memory.
Comment 1 Dariusz Luksza CLA 2023-11-07 04:35:00 EST
With the latest improvements to RefDatabase.getRefsByPrefix(String...)[1] we'll only do a single full ref scan no matter how many `ref-prefix` were sent by the git client. With this change we don't need additional handling for symbolic refs.

[1] https://git.eclipse.org/r/c/jgit/jgit/+/204910
Comment 2 Matthias Sohn CLA 2023-11-12 08:38:44 EST
https://git.eclipse.org/r/c/jgit/jgit/+/205387 was submitted as 4f18c5095049116350828e9bb499964ea887ac02