]> source.dussan.org Git - jgit.git/commitdiff
[performance] Remove synthetic access$ methods in pack and file packages 73/59073/2
authorAndrey Loskutov <loskutov@gmx.de>
Tue, 27 Oct 2015 22:51:21 +0000 (23:51 +0100)
committerAndrey Loskutov <loskutov@gmx.de>
Tue, 27 Oct 2015 23:02:41 +0000 (00:02 +0100)
Java compiler must generate synthetic access methods for private methods
and fields of the enclosing class if they are accessed from inner
classes and vice versa.

While invisible in the code, those synthetic access methods exist in the
bytecode and seem to produce some extra execution overhead at runtime
(compared with the direct access to this fields or methods), see
https://git.eclipse.org/r/58948/.

By removing the "private" access modifier from affected methods and
fields we help compiler to avoid generation of synthetic access methods
and hope to improve execution performance.

To validate changes, one can either use javap or use Bytecode Outline
plugin in Eclipse. In both cases one should look for "synthetic
access$<number>" methods at the end of the class and inner class files
in question - there should be none.

NB: don't mix this "synthetic access$" methods up with "public synthetic
bridge" methods generated to allow generic method override return types.

Change-Id: If53ec94145bae47b74e2561305afe6098012715c
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
13 files changed:
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/DeltaBaseCache.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexRemapper.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV1.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackIndexV2.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/UnpackedObject.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaTask.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapPreparer.java

