Uploaded image for project: 'MyCoRe'
  1. MCR-1290

Serving ranges of big files takes long time

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2016.12, 2016.06.0.1
    • Component/s: None
    • Labels:
      None

      Description

      If you serve a 10kb range of a 100mb pdf (via FileNodeServlet) the Servlet need 600ms on my Macbook with SSD.

      I think the reason is org.mycore.common.content.util.MCRServletContentHelper#copyRange, which uses the IOUtils.copyLarge method. I looked at the source and the skip method actually reads instead of skip:

       public static long skip(InputStream input, long toSkip) throws IOException {
              if (toSkip < 0) {
                  throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip);
              }
              /*
               * N.B. no need to synchronize this because: - we don't care if the buffer is created multiple times (the data
               * is ignored) - we always use the same size buffer, so if it it is recreated it will still be OK (if the buffer
               * size were variable, we would need to synch. to ensure some other thread did not create a smaller one)
               */
              if (SKIP_BYTE_BUFFER == null) {
                  SKIP_BYTE_BUFFER = new byte[SKIP_BUFFER_SIZE];
              }
              long remain = toSkip;
              while (remain > 0) {
                  long n = input.read(SKIP_BYTE_BUFFER, 0, (int) Math.min(remain, SKIP_BUFFER_SIZE));
                  if (n < 0) { // EOF
                      break;
                  }
                  remain -= n;
              }
              return toSkip - remain;
          }
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                mcrshofm Sebastian Hofmann
                Reporter:
                mcrshofm Sebastian Hofmann
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: