/** * Create a writer to load objects from the specified reader. * <p> * Objects for packing are specified in {@link #preparePack(Iterator)} or * {@link #preparePack(ProgressMonitor, Set, Set)}. * * @param reader * reader to read from the repository with. */ public PackWriter(ObjectReader reader) { this(new PackConfig(), reader); }
/** * Create a configuration honoring settings in a * {@link org.eclipse.jgit.lib.Config}. * * @param cfg * the source to read settings from. The source is not retained * by the new configuration, instead its settings are copied * during the constructor. */ public PackConfig(Config cfg) { fromConfig(cfg); }
setMaxDeltaDepth(rc.getInt("pack", "depth", getMaxDeltaDepth())); //$NON-NLS-1$ //$NON-NLS-2$ setDeltaSearchWindowSize(rc.getInt( "pack", "window", getDeltaSearchWindowSize())); //$NON-NLS-1$ //$NON-NLS-2$ setDeltaSearchMemoryLimit(rc.getLong( "pack", "windowmemory", getDeltaSearchMemoryLimit())); //$NON-NLS-1$ //$NON-NLS-2$ setDeltaCacheSize(rc.getLong( "pack", "deltacachesize", getDeltaCacheSize())); //$NON-NLS-1$ //$NON-NLS-2$ setDeltaCacheLimit(rc.getInt( "pack", "deltacachelimit", getDeltaCacheLimit())); //$NON-NLS-1$ //$NON-NLS-2$ setCompressionLevel(rc.getInt("pack", "compression", //$NON-NLS-1$ //$NON-NLS-2$ rc.getInt("core", "compression", getCompressionLevel()))); //$NON-NLS-1$ //$NON-NLS-2$ setIndexVersion(rc.getInt("pack", "indexversion", getIndexVersion())); //$NON-NLS-1$ //$NON-NLS-2$ setBigFileThreshold(rc.getInt( "core", "bigfilethreshold", getBigFileThreshold())); //$NON-NLS-1$ //$NON-NLS-2$ setThreads(rc.getInt("pack", "threads", getThreads())); //$NON-NLS-1$ //$NON-NLS-2$ setReuseDeltas(rc.getBoolean("pack", "reusedeltas", isReuseDeltas())); //$NON-NLS-1$ //$NON-NLS-2$ setReuseObjects( rc.getBoolean("pack", "reuseobjects", isReuseObjects())); //$NON-NLS-1$ //$NON-NLS-2$ setDeltaCompress( rc.getBoolean("pack", "deltacompression", isDeltaCompress())); //$NON-NLS-1$ //$NON-NLS-2$ setCutDeltaChains( rc.getBoolean("pack", "cutdeltachains", getCutDeltaChains())); //$NON-NLS-1$ //$NON-NLS-2$ setSinglePack( rc.getBoolean("pack", "singlepack", getSinglePack())); //$NON-NLS-1$ //$NON-NLS-2$ setBuildBitmaps( rc.getBoolean("pack", "buildbitmaps", isBuildBitmaps())); //$NON-NLS-1$ //$NON-NLS-2$ setBitmapContiguousCommitCount( rc.getInt("pack", "bitmapcontiguouscommitcount", //$NON-NLS-1$ //$NON-NLS-2$
/** * Whether to prune preserved pack files in the preserved directory. * * @since 4.7 * @param prunePreserved * whether to prune preserved pack files * @return this instance */ public GarbageCollectCommand setPrunePreserved(boolean prunePreserved) { if (pconfig == null) pconfig = new PackConfig(repo); pconfig.setPrunePreserved(prunePreserved); return this; }
/** * Whether to preserve old pack files instead of deleting them. * * @since 4.7 * @param preserveOldPacks * whether to preserve old pack files * @return this instance */ public GarbageCollectCommand setPreserveOldPacks(boolean preserveOldPacks) { if (pconfig == null) pconfig = new PackConfig(repo); pconfig.setPreserveOldPacks(preserveOldPacks); return this; }
MutableState() { phase = PackingPhase.COUNTING; if (config.isDeltaCompress()) { int threads = config.getThreads(); if (threads <= 0) threads = Runtime.getRuntime().availableProcessors(); totalDeltaSearchBytes = (threads * config.getDeltaSearchMemoryLimit()) + config.getBigFileThreshold(); } else totalDeltaSearchBytes = 0; }
public String toString() { final StringBuilder b = new StringBuilder(); b.append("maxDeltaDepth=").append(getMaxDeltaDepth()); //$NON-NLS-1$ b.append(", deltaSearchWindowSize=").append(getDeltaSearchWindowSize()); //$NON-NLS-1$ b.append(", deltaSearchMemoryLimit=") //$NON-NLS-1$ .append(getDeltaSearchMemoryLimit()); b.append(", deltaCacheSize=").append(getDeltaCacheSize()); //$NON-NLS-1$ b.append(", deltaCacheLimit=").append(getDeltaCacheLimit()); //$NON-NLS-1$ b.append(", compressionLevel=").append(getCompressionLevel()); //$NON-NLS-1$ b.append(", indexVersion=").append(getIndexVersion()); //$NON-NLS-1$ b.append(", bigFileThreshold=").append(getBigFileThreshold()); //$NON-NLS-1$ b.append(", threads=").append(getThreads()); //$NON-NLS-1$ b.append(", reuseDeltas=").append(isReuseDeltas()); //$NON-NLS-1$ b.append(", reuseObjects=").append(isReuseObjects()); //$NON-NLS-1$ b.append(", deltaCompress=").append(isDeltaCompress()); //$NON-NLS-1$ b.append(", buildBitmaps=").append(isBuildBitmaps()); //$NON-NLS-1$ b.append(", bitmapContiguousCommitCount=") //$NON-NLS-1$ .append(getBitmapContiguousCommitCount()); b.append(", bitmapRecentCommitCount=") //$NON-NLS-1$ .append(getBitmapRecentCommitCount()); b.append(", bitmapRecentCommitSpan=") //$NON-NLS-1$ .append(getBitmapRecentCommitSpan()); b.append(", bitmapDistantCommitSpan=") //$NON-NLS-1$ .append(getBitmapDistantCommitSpan()); b.append(", bitmapExcessiveBranchCount=") //$NON-NLS-1$ .append(getBitmapExcessiveBranchCount()); b.append(", bitmapInactiveBranchAge=") //$NON-NLS-1$ .append(getBitmapInactiveBranchAgeInDays()); b.append(", singlePack=").append(getSinglePack()); //$NON-NLS-1$
private void compactPacks(DfsReader ctx, ProgressMonitor pm) throws IOException, IncorrectObjectTypeException { DfsObjDatabase objdb = repo.getObjectDatabase(); PackConfig pc = new PackConfig(repo); pc.setIndexVersion(2); pc.setDeltaCompress(false); pc.setReuseDeltas(true); pc.setReuseObjects(true);
private void packGarbage(ProgressMonitor pm) throws IOException { PackConfig cfg = new PackConfig(packConfig); cfg.setReuseDeltas(true); cfg.setReuseObjects(true); cfg.setDeltaCompress(false); cfg.setBuildBitmaps(false);
PackWriterBitmapPreparer(ObjectReader reader, PackBitmapIndexBuilder writeBitmaps, ProgressMonitor pm, Set<? extends ObjectId> want, PackConfig config) throws IOException { this.reader = reader; this.writeBitmaps = writeBitmaps; this.pm = pm; this.want = want; this.commitBitmapIndex = new BitmapIndexImpl(writeBitmaps); this.bitmapRemapper = PackBitmapIndexRemapper.newPackBitmapIndex( reader.getBitmapIndex(), writeBitmaps); this.bitmapIndex = new BitmapIndexImpl(bitmapRemapper); this.contiguousCommitCount = config.getBitmapContiguousCommitCount(); this.recentCommitCount = config.getBitmapRecentCommitCount(); this.recentCommitSpan = config.getBitmapRecentCommitSpan(); this.distantCommitSpan = config.getBitmapDistantCommitSpan(); this.excessiveBranchCount = config.getBitmapExcessiveBranchCount(); long now = SystemReader.getInstance().getCurrentTime(); long ageInSeconds = config.getBitmapInactiveBranchAgeInDays() * DAY_IN_SECONDS; this.inactiveBranchTimestamp = (now / 1000) - ageInSeconds; }
@Inject TransferConfig(@GerritServerConfig final Config cfg) { timeout = (int) ConfigUtil.getTimeUnit(cfg, "transfer", null, "timeout", // 0, TimeUnit.SECONDS); packConfig = new PackConfig(); packConfig.setDeltaCompress(false); packConfig.setThreads(1); packConfig.fromConfig(cfg); }
/** * Whether to use aggressive mode or not. If set to true JGit behaves more * similar to native git's "git gc --aggressive". If set to * <code>true</code> compressed objects found in old packs are not reused * but every object is compressed again. Configuration variables * pack.window and pack.depth are set to 250 for this GC. * * @since 3.6 * @param aggressive * whether to turn on or off aggressive mode * @return this instance */ public GarbageCollectCommand setAggressive(boolean aggressive) { if (aggressive) { StoredConfig repoConfig = repo.getConfig(); pconfig.setDeltaSearchWindowSize(repoConfig.getInt( ConfigConstants.CONFIG_GC_SECTION, ConfigConstants.CONFIG_KEY_AGGRESSIVE_WINDOW, DEFAULT_GC_AGGRESSIVE_WINDOW)); pconfig.setMaxDeltaDepth(repoConfig.getInt( ConfigConstants.CONFIG_GC_SECTION, ConfigConstants.CONFIG_KEY_AGGRESSIVE_DEPTH, DEFAULT_GC_AGGRESSIVE_DEPTH)); pconfig.setReuseObjects(false); } else pconfig = new PackConfig(repo); return this; }
@Override protected void run() throws Exception { PackConfig packConfig = new PackConfig(); cfg.load(); new WindowCacheConfig().fromConfig(cfg).install(); packConfig.fromConfig(cfg); int threads = packConfig.getThreads(); if (threads <= 0) threads = Runtime.getRuntime().availableProcessors(); if (1 < threads) packConfig.setExecutor(Executors.newFixedThreadPool(threads));
/** * Initialize a garbage collector. * * @param repository * repository objects to be packed will be read from. */ public DfsGarbageCollector(DfsRepository repository) { repo = repository; refdb = repo.getRefDatabase(); objdb = repo.getObjectDatabase(); newPackDesc = new ArrayList<>(4); newPackStats = new ArrayList<>(4); newPackObj = new ArrayList<>(4); packConfig = new PackConfig(repo); packConfig.setIndexVersion(2); }
@Override protected void execute(final FileSystemUser user, final Repository repository, final InputStream in, final OutputStream out, final OutputStream err, final JGitFileSystem fileSystem) { final UploadPack up = new UploadPack(repository); final PackConfig config = new PackConfig(repository); config.setCompressionLevel(Deflater.BEST_COMPRESSION); up.setPackConfig(config); up.setRefFilter(new HiddenBranchRefFilter()); try { up.upload(in, out, err); } catch (final IOException ignored) { } } }
private void searchForDeltas(final ProgressMonitor monitor, final ObjectToPack[] list, final int cnt) throws MissingObjectException, IncorrectObjectTypeException, LargeObjectException, IOException { int threads = config.getThreads(); if (threads == 0) threads = Runtime.getRuntime().availableProcessors(); if (threads <= 1 || cnt <= config.getDeltaSearchWindowSize()) singleThreadDeltaSearch(monitor, list, cnt); else parallelDeltaSearch(monitor, list, cnt, threads); }
static byte[] buffer(PackConfig config, ObjectReader or, AnyObjectId objId) throws IOException { // PackWriter should have already pruned objects that // are above the big file threshold, so our chances of // the object being below it are very good. We really // shouldn't be here, unless the implementation is odd. return or.open(objId).getCachedBytes(config.getBigFileThreshold()); }
/** * Set the number of objects considered when searching for a delta base. * * Default setting: {@value #DEFAULT_DELTA_SEARCH_WINDOW_SIZE} * * @param objectCount * number of objects to search at once. Must be at least 2. */ public void setDeltaSearchWindowSize(int objectCount) { if (objectCount <= 2) setDeltaCompress(false); else deltaSearchWindowSize = objectCount; }
public String toString() { final StringBuilder b = new StringBuilder(); b.append("maxDeltaDepth=").append(getMaxDeltaDepth()); //$NON-NLS-1$ b.append(", deltaSearchWindowSize=").append(getDeltaSearchWindowSize()); //$NON-NLS-1$ b.append(", deltaSearchMemoryLimit=") //$NON-NLS-1$ .append(getDeltaSearchMemoryLimit()); b.append(", deltaCacheSize=").append(getDeltaCacheSize()); //$NON-NLS-1$ b.append(", deltaCacheLimit=").append(getDeltaCacheLimit()); //$NON-NLS-1$ b.append(", compressionLevel=").append(getCompressionLevel()); //$NON-NLS-1$ b.append(", indexVersion=").append(getIndexVersion()); //$NON-NLS-1$ b.append(", bigFileThreshold=").append(getBigFileThreshold()); //$NON-NLS-1$ b.append(", threads=").append(getThreads()); //$NON-NLS-1$ b.append(", reuseDeltas=").append(isReuseDeltas()); //$NON-NLS-1$ b.append(", reuseObjects=").append(isReuseObjects()); //$NON-NLS-1$ b.append(", deltaCompress=").append(isDeltaCompress()); //$NON-NLS-1$ b.append(", buildBitmaps=").append(isBuildBitmaps()); //$NON-NLS-1$ b.append(", bitmapContiguousCommitCount=") //$NON-NLS-1$ .append(getBitmapContiguousCommitCount()); b.append(", bitmapRecentCommitCount=") //$NON-NLS-1$ .append(getBitmapRecentCommitCount()); b.append(", bitmapRecentCommitSpan=") //$NON-NLS-1$ .append(getBitmapRecentCommitSpan()); b.append(", bitmapDistantCommitSpan=") //$NON-NLS-1$ .append(getBitmapDistantCommitSpan()); b.append(", bitmapExcessiveBranchCount=") //$NON-NLS-1$ .append(getBitmapExcessiveBranchCount()); b.append(", bitmapInactiveBranchAge=") //$NON-NLS-1$ .append(getBitmapInactiveBranchAgeInDays()); return b.toString();
private void compactPacks(DfsReader ctx, ProgressMonitor pm) throws IOException, IncorrectObjectTypeException { DfsObjDatabase objdb = repo.getObjectDatabase(); PackConfig pc = new PackConfig(repo); pc.setIndexVersion(2); pc.setDeltaCompress(false); pc.setReuseDeltas(true); pc.setReuseObjects(true);