Commit Graph

1678 Commits

Author SHA1 Message Date
Shawn O. Pearce 2610eaf386 Revert "PackWriter: Do not delta compress already packed objects"
This reverts commit 67b064fc9f.

The "tiny optimization" introduced by 67b0 turns out to have a big
savings on wall-clock time when the object store is very slow (e.g.
the DHT support in JGit), but comes with a much bigger penalty in
space used by the output stream.  CGit packed with 67b0 enabled is
7 MiB larger than it should be (36 MiB rather than 28/29 MiB).  The
much bigger Linux kernel repository gained over 200 MiB, though some
of this may have been caused by a smaller window setting.

Revert this patch as PackWriter should be optimizing for space used
rather than time spent, since its primary use is network transfer, and
that isn't free.

Change-Id: I7413a9ef89762208159b4a1adc5a22a4c9245611
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-13 17:01:29 -07:00
Shawn O. Pearce 53db854185 Speed up ObjectWalk by 6235 objects/sec
The "Counting objects" phase of packing is the most time consuming
part for any server providing access to Git repositories. Scanning
through the entire project history, including every revision of
every tree that has ever existed is expensive and takes an incredible
amount of CPU time.

Inline the tree parsing logic, unroll a number of loops, and setup
to better handle the common case of seeing another occurrence of
an object that was already marked SEEN.

This change boosts the "Counting objects" phase when JGit is acting
as a server and is packing the linux-2.6 repository for its client.
Compared to CGit on the same hardware, a JGit daemon server is now
21883 objects/sec faster:

CGit:
  Counted 2058062 objects in 38981 ms at 52796.54 objects/sec
  Counted 2058062 objects in 38920 ms at 52879.29 objects/sec
  Counted 2058062 objects in 39059 ms at 52691.11 objects/sec

JGit (before):
  Counted 2058062 objects in 31529 ms at 65275.21 objects/sec
  Counted 2058062 objects in 30359 ms at 67790.84 objects/sec
  Counted 2058062 objects in 30033 ms at 68526.69 objects/sec

JGit (this commit):
  Counted 2058062 objects in 28726 ms at 71644.57 objects/sec
  Counted 2058062 objects in 27652 ms at 74427.24 objects/sec
  Counted 2058062 objects in 27528 ms at 74762.50 objects/sec

Above the first run was a "cold server". For JGit the JVM had just
started up with `jgit daemon`, and for CGit we hadn't touched the
repository "recently" (but it was certainly in kernel buffer cache).
The second and third runs were against the running JGit JVM, allowing
timing tests to better reflect the benefits of JGit's pack and index
caching, as well as any optimizations the JIT may have performed.

The timings are fair.  CGit is opening, checking and mmap'ing both
the pack and index during the timer.  JGit is opening, checking
and malloc+read'ing the pack and index data into its Java heap
during the timer. Both processes are walking the same graph space,
and are computing the "path hash" necessary to sort objects in the
object table for delta compression.  Since this commit only impacts
the "Counting objects" phase, delta compression was obviously not
included in the timings and JGit may still be performing delta
compression slower than CGit, resulting in an overall slower server
experience for clients.

Change-Id: Ieb184bfaed8475d6960a494b1f3c870e0382164a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-13 14:53:18 -07:00
Shawn O. Pearce 82e735c3aa Merge "PackWriter: Only search for base objects on thin packs" 2011-08-13 17:33:18 -04:00
Shawn O. Pearce a5f5b20dff blame: Implement blame on the command line
Command line options match the C implementation of `git blame` as
closely as possible, making for a pretty complete tool.

Change-Id: Ie1bd172ad9de586c3b60f0ee4a77a8f047364882
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-13 14:12:03 -07:00
Shawn Pearce a2eadf0b67 Merge "Ignore missing MERGE_MSG when deleting MERGE_MSG" 2011-08-13 17:08:40 -04:00
Shawn Pearce ac9d9ee96d Merge "Correct comment on CloneCommand.setRemote method." 2011-08-13 17:00:29 -04:00
Shawn O. Pearce 895af1480d Merge "Fix jgit rev-list --objects master" 2011-08-13 16:59:52 -04:00
Robin Rosenberg 5a3a2b53ee Merge "Fix reading of ref names containing characters that sort before /" 2011-08-10 14:40:25 -04:00
Robin Rosenberg d4db26bb57 Merge "Fix offset64 creation for objects at 2 GiB" 2011-08-10 14:39:30 -04:00
Robin Stocker 8db5b6a013 Add isSuccessful to MergeStatus, RebaseResult.Status and PullResult
This is useful when the result needs to be displayed and it's only of
interest if the operation was successful or not (in egit, it could be
used in MultiPullResultDialog).

