]> source.dussan.org Git - jgit.git/commit
Remove unnecessary inflate stride in DfsBlock 36/16136/3
authorShawn Pearce <spearce@spearce.org>
Wed, 4 Sep 2013 19:56:38 +0000 (12:56 -0700)
committerShawn Pearce <spearce@spearce.org>
Wed, 4 Sep 2013 21:54:50 +0000 (14:54 -0700)
commitaa8d5ac26c29663ef2792cd2eb1a749746c9307f
treee154f2052bbbd4dce3b7ed426716bc88b3094909
parentf68ffb48eb16171da3d42b91f20c842201ea7431
Remove unnecessary inflate stride in DfsBlock

OpenJDK 7 does not benefit from using an inflate stride on the input
array. The implementation of java.util.zip.Inflater supplies the
entire input byte[] to libz, with no regards for the bounds supplied.
Slicing at 512 byte increments in DfsBlock no longer has any benefit.

In OpenJDK 6 the native portion of Inflater used GetByteArrayRegion
to obtain a copy of the input buffer for libz. In this use case
supplying a small stride made sense, it avoided allocating space
for and copying data past the end of the object's compressed stream.

In OpenJDK 7 the native code uses GetPrimitiveArrayCritical,
which tries to avoid copying by freezing Java garbage collection
and accessing the byte[] contents in place. On OpenJDK 7 derived
JVMs it is likely more efficient to supply the entire DfsBlock.

Since OpenJDK 5 and 6 are deprecated and replaced by OpenJDK 7
it is reasonable to suggest any consumers running JGit with DFS
support use an OpenJDK 7 derived JVM. However, JGit still targets
local filesystem support on Java 5, so it is still not reasonble to
apply this same simplification to the internal.storage.file package.

See: JDK-6751338 (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6751338)
Change-Id: Ib248b6d383da5c8aa887d9c355a0df6f3e2247a5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsBlock.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java