Simplify size test in PackWriter
Clip the configured limit to Integer.MAX_VALUE at the top of the loop, saving a compare branch per object considered. This can cut 2M branches out of a repacking of the Linux kernel. Rewrite the logic so the primary path is to match the conditional; most objects are larger than BLKSZ (16 bytes) and less than limit. This may help branch prediction on CPUs if the CPU tries to assume execution takes the side of the branch and not the second. Change-Id: I5133d1651640939afe9fbcfd8cfdb59965c57d5a
This commit is contained in:
parent
d45277a691
commit
93a27ce728
|
@ -1147,7 +1147,9 @@ private void searchForDeltas(ProgressMonitor monitor)
|
|||
AsyncObjectSizeQueue<ObjectToPack> sizeQueue = reader.getObjectSize(
|
||||
Arrays.<ObjectToPack> asList(list).subList(0, cnt), false);
|
||||
try {
|
||||
final long limit = config.getBigFileThreshold();
|
||||
final long limit = Math.min(
|
||||
config.getBigFileThreshold(),
|
||||
Integer.MAX_VALUE);
|
||||
for (;;) {
|
||||
try {
|
||||
if (!sizeQueue.next())
|
||||
|
@ -1175,14 +1177,10 @@ private void searchForDeltas(ProgressMonitor monitor)
|
|||
otp = objectsMap.get(sizeQueue.getObjectId());
|
||||
|
||||
long sz = sizeQueue.getSize();
|
||||
if (limit <= sz || Integer.MAX_VALUE <= sz)
|
||||
otp.setDoNotDelta(); // too big, avoid costly files
|
||||
|
||||
else if (sz <= DeltaIndex.BLKSZ)
|
||||
otp.setDoNotDelta(); // too small, won't work
|
||||
|
||||
else
|
||||
if (DeltaIndex.BLKSZ < sz && sz < limit)
|
||||
otp.setWeight((int) sz);
|
||||
else
|
||||
otp.setDoNotDelta(); // too small, or too big
|
||||
monitor.update(1);
|
||||
}
|
||||
} finally {
|
||||
|
|
Loading…
Reference in New Issue