diff options
author | Anna Papitto <annapapitto@google.com> | 2023-04-27 11:01:30 -0700 |
---|---|---|
committer | Anna Papitto <annapapitto@google.com> | 2023-04-28 10:19:18 -0700 |
commit | 64615b44e6f4a7f14a43ba19d4dd28f8483ed2eb (patch) | |
tree | 98081ecdbfddcfd13c79b9fbb2cbdd73620ad9f2 /org.eclipse.jgit/resources/org | |
parent | 7d3f893d31a02ebf50b34fba7203f996d5162c62 (diff) | |
download | jgit-64615b44e6f4a7f14a43ba19d4dd28f8483ed2eb.tar.gz jgit-64615b44e6f4a7f14a43ba19d4dd28f8483ed2eb.zip |
PackReverseIndexWriter: write out version 1 reverse index file
The reverse index for a pack is used to quickly find an object's
position in the pack's forward index based on that object's pack offset.
It is currently computed from the forward index by sorting the index
entries by the corresponding pack offset. This computation uses
bucket sort with insertion sort, which has an average runtime of
O(n log n) and worst case runtime of O(n^2); and memory usage of
3*size(int)*n because it maintains 3 int arrays, even after sorting is
completed. The computation must be performed every time that the reverse
index object is created in memory.
In contrast, Cgit persists a pack reverse index file to avoid
recomputing the reverse index ordering every time that it is needed.
Instead they write a file with format
https://git-scm.com/docs/pack-format#_pack_rev_files_have_the_format
which can later be read and parsed into an in-memory reverse index each
time it is needed.
Introduce these reverse index files to JGit. PackReverseIndexWriter
writes out a reverse index file to be read later when needed. Subclass
PackReverseIndexWriterV1 writes a file with the official version 1
format.
To avoid temporarily allocating an Integer collection while sorting and
writing out the contents, using memory 4*size(Integer)*n, use an
IntList and its #sort method, which uses quicksort.
Change-Id: I6437745777a16f723e2f1cfcce4e0d94e599dcee
Signed-off-by: Anna Papitto <annapapitto@google.com>
Diffstat (limited to 'org.eclipse.jgit/resources/org')
-rw-r--r-- | org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties index 78dd9bd4c3..bc8144f1c9 100644 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@ -839,6 +839,7 @@ unsupportedGC=Unsupported garbage collector for repository type: {0} unsupportedMark=Mark not supported unsupportedOperationNotAddAtEnd=Not add-at-end: {0} unsupportedPackIndexVersion=Unsupported pack index version {0} +unsupportedPackReverseIndexVersion=Unsupported pack reverse index version {0} unsupportedPackVersion=Unsupported pack version {0}. unsupportedReftableVersion=Unsupported reftable version {0}. unsupportedRepositoryDescription=Repository description not supported |