Poor Read Performance in Dockerfile.ScannedResult
In the buildDockerFolderTar method in Dockerfile.ScannedResult, an anonymous subclass of InputStream is created. The subclass overrides only the single-byte variant of the read method:
// line 139, Dockerfile.java
return new InputStream() {
@Override
public int read() throws IOException {
return tarInputStream.read();
}
@Override
public void close() throws IOException {
IOUtils.closeQuietly(tarInputStream);
FileUtils.deleteQuietly(tarFile);
}
};
For some setups, this causes slow but acceptable performance, on others performance is completely unacceptable (e.g. 2mins plus to read a 40MB file).
This can be fixed by also overriding the bulk read method, i.e.
@Override
public int read(byte [] buff, int offset, int len) throws IOException {
return tarInputStream.read(buff, offset, len);
}
I can provide a gist to demonstrate if necessary, but hopefully the problem and fix are self-explanatory enough without.