index 0c3c7361a9e7581030ae57f5ec79d8d85473c609..5786019e9fb54037a9e2de6818bd852ad12ac7c3 100644 (file)
@@ -63,11 +63,11 @@ import org.eclipse.jgit.util.BlockList;
 public class BitmapIndexImpl implements BitmapIndex {
        private static final int EXTRA_BITS = 10 * 1024;
 
-       private final PackBitmapIndex packIndex;
+       final PackBitmapIndex packIndex;
 
-       private final MutableBitmapIndex mutableIndex;
+       final MutableBitmapIndex mutableIndex;
 
-       private final int indexObjectCount;
+       final int indexObjectCount;
 
        /**
         * Creates a BitmapIndex that is back by Compressed bitmaps.
@@ -96,7 +96,7 @@ public class BitmapIndexImpl implements BitmapIndex {
                return new CompressedBitmapBuilder();
        }
 
-       private int findPosition(AnyObjectId objectId) {
+       int findPosition(AnyObjectId objectId) {
                int position = packIndex.findPosition(objectId);
                if (position < 0) {
                        position = mutableIndex.findPosition(objectId);
@@ -106,7 +106,7 @@ public class BitmapIndexImpl implements BitmapIndex {
                return position;
        }
 
-       private int addObject(AnyObjectId objectId, int type) {
+       int addObject(AnyObjectId objectId, int type) {
                int position = findPosition(objectId);
                if (position < 0) {
                        position = mutableIndex.addObject(objectId, type);
@@ -122,11 +122,11 @@ public class BitmapIndexImpl implements BitmapIndex {
 
                private BitSet toRemove;
 
-               private ComboBitset() {
+               ComboBitset() {
                        this(new EWAHCompressedBitmap());
                }
 
-               private ComboBitset(EWAHCompressedBitmap bitmap) {
+               ComboBitset(EWAHCompressedBitmap bitmap) {
                        this.inflatingBitmap = new InflatingBitSet(bitmap);
                }
 
@@ -289,15 +289,15 @@ public class BitmapIndexImpl implements BitmapIndex {
                        return true;
                }
 
-               private BitmapIndexImpl getBitmapIndex() {
+               BitmapIndexImpl getBitmapIndex() {
                        return BitmapIndexImpl.this;
                }
        }
 
        final class CompressedBitmap implements Bitmap {
-               private final EWAHCompressedBitmap bitmap;
+               final EWAHCompressedBitmap bitmap;
 
-               private CompressedBitmap(EWAHCompressedBitmap bitmap) {
+               CompressedBitmap(EWAHCompressedBitmap bitmap) {
                        this.bitmap = bitmap;
                }
 
@@ -387,7 +387,7 @@ public class BitmapIndexImpl implements BitmapIndex {
                        return bitmap;
                }
 
-               private BitmapIndexImpl getPackBitmapIndex() {
+               BitmapIndexImpl getPackBitmapIndex() {
                        return BitmapIndexImpl.this;
                }
        }
@@ -429,9 +429,9 @@ public class BitmapIndexImpl implements BitmapIndex {
        }
 
        private static final class MutableEntry extends ObjectIdOwnerMap.Entry {
-               private final int type;
+               final int type;
 
-               private final int position;
+               final int position;
 
                MutableEntry(AnyObjectId objectId, int type, int position) {
                        super(objectId);
@@ -456,7 +456,7 @@ public class BitmapIndexImpl implements BitmapIndex {
                }
        }
 
-       private boolean isSameCompressedBitmap(Bitmap other) {
+       boolean isSameCompressedBitmap(Bitmap other) {
                if (other instanceof CompressedBitmap) {
                        CompressedBitmap b = (CompressedBitmap) other;
                        return this == b.getPackBitmapIndex();
@@ -464,7 +464,7 @@ public class BitmapIndexImpl implements BitmapIndex {
                return false;
        }
 
-       private boolean isSameCompressedBitmapBuilder(Bitmap other) {
+       boolean isSameCompressedBitmapBuilder(Bitmap other) {
                if (other instanceof CompressedBitmapBuilder) {
                        CompressedBitmapBuilder b = (CompressedBitmapBuilder) other;
                        return this == b.getBitmapIndex();
@@ -472,7 +472,7 @@ public class BitmapIndexImpl implements BitmapIndex {
                return false;
        }
 
-       private static final EWAHCompressedBitmap ones(int sizeInBits) {
+       static final EWAHCompressedBitmap ones(int sizeInBits) {
                EWAHCompressedBitmap mask = new EWAHCompressedBitmap();
                mask.addStreamOfEmptyWords(
                                true, sizeInBits / EWAHCompressedBitmap.wordinbits);
index 2f30496e2fccefd8a1243ad17b8bad3aff23d18b..a95dea74b627ea5945502f417362c72581ee44d4 100644 (file)
@@ -50,7 +50,7 @@ import org.eclipse.jgit.storage.file.WindowCacheConfig;
 class DeltaBaseCache {
        private static final int CACHE_SZ = 1024;
 
-       private static final SoftReference<Entry> DEAD;
+       static final SoftReference<Entry> DEAD;
 
        private static int hash(final long position) {
                return (((int) position) << 22) >>> 22;
index 06eb42cbbce4699f4de8f825b238eb958ed1729c..50297a97a02f3d1bc70fc41ee02a9e22f27f835d 100644 (file)
@@ -120,11 +120,11 @@ public class LockFile {
 
        private boolean haveLck;
 
-       private FileOutputStream os;
+       FileOutputStream os;
 
        private boolean needSnapshot;
 
-       private boolean fsync;
+       boolean fsync;
 
        private FileSnapshot commitSnapshot;
 
index 3506953f14ce3e43b352950112d8b8007e9120ef..4ff09a148f43afadf44407d64e4b10ad809ccfda 100644 (file)
@@ -74,9 +74,9 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
        private final EWAHCompressedBitmap blobs;
        private final EWAHCompressedBitmap tags;
        private final BlockList<PositionEntry> byOffset;
-       private final BlockList<StoredBitmap>
+       final BlockList<StoredBitmap>
                        byAddOrder = new BlockList<StoredBitmap>();
-       private final ObjectIdOwnerMap<PositionEntry>
+       final ObjectIdOwnerMap<PositionEntry>
                        positionEntries = new ObjectIdOwnerMap<PositionEntry>();
 
        /**
@@ -330,7 +330,7 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
                private final int xorOffset;
                private final int flags;
 
-               private StoredEntry(long objectId, EWAHCompressedBitmap bitmap,
+               StoredEntry(long objectId, EWAHCompressedBitmap bitmap,
                                int xorOffset, int flags) {
                        this.objectId = objectId;
                        this.bitmap = bitmap;
@@ -360,11 +360,11 @@ public class PackBitmapIndexBuilder extends BasePackBitmapIndex {
        }
 
        private static final class PositionEntry extends ObjectIdOwnerMap.Entry {
-               private final int namePosition;
+               final int namePosition;
 
-               private int offsetPosition;
+               int offsetPosition;
 
-               private PositionEntry(AnyObjectId objectId, int namePosition) {
+               PositionEntry(AnyObjectId objectId, int namePosition) {
                        super(objectId);
                        this.namePosition = namePosition;
                }
index f2d9f6462e8a5dfe3bf37609a77074e5ae50abfa..7cd68b625e96516687e74ed3056729012904d49c 100644 (file)
@@ -66,7 +66,7 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
                implements Iterable<PackBitmapIndexRemapper.Entry> {
 
        private final BasePackBitmapIndex oldPackIndex;
-       private final PackBitmapIndex newPackIndex;
+       final PackBitmapIndex newPackIndex;
        private final ObjectIdOwnerMap<StoredBitmap> convertedBitmaps;
        private final BitSet inflated;
        private final int[] prevToNewMapping;
@@ -199,7 +199,7 @@ public class PackBitmapIndexRemapper extends PackBitmapIndex
        public final class Entry extends ObjectId {
                private final int flags;
 
-               private Entry(AnyObjectId src, int flags) {
+               Entry(AnyObjectId src, int flags) {
                        super(src);
                        this.flags = flags;
                }
index 589a8117353a349a49abf8c5cd6a503ebc304bef..b385b8ab735646a7e7bb19af5b67e53794ad51ed 100644 (file)
@@ -119,7 +119,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
 
        private int activeCopyRawData;
 
-       private int packLastModified;
+       int packLastModified;
 
        private volatile boolean invalid;
 
index ab3297ad2a9c862f1dc05f55cec4b3de22e14ef4..e5a729dbf3bc418295552928a1c00a4479c80176 100644 (file)
@@ -67,7 +67,7 @@ class PackIndexV1 extends PackIndex {
 
        private final long[] idxHeader;
 
-       private byte[][] idxdata;
+       byte[][] idxdata;
 
        private long objectCnt;
 
@@ -233,9 +233,9 @@ class PackIndexV1 extends PackIndex {
        }
 
        private class IndexV1Iterator extends EntriesIterator {
-               private int levelOne;
+               int levelOne;
 
-               private int levelTwo;
+               int levelTwo;
 
                @Override
                protected MutableEntry initEntry() {
index cb8c91a5a75141830dd693023ae7ca1a08fa3224..d87336f99c2faf69e294a5e7382d3d5a03e4c07d 100644 (file)
@@ -75,16 +75,16 @@ class PackIndexV2 extends PackIndex {
        private final long[] fanoutTable;
 
        /** 256 arrays of contiguous object names. */
-       private int[][] names;
+       int[][] names;
 
        /** 256 arrays of the 32 bit offset data, matching {@link #names}. */
-       private byte[][] offset32;
+       byte[][] offset32;
 
        /** 256 arrays of the CRC-32 of objects, matching {@link #names}. */
        private byte[][] crc32;
 
        /** 64 bit offset table. */
-       private byte[] offset64;
+       byte[] offset64;
 
        PackIndexV2(final InputStream fd) throws IOException {
                final byte[] fanoutRaw = new byte[4 * FANOUT];
@@ -304,9 +304,9 @@ class PackIndexV2 extends PackIndex {
        }
 
        private class EntriesIteratorV2 extends EntriesIterator {
-               private int levelOne;
+               int levelOne;
 
-               private int levelTwo;
+               int levelTwo;
 
                @Override
                protected MutableEntry initEntry() {
index 6a04a538ef2ea242f7cb4e4f722ab15a89a8a443..731bbd3839b1870162d2459518e6aa4c3bf69247 100644 (file)
@@ -138,7 +138,7 @@ public class RefDirectory extends RefDatabase {
 
        private final File gitDir;
 
-       private final File refsDir;
+       final File refsDir;
 
        private final ReflogWriter logWriter;
 
@@ -155,7 +155,7 @@ public class RefDirectory extends RefDatabase {
        private final AtomicReference<RefList<LooseRef>> looseRefs = new AtomicReference<RefList<LooseRef>>();
 
        /** Immutable sorted list of packed references. */
-       private final AtomicReference<PackedRefList> packedRefs = new AtomicReference<PackedRefList>();
+       final AtomicReference<PackedRefList> packedRefs = new AtomicReference<PackedRefList>();
 
        /**
         * Number of modifications made to this database.
@@ -901,7 +901,7 @@ public class RefDirectory extends RefDatabase {
                return n;
        }
 
-       private LooseRef scanRef(LooseRef ref, String name) throws IOException {
+       LooseRef scanRef(LooseRef ref, String name) throws IOException {
                final File path = fileFor(name);
                FileSnapshot currentSnapshot = null;
 
index e4cc6979626d73d95e05dab170e0a8e340fd5ed4..2cc2563962b85d4581bb75a16d71fa4b968bea64 100644 (file)
@@ -232,7 +232,7 @@ public class UnpackedObject {
                }
        }
 
-       private static void checkValidEndOfStream(InputStream in, Inflater inf,
+       static void checkValidEndOfStream(InputStream in, Inflater inf,
                        AnyObjectId id, final byte[] buf) throws IOException,
                        CorruptObjectException {
                for (;;) {
@@ -266,7 +266,7 @@ public class UnpackedObject {
                }
        }
 
-       private static boolean isStandardFormat(final byte[] hdr) {
+       static boolean isStandardFormat(final byte[] hdr) {
                /*
                 * We must determine if the buffer contains the standard
                 * zlib-deflated stream or the experimental format based
@@ -298,7 +298,7 @@ public class UnpackedObject {
                return (fb & 0x8f) == 0x08 && (((fb << 8) | hdr[1] & 0xff) % 31) == 0;
        }
 
-       private static InputStream inflate(final InputStream in, final long size,
+       static InputStream inflate(final InputStream in, final long size,
                        final ObjectId id) {
                final Inflater inf = InflaterCache.get();
                return new InflaterInputStream(in, inf) {
@@ -334,11 +334,11 @@ public class UnpackedObject {
                return new InflaterInputStream(in, inf, BUFFER_SIZE);
        }
 
-       private static BufferedInputStream buffer(InputStream in) {
+       static BufferedInputStream buffer(InputStream in) {
                return new BufferedInputStream(in, BUFFER_SIZE);
        }
 
-       private static int readSome(InputStream in, final byte[] hdr, int off,
+       static int readSome(InputStream in, final byte[] hdr, int off,
                        int cnt) throws IOException {
                int avail = 0;
                while (0 < cnt) {
@@ -363,7 +363,7 @@ public class UnpackedObject {
 
                private final FileObjectDatabase source;
 
-               private LargeObject(int type, long size, File path, AnyObjectId id,
+               LargeObject(int type, long size, File path, AnyObjectId id,
                                FileObjectDatabase db) {
                        this.type = type;
                        this.size = size;
index 8ea0c23eaf092246b245cfaf7c4077162c8b59a1..f855312761c8cad31b138ab09e7945e82de48575 100644 (file)
@@ -73,7 +73,7 @@ final class DeltaTask implements Callable<Object> {
                final int endIndex;
 
                private long totalWeight;
-               private long bytesPerUnit;
+               long bytesPerUnit;
 
                Block(int threads, PackConfig config, ObjectReader reader,
                                DeltaCache dc, ThreadSafeProgressMonitor pm,
@@ -250,7 +250,7 @@ final class DeltaTask implements Callable<Object> {
        }
 
        private final Block block;
-       private final LinkedList<Slice> slices;
+       final LinkedList<Slice> slices;
 
        private ObjectReader or;
        private DeltaWindow dw;
index 1bff6ba4cb8d21674182bf468b30de2e49e832e4..f087aca05b2cd39a337a279674be1e58ce388025 100644 (file)
@@ -218,7 +218,7 @@ public class PackWriter implements AutoCloseable {
        }
 
        @SuppressWarnings("unchecked")
-       private BlockList<ObjectToPack> objectsLists[] = new BlockList[OBJ_TAG + 1];
+       BlockList<ObjectToPack> objectsLists[] = new BlockList[OBJ_TAG + 1];
        {
                objectsLists[OBJ_COMMIT] = new BlockList<ObjectToPack>();
                objectsLists[OBJ_TREE] = new BlockList<ObjectToPack>();
@@ -249,7 +249,7 @@ public class PackWriter implements AutoCloseable {
        /** {@link #reader} recast to the reuse interface, if it supports it. */
        private final ObjectReuseAsIs reuseSupport;
 
-       private final PackConfig config;
+       final PackConfig config;
 
        private final PackStatistics.Accumulator stats;
 
index 1834fef816559efdc360893ffe62719601d441cf..d7d45e41ffd98697827d27ff0ddb9bd07663d6dc 100644 (file)
@@ -512,8 +512,8 @@ class PackWriterBitmapPreparer {
 
                final List<BitmapBuilderEntry> tipCommitBitmaps;
                final Iterable<BitmapCommit> reusedCommits;
-               private final RevCommit[] commitsByOldest;
-               private final int commitStartPos;
+               final RevCommit[] commitsByOldest;
+               final int commitStartPos;
 
                CommitSelectionHelper(Set<? extends ObjectId> peeledWant,
                                RevCommit[] commitsByOldest, int commitStartPos,