X Tutup
Skip to content

Poor Read Performance in Dockerfile.ScannedResult #358

@s-webb

Description

@s-webb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup