import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.internal.revwalk.AddUnseenToBitmapFilter;
import org.eclipse.jgit.internal.storage.file.BitmapIndexImpl;
-import org.eclipse.jgit.internal.storage.file.BitmapIndexImpl.CompressedBitmap;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndex;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder;
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexRemapper;
+import org.eclipse.jgit.internal.storage.file.BitmapIndexImpl.CompressedBitmap;
import org.eclipse.jgit.lib.AnyObjectId;
-import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.ProgressMonitor;
+import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder;
import org.eclipse.jgit.revwalk.BitmapWalker;
import org.eclipse.jgit.revwalk.ObjectWalk;
import org.eclipse.jgit.revwalk.RevCommit;
private final int recentCommitSpan;
private final int distantCommitSpan;
private final int excessiveBranchCount;
+ private final int excessiveBranchTipCount;
private final long inactiveBranchTimestamp;
PackWriterBitmapPreparer(ObjectReader reader,
this.recentCommitSpan = config.getBitmapRecentCommitSpan();
this.distantCommitSpan = config.getBitmapDistantCommitSpan();
this.excessiveBranchCount = config.getBitmapExcessiveBranchCount();
+ this.excessiveBranchTipCount = Math.max(excessiveBranchCount,
+ config.getBitmapExcessiveBranchTipCount());
long now = SystemReader.getInstance().getCurrentTime();
long ageInSeconds = (long) config.getBitmapInactiveBranchAgeInDays()
* DAY_IN_SECONDS;
rw2.setRetainBody(false);
rw2.setRevFilter(new NotInBitmapFilter(seen));
+ int maxBranches = Math.min(excessiveBranchTipCount,
+ selectionHelper.newWantsByNewest.size());
// For each branch, do a revwalk to enumerate its commits. Exclude
// both reused commits and any commits seen in a previous branch.
// Then iterate through all new commits from oldest to newest,
// selecting well-spaced commits in this branch.
- for (RevCommit rc : selectionHelper.newWantsByNewest) {
+ for (RevCommit rc : selectionHelper.newWantsByNewest.subList(0,
+ maxBranches)) {
BitmapBuilder tipBitmap = commitBitmapIndex.newBitmapBuilder();
rw2.markStart((RevCommit) rw2.peel(rw2.parseAny(rc)));
RevCommit rc2;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_CONTIGUOUS_COMMIT_COUNT;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_DISTANT_COMMIT_SPAN;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_EXCESSIVE_BRANCH_COUNT;
+import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_EXCLUDED_REFS_PREFIXES;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_INACTIVE_BRANCH_AGE_INDAYS;
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_BITMAP_RECENT_COMMIT_COUNT;
*/
public static final int DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT = 100;
+ /**
+ * Default maxium count of branches to create tip bitmaps for. If the number
+ * of branches exceeds this, then tip bitmaps will only be created for the
+ * most recently active branches. Branches exceeding this count will receive
+ * 0 bitmaps: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT}
+ *
+ * @see #setBitmapExcessiveBranchTipCount(int)
+ * @since 6.9
+ */
+ public static final int DEFAULT_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT = Integer.MAX_VALUE;
+
/**
* Default age at which a branch is considered inactive. Age is taken as the
* number of days ago that the most recent commit was made to a branch. Only
private int bitmapExcessiveBranchCount = DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT;
+ private int bitmapExcessiveBranchTipCount = DEFAULT_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT;
+
private int bitmapInactiveBranchAgeInDays = DEFAULT_BITMAP_INACTIVE_BRANCH_AGE_IN_DAYS;
private String[] bitmapExcludedRefsPrefixes = DEFAULT_BITMAP_EXCLUDED_REFS_PREFIXES;
* a repository exceeds this number and bitmaps are enabled, "inactive"
* branches will have fewer bitmaps than "active" branches.
*
- * Default setting: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT}
+ * Default setting: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT}. See
+ * also {@link #getBitmapExcessiveBranchTipCount}.
*
* @return the count of branches deemed "excessive"
* @since 4.2
* a repository exceeds this number and bitmaps are enabled, "inactive"
* branches will have fewer bitmaps than "active" branches.
*
- * Default setting: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT}
+ * Default setting: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT}. See
+ * also {@link #setBitmapExcessiveBranchTipCount(int)}.
*
* @param count
* the count of branches deemed "excessive"
bitmapExcessiveBranchCount = count;
}
+ /**
+ * Get the count of branches deemed "excessive". If the count of branches in
+ * a repository exceeds this number and bitmaps are enabled, branches
+ * exceeding this count will have no bitmaps selected. Branches are indexed
+ * most recent first.
+ *
+ * <li>The first {@code DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT} most active
+ * branches have full bitmap coverage.
+ * <li>The {@code DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT} to {@code
+ * DEFAULT_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT} most active branches have
+ * only the tip commit covered.
+ * <li>The remaining branches have no bitmap coverage.
+ *
+ * If {@link #getBitmapExcessiveBranchCount()} is greater, then that value
+ * will override this value.
+ *
+ * Default setting: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT}
+ *
+ * @return the count of branch tips deemed "excessive"
+ * @since 6.9
+ */
+ public int getBitmapExcessiveBranchTipCount() {
+ return bitmapExcessiveBranchTipCount;
+ }
+
+ /**
+ * Get the count of branches deemed "excessive". If the count of branches in
+ * a repository exceeds this number and bitmaps are enabled, branches
+ * exceeding this count will have no bitmaps selected. Branches are indexed
+ * most recent first.
+ *
+ * <li>The first {@code DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT} most active
+ * branches have full bitmap coverage.
+ * <li>The {@code DEFAULT_BITMAP_EXCESSIVE_BRANCH_COUNT} to {@code
+ * DEFAULT_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT} most active branches have
+ * only the tip commit covered.
+ * <li>The remaining branches have no bitmap coverage.
+ *
+ * If {@link #getBitmapExcessiveBranchCount()} is greater, then that value
+ * will override this value.
+ *
+ * Default setting: {@value #DEFAULT_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT}
+ *
+ * @param count
+ * the count of branch tips deemed "excessive"
+ * @since 6.9
+ */
+ public void setBitmapExcessiveBranchTipCount(int count) {
+ bitmapExcessiveBranchTipCount = count;
+ }
+
/**
* Get the age in days that marks a branch as "inactive".
*
setBitmapExcessiveBranchCount(rc.getInt(CONFIG_PACK_SECTION,
CONFIG_KEY_BITMAP_EXCESSIVE_BRANCH_COUNT,
getBitmapExcessiveBranchCount()));
+ setBitmapExcessiveBranchTipCount(rc.getInt(CONFIG_PACK_SECTION,
+ CONFIG_KEY_BITMAP_EXCESSIVE_BRANCH_TIP_COUNT,
+ getBitmapExcessiveBranchTipCount()));
setBitmapInactiveBranchAgeInDays(rc.getInt(CONFIG_PACK_SECTION,
CONFIG_KEY_BITMAP_INACTIVE_BRANCH_AGE_INDAYS,
getBitmapInactiveBranchAgeInDays()));