Skip to main content
aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2011-03-14CommitCommand: set correct Reflog message when amendingJens Baumgart1-2/+3
Change-Id: I2322d31b09ca63bdcee50e90340e326467dc5021 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-03-14Fix dumb transport pushShawn O. Pearce1-7/+12
PackWriter incorrectly returned 0 from getObjectsNumber() when the pack has not been written yet. This caused dumb transports like amazon-s3:// and sftp:// to abort early and never write out a pack, under the assumption that the pack had no objects. Until the pack header is written to the output stream, compute the current object count each time it is requested. Once the header is started, use the object count from the stats object. Change-Id: I041a2368ae0cfe6f649ec28658d41a6355933900 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-14Avoid NullPointerException in PlotCommitMathias Kinzler2-5/+4
Bug: 339289 Change-Id: Idf36f080ae6638c2bdbe11d69a4ad870851622b1 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-03-13ObjectIdOwnerMap: More lightweight map for ObjectIdsShawn O. Pearce9-25/+388
OwnerMap is about 200 ms faster than SubclassMap, more friendly to the GC, and uses less storage: testing the "Counting objects" part of PackWriter on 1886362 objects: ObjectIdSubclassMap: load factor 50% table: 4194304 (wasted 2307942) ms spent 36998 36009 34795 34703 34941 35070 34284 34511 34638 34256 ms avg 34800 (last 9 runs) ObjectIdOwnerMap: load factor 100% table: 2097152 (wasted 210790) directory: 1024 ms spent 36842 35112 34922 34703 34580 34782 34165 34662 34314 34140 ms avg 34597 (last 9 runs) The major difference with OwnerMap is entries must extend from ObjectIdOwnerMap.Entry, where the OwnerMap has injected its own private "next" field into each object. This allows the OwnerMap to use a singly linked list for chaining collisions within a bucket. By putting collisions in a linked list, we gain the entire table back for the SHA-1 bits to index their own "private" slot. Unfortunately this means that each object can appear in at most ONE OwnerMap, as there is only one "next" field within the object instance to thread into the map. For types that are very object map heavy like RevWalk (entity RevObject) and PackWriter (entity ObjectToPack) this is sufficient, these entity types are only put into one map by their container. By introducing a new map type, we don't break existing applications that might be trying to use ObjectIdSubclassMap to track RevCommits they obtained from a RevWalk. The OwnerMap uses less memory. Each object uses 1 reference more (so we're up 1,886,362 references), but the table is 1/2 the size (2^20 rather than 2^21). The table itself wastes only 210,790 slots, rather than 2,307,942. So OwnerMap is wasting 200k fewer references. OwnerMap is more friendly to the GC, because it hardly ever generates garbage. As the map reaches its 100% load factor target, it doubles in size by allocating additional segment arrays of 2048 entries. (So the first grow allocates 1 segment, second 2 segments, third 4 segments, etc.) These segments are hooked into the pre-allocated directory of 1024 spaces. This permits the map to grow to 2 million objects before the directory itself has to grow. By using segments of 2048 entries, we are asking the GC to acquire 8,204 bytes in a 32 bit JVM. This is easier to satisfy then 2,307,942 bytes (for the 512k table that is just an intermediate step in the SubclassMap). By reusing the previously allocated segments (they are re-hashed in-place) we don't release any memory during a table grow. When the directory grows, it does so by discarding the old one and using one that is 4x larger (so the directory goes to 4096 entries on its first grow). A directory of size 4096 can handle up to 8 millon objects. The second directory grow (16384) goes to 33 million objects. At that point we're starting to really push the limits of the JVM heap, but at least its many small arrays. Previously SubclassMap would need a table of 67108864 entries to handle that object count, which needs a single contiguous allocation of 256 MiB. That's hard to come by in a 32 bit JVM. Instead OwnerMap uses 8192 arrays of about 8 KiB each. This is much easier to fit into a fragmented heap. Change-Id: Ia4acf5cfbf7e9b71bc7faa0db9060f6a969c0c50 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-13Merge "ObjectIdSubclassMap: Micro-optimize wrapping at end of table"Shawn O. Pearce1-14/+10
2011-03-13Register TransportProtocols using servicesShawn O. Pearce2-1/+100
Use the Java 6 like services approach to find all supported TransportProtocols within the CLASSPATH and load them all for use. This allows users to inject additional protocol implementations simply by putting their JARs on the application CLASSPATH, provided the protocol author has written the proper services file. Change-Id: I7a82d8846e4c4ed012c769f03d4bb2461f1bd148 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-13Make the supported Transports extensible and discoverableShawn O. Pearce13-143/+700
The new TransportProtocol type describes what a particular Transport implementation wants in order to support a connection. 3rd parties can now plug into the Transport.open() logic by implementing their own TransportProtocol and Transport classes, and registering with Transport.register(). GUI applications can help the user configure a connection by looking at the supported fields of a particular TransportProtocol type, which makes the GUI more dynamic and may better support new Transports. Change-Id: Iafd8e3a6285261412aac6cba8e2c333f8b7b76a5 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-13Merge "Don't auto follow non-annotated tags in fetch"Shawn O. Pearce1-5/+15
2011-03-11Add -o option to commit commandPhilipp Thun3-3/+215
This change adds the --only/ -o option to the commit command. Change-Id: I44352d56877f8204d985cb7a35a2e0faffb7d341 Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-10ObjectIdSubclassMap: Micro-optimize wrapping at end of tableShawn O. Pearce1-14/+10
During a review of the class, Josh Bloch pointed out we can use "i = (i + 1) & mask" to wrap around at the end of the table, instead of a conditional with a branch. This is generally faster due to one less branch that will be mis-predicted by the CPU. Change-Id: Ic88c00455ebc6adde9708563a6ad4d0377442bba Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-10Merge changes I0d797533,I128522af,I6dd076eb,Ief6f81b9,I83d01e5cShawn O. Pearce1-22/+34
* changes: ObjectIdSubclassMap: Avoid field loads in inner loops ObjectIdSubclassMap: Manually inline index() ObjectIdSubclassMap: Change initial size to 2048 ObjectIdSubclassMap: Grow before insertions ObjectIdSubclassMap: Use & rather than % for hashing
2011-03-10Merge "Cache gitPrefix in FS_Win32"Shawn Pearce1-11/+19
2011-03-10Fix Bundle-Version of jgit source bundleMatthias Sohn1-1/+1
Bug: 339033 Change-Id: Idaf965cb684d5ed3f3634b0f3d256c92182d7c58 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-10Cache gitPrefix in FS_Win32Marc Strapetz1-11/+19
readPipe() may consume rather much time, so gitPrefix should be cached. If the git executable changes, users should run FS.detect() again to get a new instance of FS_Win32.
2011-03-10ObjectIdSubclassMap: Avoid field loads in inner loopsShawn O. Pearce1-8/+14
Ensure the JIT knows the table cannot be changed during the critical inner loop of get() or insert() by loading the field into a final local variable. This shouldn't be necessary, but the instance member is declared non-final (to resizing) and it is not very obvious to the JIT that the table cannot be modified by AnyObjectId.equals(). Simplify the JIT's decision making by making it obvious, these values cannot change during the critical inner loop, allowing for better register allocation. Change-Id: I0d797533fc5327366f1207b0937c406f02cdaab3 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-10ObjectIdSubclassMap: Manually inline index()Shawn O. Pearce1-7/+3
This method is trivial in definition, and is called in only 3 places. Inline the method manually to ensure its really going to be inlined by the JIT at runtime. Change-Id: I128522af8167c07d2de6cc210573599038871dda Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-09ObjectIdSubclassMap: Change initial size to 2048Shawn O. Pearce1-1/+1
32 is way to small for the map. Most applications using the map will need to load more than 16 objects just from the root refs being read from the Repository. Default the initial size to 2048. This cuts out 6 expansions in the early life of the table, reducing garbage and rehashing time. Change-Id: I6dd076ebc0b284f1755855d383b79535604ac547 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-09ObjectIdSubclassMap: Grow before insertionsShawn O. Pearce1-4/+5
If the table needs to be grown, do it before the current insertion rather than after. This is a tiny micro-optimization that allows the compiler to reuse the result of "++size" to compare against previously pre-computed size at which the table should rehash itself. Change-Id: Ief6f81b91c10ed433d67e0182f558ca70d58a2b0 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-09ObjectIdSubclassMap: Use & rather than % for hashingShawn O. Pearce1-4/+13
Bitwise and is faster than integer modulus operations, and since the table size is always a power of 2, this is simple to use for index operation. Change-Id: I83d01e5c74fd9e910c633a98ea6f90b59092ba29 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-09ObjectIdSubclassMap: Fix non-standard naming conventionsShawn O. Pearce1-21/+21
obj_hash doesn't match our naming conventions, camelCaseNames are the preferred format. Change-Id: I72da199daccb60a98d17b6af1e498189bf149515 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-09Fixed ordering of Config.getSubsections(...)Jesse Greenwald1-2/+2
A standard HashSet was being used to store the list of subsections as they were being parsed. This was changed to use a LinkedHashSet so that iterating over the set would return values in the same order as they are listed in the config file. Change-Id: I4251f95b8fe0ad59b07ff563c9ebb468f996c37d
2011-03-08[findbugs] ProgressReportingFilter can be a static inner classMatthias Sohn1-1/+1
Change-Id: I628b1f25f04c9297655d5ac451ae5a133db53896 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-08[findbugs] Avoid futile attempt to change max pool sizeMatthias Sohn1-1/+0
Javadoc for ScheduledThreadPoolExecutor says [1]: While ScheduledThreadPoolExecutor inherits from ThreadPoolExecutor, a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments to maximumPoolSize have no useful effect. [1] http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html Change-Id: I8eccb7d6544aa6e27f5fa064c19dddb2a706523f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-08PackWriter: Reduce GC during enumerationShawn O. Pearce3-20/+312
Instead of resizing an ArrayList until all objects have been added, append objects into a specialized List type that uses small arrays of 1024 entries for each 1024 objects added. For a large repository like linux-2.6, PackWriter will now allocate 1,758 smaller arrays to hold the object list, without creating any garbage from the intermediate states due to list expansion. 1024 was chosen as the block size (and initial directory size) as this is a reasonable balance for the PackWriter code. Each block uses approximately 4096 bytes in a 32 bit JVM, as does the default top level block directory. The top level directory doesn't expand until 1 million items have been added to the list, which for linux-2.6 won't yet occur as the lists are per-object-type and are thus bounded to about 1/3 of 1.8 million. Change-Id: If9e4092eb502394c5d3d044b58cf49952772f6d6 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-07Remove deprecated TreeVisitorShawn O. Pearce7-269/+0
This type and its associated methods has been deprecated for a while now. Time to remove it. Applications can use a TreeWalk instead to access the elements of any tree-like object. Change-Id: I047e552ac77b77e2de086f63cb4fb318da57c208 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-07Remove deprecated TreeIteratorShawn O. Pearce1-214/+0
This interface has been deprecated for a while now. Applications can use a TreeWalk instead. Change-Id: I751d6e919e4b501c36fc36e5f816b8a8c5379cb9 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-07Remove deprecated IndexTreeVisitorShawn O. Pearce3-444/+0
This has been deprecated for some time now. Applications should instead use DirCache within a TreeWalk. Change-Id: I8099d93f07139c33fe09bdeef8d739782397da17 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-07Remove deprecated WriteTreeShawn O. Pearce2-195/+0
This class has been deprecated for a long time now. Time to remove it. Applications can use the newer DirCache.writeTree() as a replacement. Change-Id: I91dc9507668d8a3ecadd6acd4f1c8b7bd7760cc3 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-07Remove deprecated WorkDirCheckoutShawn O. Pearce2-417/+1
This class has been deprecated for a long time now. Time to remove it. Applications can use the newer DirCacheCheckout class as a replacement. Change-Id: Id66d29fcca5a7286b8f8838303d83f40898918d2 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-07Remove deprecated Treeish interfaceShawn O. Pearce3-78/+2
This interface has been deprecated for a long time now. Time to remove it. Change-Id: I29a938657e4637b2a9d0561940b38d70866613f7 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-07Allow to amend a commit with CommitCommandTomasz Zarna1-2/+26
Bug: 339088 Change-Id: I57dc727688c4bb6968ac076b176661c857c05afa Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-03-05PackFile: Fix copy as-is for small objectsShawn O. Pearce1-0/+10
When I disabled validation I broke the code that handled copying small objects whose contents were below 8192 bytes in size but spanned over the end of one window and into the next window. These objects did not ever populate the temporary write buffer, resulting in garbage writing into the output stream instead of valid object contents. Change-Id: Ie26a2aaa885d0eee4888a9b12c222040ee4a8562 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-04Merge "Fix DirCache re-read."Shawn Pearce2-12/+17
2011-03-04Don't auto follow non-annotated tags in fetchShawn O. Pearce1-5/+15
When fetch TagOpt is AUTO_FOLLOW do not follow refs/tags/ names that point directly to commits which are on unreleated side branches. Change-Id: Iea6eee5a05ae7402a7f256fd9c1e3d3b5ccb58dd Reported-by: Slawomir Ginter <sginter@atlassian.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-04Fix DirCache re-read.Robin Rosenberg2-12/+17
During unit tests and most likely elsewhere, updates come too fast for a simple timestamp comparison (with one seconds resolution) to work. I.e. DirCache thinks it hasn't changed. Use FileSnapshot instead which has more advanced logic. Change-Id: Ib850f84398ef7d4b8a8a6f5a0ae6963e37f2b470 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-03-04resolve(): Fix wrong parsing of branch "foo-gbed2-dev"Shawn O. Pearce1-18/+19
When parsing a string such as "foo-gbed2" resolve() was assuming the suffix was from git describe output. This lead to JGit trying to find the completion for the object abbreviation "bed2", rather than using the current value of the reference. If there was only one such object in the repository, JGit might actually use the wrong value here, as resolve() would return the completion of the abbreviation "bed2" rather than the current value of the reference "refs/heads/foo-gbed2". Move the parsing of git describe abbreviations out of the operator portion of the resolve() method and into the simple portion that is supposed to handle only object ids or reference names, and only do the describe parsing after all other approaches have already failed to provide a resolution. Add new unit tests to verify the behavior is as expected by users. Bug: 338839 Change-Id: I52054d7b89628700c730f9a4bd7743b16b9042a9 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-03RemoteRefUpdate: Accept Ref and ObjectId arguments for sourceShawn O. Pearce1-4/+108
Applications may already have a Ref or ObjectId on hand that they want the remote to be updated to. Instead of converting these into a String and relying on the parsing rules of resolve(), allow the application to supply the Ref or ObjectId directly. Bug: 338839 Change-Id: If5865ac9eb069de1c8f224090b6020fc422f9f12 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-02PackWriter: Validate reused cached packsShawn O. Pearce8-22/+77
If object reuse validation is enabled, the output pack is going to probably be stored locally. When reusing an existing cached pack to save object enumeration costs, ensure the cached pack has not been corrupted by checking its SHA-1 trailer. If it has, writing will abort and the output pack won't be complete. This prevents anyone from trying to use the output pack, and catches corruption before it can be carried any further. Change-Id: If89d0d4e429d9f4c86f14de6c0020902705153e6 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-02PackWriter: Avoid CRC-32 validation when feeding IndexPackShawn O. Pearce7-25/+75
There is no need to validate the object contents during copyObjectAsIs if the result is going to be parsed by unpack-objects or index-pack. Both programs will compute the SHA-1 of the object, and also validate most of the pack structure. For git daemon like servers, this work is already done on the client end of the connection, so the server doesn't need to repeat that work itself. Disable object validation for the 3 transport cases where we know the remote side will handle object validation for us (push, bundle creation, and upload pack). This improves performance on the server side by reducing the work that must be done. Change-Id: Iabb78eec45898e4a17f7aab3fb94c004d8d69af6 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01PackWriter: Position tags after commitsShawn O. Pearce1-2/+4
Annotated tags need to be parsed by many viewing tools, but putting them at the end of the pack hurts because kernel prefetching might not have loaded them, since they are so far from the commits they reference. Position tags right behind the commits, but before the trees. Typically the annotated tag set for a repository is very small, so the extra prefetch burden it puts on tools that don't need annotated tags (but do need commits and trees) is fairly low. Change-Id: Ibbabdd94e7d563901c0309c79a496ee049cdec50 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01PackWriter: Refactor object writing loopShawn O. Pearce1-6/+9
This simple refactoring makes it easier to pre-process each of the object lists before its handed into the actual write routine. Change-Id: Iea95e5ecbc7374f6bcbb43d1c75285f4f564d09d Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01PackWriter: Don't reuse commit or tag deltasShawn O. Pearce2-1/+40
JGit doesn't generate deltas for commit or tag objects when it packs a repository from scratch. This is an explicit design decision that is (mostly) justified by the fact that these objects do not delta compress well. Annotated tags are made once on stable points of the project history, it is unlikely they will ever appear again with sufficient common text to justify using a delta over just deflating the raw content. JGit never tries to delta compress annotated tags and I take the stance that these are best stored as non-deltas given how frequently they might be accessed by repository viewers. Commits only have sufficient common text when they are cherry-picked to forward-port or back-port a change from one branch to another. Even in these cases the distance between the commits as returned by the log traversal has to be small enough that they would both appear in the delta search window at the same time in order to delta compress one of the messages against the other. JGit never tries to delta compress commits, as it requires a lot of CPU time but typically does not produce a smaller pack file. Avoid reusing deltas for either of these types when constructing a new pack. To avoid killing performance during serving of network clients, UploadPack disables this code change by allowing PackWriter to reuse delta commits. Repositories that were already repacked by C Git will not have their delta commits decompressed and recompressed on the fly during object writing, saving server-side CPU resources. Change-Id: I749407e7c5c677e05e4d054b40db7656cfa7fca8 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01PackWriter: Do not delta compress already packed objectsShawn O. Pearce1-2/+2
This is a tiny optimization to how delta search works. Checking for isReuseAsIs() avoids doing delta compression search on non-delta objects already stored in packs within the repository. Such objects are not likely to be delta compressable, as they were already delta searched when their containing pack was generated and they were not delta compressed at that time. Doing delta compression now is unlikely to produce a different result, but would waste a lot of CPU. The isReuseAsIs() flag is checked before isDoNotDelta() because it is very common to reuse objects in the output pack. Most objects get reused, and only a handful have the isDoNotDelta() bit set. Moving the check earlier allows the loop to more quickly skip through objects that will never need to be considered. Change-Id: Ied757363f775058177fc1befb8ace20fe9759bac Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01Paper bag fix BatchingProgressMonitor alarm queueShawn O. Pearce1-2/+5
The alarm queue threads were started with an empty task body, which meant the thread started and terminated immediately, leaving the queue itself with no worker. Change-Id: I2a9b5fe9c2bdff4a5e0f7ec7ad41a54b41a4ddd6 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01ProgressMonitor: Refactor to use background alarmsShawn O. Pearce3-157/+407
Instead of polling the system clock on every update(1) method call, use a scheduled executor to toggle a volatile once per second until the task is done. Check the volatile on each update(int), looking to see if output should occur. This limits progress output to either once per 1% complete, or once per second. To save time during update calls the timer isn't reset during each 1% of output, which means we may see one unnecessary output trigger if at least 1% completed during the one second of the alarm time. Change-Id: I8fdd7e31c37bef39a5d1b3da7105da0ef879eb84 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-28Fix NPE on checkout of remote tracking branchMatthias Sohn1-7/+11
Checkout of remote tracking branch failed when no local branch existed. Also enhance RepositoryTestCase to enable checking index state of another test repository. Bug: 337695 Change-Id: Idf4c05bdf23b5161688818342b2bf9a45b49f479 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-26UnpackedObject: Fix readSome() when initial read is shortShawn O. Pearce1-0/+1
JDK7 changed behavior slightly on some InputStream types, resulting in the first read being shorter than the count requested. That caused us to overwrite the earlier part of the buffer with later data, as the offset index wasn't updated in the loop. Fix the loop to increment offset by the number of bytes read in this iteration, so the next read appends to the buffer rather than doing an overwrite. Bug: 338119 Change-Id: I222fb2f993cd9b637b6b8d93daab5777ef7ec7a6 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-24Merge "RevWalk: Don't release during inMergeBase()"Chris Aniszczyk1-1/+0
2011-02-24Merge "Fix formatting of pom.xml"Shawn Pearce1-34/+36
2011-02-24FetchCommand: do not set a null credentials providerMatthias Sohn1-1/+2
FetchCommand now does not set a null credentials provider on Transport because in this case the default provider is replaced with null and the default mechanism for providing credentials is not working. Change-Id: I44096aa856f031545df39d4b09af198caa2c21f6 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>

Back to the top