Change-Id: Icfc9a9c76763f8a777087a1262c8d6ad251a9068
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-08-09 23:31:50 +02:00
Shawn O. Pearce 3bac5b1d7d Fix offset64 creation for objects at 2 GiB
The offset32 format is used for objects <= 2^31-1, while the offset64
format is used for all other objects.  This condition was missing
the = needed to ensure an object placed exactly at 2^31 would have
its 64 bit offset in the index.

Change-Id: I293fac0e829c9baa12cb59411dffde666051d6c5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-08 16:36:56 -07:00
Shawn O. Pearce 99e6cfb131 PackWriter: Only search for base objects on thin packs
A non-thin pack does not need to worry about preferred bases, the pack
will be self-contained and all required delta base objects will appear
within the pack itself. Obtaining the path buffer and length from the
ObjectWalk to build the preferred base table is "expensive", so avoid
the cost unless a thin pack is being constructed.

Change-Id: I16e30cd864f4189d4304e7957a7cd5bdb9e84528
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-08 15:10:11 -07:00
Shawn O. Pearce 489604aaad Fix jgit rev-list --objects master
This flag was not being honored due to a bug in createWalk().
argWalk is always non-null when there are commits passed in
on the command line. If --objects was specified, always make
a new ObjectWalk for the actual execution.

Change-Id: I6e1a1636f2634605d86671a83766cc1c42939821
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-08-08 08:31:47 -07:00
Shawn O. Pearce 86ecf141b6 Merge changes I58110f17,I440baa64,Ic77dcac5
* changes:
  PackWriter: Skip progress messages on fast operations
  IndexPack: Defer the "Resolving deltas" progress meter
  IndexPack: Fix "Resolving deltas" progress meter
2011-08-05 21:21:10 -04:00
Kevin Sawicki 4ae9d47130 Correct comment on CloneCommand.setRemote method.
The previous comment stated that the value set was used
to keep track of the branch in the remote repository
which was incorrect.

Updated the method comment to match the format used
for the PushCommand.setRemote and FetchCommand.setRemote
methods.

Change-Id: I11b81eb3125958af29247b485da56fd88c3bfdf5
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-08-05 11:02:10 -07:00
Matthias Sohn 1067f82f56 Reuse ObjectReader for all objects touched during checkout
Bug: 349361
Change-Id: I61ffcb7694eb8b99ebaf4d0d0acd63e0ee91bcb3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-08-02 17:54:20 +02:00
Tomasz Zarna 6d293c7b06 Don't hard-code section names, use ConfigConstants instead
Change-Id: Ie2dde43da491fa27b25a2ad8014866d77d484b24
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-08-02 16:19:09 +02:00
Shawn O. Pearce 68cc21b60d PackWriter: Skip progress messages on fast operations
If the "Finding sources" phase will complete in <1 second with no
delta compression enabled, don't bother showing the progress meter for
this phase.  Small repositories on the local filesystem tend to rip
through this phase always subsecond and the ProgressMonitor display
can actually slow the operation down.

If delta compression is enabled, there are two phases that may run
very quickly. Set the timer to 500 milliseconds instead, reducing the
risk that the user has to wait longer than 1 second before any sort of
output from the packer occurs.

Change-Id: I58110f17e2a5ffa0134f9768b94804d16bbb8399
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce c81f6ab3ab IndexPack: Defer the "Resolving deltas" progress meter
If delta resolution completes in < 1000 milliseconds, don't bother
showing the progress meter. This is actually very common for a Gerrit
Code Review server, where the client is probably sending 1 commit and
only a few trees/blobs modified... and the base objects are hot in the
process buffer cache.

The 1000 millisecond delay is just a guess at a reasonable time to wait.

Change-Id: I440baa64ab0dfa21be61deae8dcd3ca061bed8ce
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce e0111b18c8 IndexPack: Fix "Resolving deltas" progress meter
This progress meter never reached 100% as it did not update while
resolving the external bases in thin packs.

Instead of updating in batches at the top level, update once per delta
that is resolved. The batching progress meter type should smooth out
the frequent updates to an update rate that is more reasonable to send
to the UI, while also ensuring a successful pack parse always reaches
100% deltas resolved.

