Browse Source
An ObjectReader implementation may be very slow for a single object, but yet support bulk queries efficiently by batching multiple small requests into a single larger request. This easily happens when the reader is built on top of a database that is stored on another host, as the network round-trip time starts to dominate the operation cost. RevWalk, ObjectWalk, UploadPack and PackWriter are the first major users of this new bulk interface, with the goal being to support an efficient way to pack a repository for a fetch/clone client when the source repository is stored in a high-latency storage system. Processing the want/have lists is now done in bulk, to remove the high costs associated with common ancestor negotiation. PackWriter already performs object reuse selection in bulk, but it now can also do the object size lookup and object counting phases with higher efficiency. Actual object reuse, deltification, and final output are still doing sequential lookups, making them a bit more expensive to perform. Change-Id: I4c966f84917482598012074c370b9831451404ee Signed-off-by: Shawn O. Pearce <spearce@spearce.org>stable-0.9
Shawn O. Pearce
15 years ago
10 changed files with 864 additions and 176 deletions
@ -0,0 +1,112 @@
|
||||
/* |
||||
* Copyright (C) 2010, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.lib; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
import org.eclipse.jgit.errors.MissingObjectException; |
||||
|
||||
/** |
||||
* Queue to open objects asynchronously. |
||||
* |
||||
* A queue may perform background decompression of objects and supply them |
||||
* (possibly out-of-order) to the application. |
||||
* |
||||
* @param <T> |
||||
* type of identifier supplied to the call that made the queue. |
||||
*/ |
||||
public interface AsyncObjectLoaderQueue<T extends ObjectId> extends |
||||
AsyncOperation { |
||||
|
||||
/** |
||||
* Position this queue onto the next available result. |
||||
* |
||||
* Even if this method returns true, {@link #open()} may still throw |
||||
* {@link MissingObjectException} if the underlying object database was |
||||
* concurrently modified and the current object is no longer available. |
||||
* |
||||
* @return true if there is a result available; false if the queue has |
||||
* finished its input iteration. |
||||
* @throws MissingObjectException |
||||
* the object does not exist. If the implementation is retaining |
||||
* the application's objects {@link #getCurrent()} will be the |
||||
* current object that is missing. There may be more results |
||||
* still available, so the caller should continue invoking next |
||||
* to examine another result. |
||||
* @throws IOException |
||||
* the object store cannot be accessed. |
||||
*/ |
||||
public boolean next() throws MissingObjectException, IOException; |
||||
|
||||
/** |
||||
* @return the current object, null if the implementation lost track. |
||||
* Implementations may for performance reasons discard the caller's |
||||
* ObjectId and provider their own through {@link #getObjectId()}. |
||||
*/ |
||||
public T getCurrent(); |
||||
|
||||
/** @return the ObjectId of the current object. Never null. */ |
||||
public ObjectId getObjectId(); |
||||
|
||||
/** |
||||
* Obtain a loader to read the object. |
||||
* |
||||
* This method can only be invoked once per result |
||||
* |
||||
* Due to race conditions with a concurrent modification of the underlying |
||||
* object database, an object may be unavailable when this method is |
||||
* invoked, even though next returned successfully. |
||||
* |
||||
* @return the ObjectLoader to read this object. Never null. |
||||
* @throws MissingObjectException |
||||
* the object does not exist. If the implementation is retaining |
||||
* the application's objects {@link #getCurrent()} will be the |
||||
* current object that is missing. There may be more results |
||||
* still available, so the caller should continue invoking next |
||||
* to examine another result. |
||||
* @throws IOException |
||||
* the object store cannot be accessed. |
||||
*/ |
||||
public ObjectLoader open() throws IOException; |
||||
} |
@ -0,0 +1,90 @@
|
||||
/* |
||||
* Copyright (C) 2010, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.lib; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
import org.eclipse.jgit.errors.MissingObjectException; |
||||
|
||||
/** |
||||
* Queue to examine object sizes asynchronously. |
||||
* |
||||
* A queue may perform background lookup of object sizes and supply them |
||||
* (possibly out-of-order) to the application. |
||||
* |
||||
* @param <T> |
||||
* type of identifier supplied to the call that made the queue. |
||||
*/ |
||||
public interface AsyncObjectSizeQueue<T extends ObjectId> extends |
||||
AsyncOperation { |
||||
|
||||
/** |
||||
* Position this queue onto the next available result. |
||||
* |
||||
* @return true if there is a result available; false if the queue has |
||||
* finished its input iteration. |
||||
* @throws MissingObjectException |
||||
* the object does not exist. If the implementation is retaining |
||||
* the application's objects {@link #getCurrent()} will be the |
||||
* current object that is missing. There may be more results |
||||
* still available, so the caller should continue invoking next |
||||
* to examine another result. |
||||
* @throws IOException |
||||
* the object store cannot be accessed. |
||||
*/ |
||||
public boolean next() throws MissingObjectException, IOException; |
||||
|
||||
/** |
||||
* @return the current object, null if the implementation lost track. |
||||
* Implementations may for performance reasons discard the caller's |
||||
* ObjectId and provider their own through {@link #getObjectId()}. |
||||
*/ |
||||
public T getCurrent(); |
||||
|
||||
/** @return the ObjectId of the current object. Never null. */ |
||||
public ObjectId getObjectId(); |
||||
|
||||
/** @return the size of the current object. */ |
||||
public long getSize(); |
||||
} |
@ -0,0 +1,75 @@
|
||||
/* |
||||
* Copyright (C) 2010, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.lib; |
||||
|
||||
/** |
||||
* Asynchronous operation handle. |
||||
* |
||||
* Callers that start an asynchronous operation are supplied with a handle that |
||||
* may be used to attempt cancellation of the operation if the caller does not |
||||
* wish to continue. |
||||
*/ |
||||
public interface AsyncOperation { |
||||
/** |
||||
* Cancels the running task. |
||||
* |
||||
* Attempts to cancel execution of this task. This attempt will fail if the |
||||
* task has already completed, already been cancelled, or could not be |
||||
* cancelled for some other reason. If successful, and this task has not |
||||
* started when cancel is called, this task should never run. If the task |
||||
* has already started, then the mayInterruptIfRunning parameter determines |
||||
* whether the thread executing this task should be interrupted in an |
||||
* attempt to stop the task. |
||||
* |
||||
* @param mayInterruptIfRunning |
||||
* true if the thread executing this task should be interrupted; |
||||
* otherwise, in-progress tasks are allowed to complete |
||||
* @return false if the task could not be cancelled, typically because it |
||||
* has already completed normally; true otherwise |
||||
*/ |
||||
public boolean cancel(boolean mayInterruptIfRunning); |
||||
|
||||
/** Release resources used by the operation, including cancellation. */ |
||||
public void release(); |
||||
} |
@ -0,0 +1,70 @@
|
||||
/* |
||||
* Copyright (C) 2010, Google Inc. |
||||
* and other copyright owners as documented in the project's IP log. |
||||
* |
||||
* This program and the accompanying materials are made available |
||||
* under the terms of the Eclipse Distribution License v1.0 which |
||||
* accompanies this distribution, is reproduced below, and is |
||||
* available at http://www.eclipse.org/org/documents/edl-v10.php
|
||||
* |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or |
||||
* without modification, are permitted provided that the following |
||||
* conditions are met: |
||||
* |
||||
* - Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* |
||||
* - Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following |
||||
* disclaimer in the documentation and/or other materials provided |
||||
* with the distribution. |
||||
* |
||||
* - Neither the name of the Eclipse Foundation, Inc. nor the |
||||
* names of its contributors may be used to endorse or promote |
||||
* products derived from this software without specific prior |
||||
* written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND |
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
package org.eclipse.jgit.revwalk; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
import org.eclipse.jgit.errors.MissingObjectException; |
||||
import org.eclipse.jgit.lib.AsyncOperation; |
||||
|
||||
/** |
||||
* Queue to lookup and parse objects asynchronously. |
||||
* |
||||
* A queue may perform background lookup of objects and supply them (possibly |
||||
* out-of-order) to the application. |
||||
*/ |
||||
public interface AsyncRevObjectQueue extends AsyncOperation { |
||||
/** |
||||
* Obtain the next object. |
||||
* |
||||
* @return the object; null if there are no more objects remaining. |
||||
* @throws MissingObjectException |
||||
* the object does not exist. There may be more objects |
||||
* remaining in the iteration, the application should call |
||||
* {@link #next()} again. |
||||
* @throws IOException |
||||
* the object store cannot be accessed. |
||||
*/ |
||||
public RevObject next() throws MissingObjectException, IOException; |
||||
} |
Loading…
Reference in new issue