Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-8633

Content Repository can be improved to make fewer disks accesses on read

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.14.0
    • Core Framework
    • None

    Description

      When FileSystemRepository.read(ContentClaim) or FileSystemRepository.read(ResourceClaim) is called, the repository determines the file path for the claim via getPath(claim, true); where the true indicates that we should verify that the file exists.

      This is done so that if we were to pass in a ContentClaim that does not exist, we throw a more meaningful ContentNotFoundException instead of just letting a FileNotFoundException fly.

      However, this call to Files.exists(Path) is fairly expensive, as it's a disk access. For a flow that uses a lot of smaller files, this can be extremely expensive.

      We can improve this by removing the call to Files.exists all together. Instead, just blindly create the FileInputStream in a try/catch block and catch FileNotFoundException, and then wrap that in a ContentNotFoundException. This results in the same API and the same contracts as before but avoids the overhead of additional disk accesses/seeks.

      Attachments

        Issue Links

          Activity

            People

              markap14 Mark Payne
              markap14 Mark Payne
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m