Change-Id: Ic77dcac542cfa97213a6b0194708f9d3c256d223
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:22:50 -07:00
Shawn O. Pearce d16085b3b9 Make PackReverseIndex a public structure
Repository inspection tools may find building a reverse index on a
pack useful, as they can then locate an object by offset. As both
C Git and JGit sometimes produce error messages with the offset
rather than the SHA-1, it may be useful to expose this type.

Change-Id: I487bf32e85a8985cf8ab382d4c82fcbe1fc7da6c
2011-07-28 10:07:10 -07:00
Shawn O. Pearce d60cb2a3f5 Make lookup methods on PackIndex public
There isn't a good reason to hide all of these as package-private.
Make them public so applications can inspect pack files.

Change-Id: Ia418daf65d63e9e015b8dafdf3d06a1ed91d190b
2011-07-28 10:07:10 -07:00
Shawn O. Pearce 38c5b26245 PackIndex: Support reading from any InputStream
Change-Id: If065a9e33a8f3a03e9758eb7612af2fc460c87e5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-28 10:07:09 -07:00
Shawn O. Pearce d1f130f7f9 Add String form of PackInvalidException constructor
This way the path can be supplied as a string, without first
converting to a java.io.File.

Change-Id: I54d9bb9867556cd98b378c0762054b31497459cb
2011-07-28 10:07:09 -07:00
Shawn O. Pearce 14680f6e6e Add copy constructor to PackConfig
Some embeddings of UploadPack (e.g. Gerrit Code Review) set their own
PackConfig from a server-wide configuration, overriding any JGit
defaults or settings that may exist at the local repository level.

Make a copy constructor form of PackConfig so this server-wide
configuration object can be copied and then merged with repository
specific configuration data.

Change-Id: I4463c95aeaf7d6536c3ab132dec9c50ee528d9e0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-27 10:00:41 -07:00
Shawn O. Pearce bfa62d88d4 Don't close ObjectDatabase after parsing pack
The cached object databases should not require a close to release
their cached resources. Most object databases just return their
own reference for newCachedDatabase(), so a close() here kills
the real database's internal caches, and possibly underlying files,
resulting in poor performance for the callers of PackParser like
ReceivePack or FetchProcess trying to then go look up objects that
were just parsed, or that current references point to.

Change-Id: Ia4a239093866e5b9faf82744f729fb73f4373f1a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-07-27 10:00:41 -07:00
Robin Rosenberg c536873c87 Fix reading of ref names containing characters that sort before /
A set of ref names like ('a/b' and 'a+b') would cause the RefDirectory
to think that the set of refs have changed because it traversed the
'a' directory in the subtree before looking at 'a+b', but it then
compared with the know refs which are sorted with 'a+b' first.

Fix this by traversing the refs tree in another order. Treat a directory
as if they ends with a '/' before deciding on the order to traverse
the refs tree.

Bug: 348834
Change-Id: I23377f8df00c7252bf27dbcfba5da193c5403917
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-07-22 11:51:41 +02:00
Jens Baumgart dcf9ba411b Ignore missing MERGE_MSG when deleting MERGE_MSG
Repository.writeMergeCommitMsg(null) no longer fails if the MERGE_MSG
file is missing. This was done to avoid CommitCommand to fail in case of
a missing MERGE_MSG file.

Bug: 352243
Change-Id: Iddf43533d133f8f22199ed6e2393a552670e7d1f
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2011-07-19 17:31:50 +02:00
Tomasz Zarna e15037b3c7 Merge doesn't remove empty folders
Bug: 349848
Change-Id: I2aa5a1a7259889428e4845046b900538262f3c84
2011-07-13 15:42:33 +02:00
Dariusz Luksza 1d1f572771 Add support for reseting on directories
Reset command should works recursively and allows reset all changed
files in given directory.

Bug: 348524
Change-Id: I441db34f226be36548c61cef77958995971498de
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-07-12 11:14:28 -05:00
Sasa Zivkov 1d4a1fe772 Fixed creation of branch from a tag
Creation of a branch X from an annotated tag, as the starting point,
resulted into .git/refs/heads/X containing the ID of the annotated tag
instead of the ID of the tagged commit.

This fix peels the tag ref before using it as the starting point for
the newly created branch.

