Refactor Repository's ref reading/writing for aggressive caching
commite2a740480095be18b9e1a94032d9d75c7d6af96d
authorShawn O. Pearce <spearce@spearce.org>
Thu, 15 May 2008 23:01:29 +0000 (15 19:01 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Sat, 17 May 2008 03:59:50 +0000 (16 23:59 -0400)
treed7f72492da38cd4ed42d2a90023bd58a8b9bf4fd
parentc0835e4a8b54ceed9fd0b41d9bbc605f0d1cffe5
Refactor Repository's ref reading/writing for aggressive caching

We kept reading the packed-refs file on every request for the refs,
as we never updated our cached last modification time.  We also did
not remember the peeled ref information if it was available in the
packed-refs file, making client applications potentially spend CPU
time to parse the tag.

By storing all ref data as a Ref object we can return all known
packed ref entries, along with their peeled object (if available)
without needing to re-read the file or create a new Ref object for
the read request.  This reduces the costs associated with reading
all available refs.

The packed-refs file is cached by remembering the combination
of both modification time and file size, to try and avoid racy
update operations.  The caching is not perfect as we cannot detect
all updates if they happen too quickly, but it is good enough for
most uses against packed-refs as the file is not usually updated
more than once per minute.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.spearce.egit.core.test/src/org/spearce/egit/core/internal/mapping/T0002_history.java
org.spearce.egit.core.test/src/org/spearce/egit/core/op/T0001_ConnectProviderOperationTest.java
org.spearce.egit.core/src/org/spearce/egit/core/internal/storage/CommitFileRevision.java
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/BranchSelectionDialog.java
org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0003_Basic.java
org.spearce.jgit/src/org/spearce/jgit/lib/LockFile.java
org.spearce.jgit/src/org/spearce/jgit/lib/RefDatabase.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/RefUpdate.java
org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
org.spearce.jgit/src/org/spearce/jgit/transport/PackFetchConnection.java
org.spearce.jgit/src/org/spearce/jgit/transport/WalkFetchConnection.java