Bug: 340836
Change-Id: I01c7325770ecb37f5bf8ddb2a22f802466524f24
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-07-12 10:48:59 -05:00
Chris Aniszczyk f0060f64a7 Merge "Merge in JGit CLI is missing break statement" 2011-07-12 09:53:51 -04:00
Tomasz Zarna 1efecaa9f9 Merge in JGit CLI is missing break statement
Change-Id: I2095601b848e66e54d5dac828ef6ed1a4c5ae66c
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-07-12 08:48:53 -05:00
Adrian Goerler ad74bbf9c1 Cleanup directories leftover by test.
Use the temporary file management from superclass.

Change-Id: I3042951dc21860b4b85dd72a6bf41ee7cfe2aba4
Signed-off-by: Adrian Goerler <adrian.goerler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-07-07 23:16:40 +02:00
Adrian Goerler 172a9f0521 Cloning should fail when destination directory exists and is not empty
When trying to clone into a folder that already contains a cloned
repository native git will fail with a message "fatal: destination path
'folder' already exists and is not an empty directory.". Now JGit will
also fail in this situation throwing a JGitInternalException.

The test case was provided by Tomasz Zarna.

Bug: 347852
Change-Id: If9e9919a5f92d13cf038dc470c21ee5967322dac
Also-by: Tomasz Zarna <Tomasz.Zarna@pl.ibm.com>
Signed-off-by: Adrian Goerler <adrian.goerler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-07-06 23:10:53 +02:00
Stefan Lay 7e1b2466e3 Do not catch Exception in test cases
Exception handling is already done by JUnit.

Change-Id: Ia25d768c311d384d728f281aced92f598e5e2041
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-07-06 23:10:52 +02:00
Christian Halstrick 9ea9537d7c Merge "Cleanup curly braces" 2011-07-06 04:44:54 -04:00
Adrian Goerler 2062d623e3 Cleanup curly braces
Change-Id: I2de6439a3ad951a99d89e4aee02006c745d16510
Signed-off-by: Adrian Goerler <adrian.goerler@sap.com>
2011-07-06 10:29:56 +02:00
Christian Halstrick 18e10b41c9 Merge "Add lookup to remote config if the refSpec is not explicitly set" 2011-07-06 04:14:49 -04:00
Stefan Lay e2815f0121 Add lookup to remote config if the refSpec is not explicitly set
If no refSpec is explicitly set, the PushCommand should first check the
remote config and then as a fallback use the current behavior.


Change-Id: I2bc648abc517b1d01b2de15d383423ace2081e72
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-07-04 13:20:51 +02:00
Shawn Pearce ac56c024c1 Merge "Enable PlotWalk to show additional refs" 2011-07-01 11:58:24 -04:00
Stefan Lay 872c1fec17 Enable PlotWalk to show additional refs
Change-Id: Ic85f8859571dc2aef7f146ce56a6c9b8ec142e60
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-07-01 17:38:01 +02:00
Shawn O. Pearce 622d922ddc Merge "Improve performance when writing trees and small blobs" 2011-07-01 11:04:41 -04:00
Shawn O. Pearce 532f9eba3b Merge "TemporaryBuffer: Fix reading from in-memory InputStream" 2011-07-01 10:55:16 -04:00
Shawn Pearce 186b71f7e6 Merge "Implement Serializable interface in PersonIdent class." 2011-07-01 10:55:02 -04:00
Matthias Sohn 5223cb6e5a Merge "Fix compilation with Java 1.5" 2011-07-01 07:20:48 -04:00
Kevin Sawicki a5b5d5a9b2 Implement Serializable interface in PersonIdent class.
Change-Id: I3229f4ec85e7604cb45642813757975b30f1227e
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-06-30 09:38:43 -07:00
Jens Baumgart eb46d7ffdc DirCacheCheckout: unlock DirCache in case of failure
DirCacheCheckout did not unlock the index if e.g. an IOException occured
during checkout.

Bug: 350677
Change-Id: Ie9fa09f7a404080da7cdccafb9be3a8c845e4869
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2011-06-29 14:18:00 +02:00
Carsten Pfeiffer 46110935b5 Fix compilation with Java 1.5
Change-Id: I785f59fcf2018cd923d4d1617b923049dbde9809
2011-06-29 09:45:31 +02:00
Shawn Pearce 553920088d Merge "RFC: Ugly fix for i18n of metaVar CLI arguments" 2011-06-24 18:47:32 -04:00