Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5416

Vectors read from disk report incorrect memory sizes

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.0
    • Fix Version/s: 1.12.0
    • Component/s: None
    • Labels:
      None

      Description

      The external sort and revised hash agg operators spill to disk using a vector serialization mechanism. This mechanism serializes each vector as a (length, bytes) pair.

      Before spilling, if we check the memory used for a vector (using the new RecordBatchSizer class), we learn of the actual memory consumed by the vector, including any unused space in the vector.

      If we spill the vector, then reread it, the reported storage size is wrong.

      On reading, the code allocates a buffer, based on the saved length, rounded up to the next power of two. Then, when building the vector, we "slice" the read buffer, setting the memory size to the data size.

      For example, suppose we save 20 1-byte fields. The size on disk is 20. The read buffer is rounded to 32 bytes (the size of the original, pre-spill buffer.) We read the 20 bytes and create a vector. Creating the vector reports the memory size as 20, "hiding" the extra, unused 12 bytes.

      As a result, when computing memory sizes, we receive incorrect numbers. Working with false numbers means that the code cannot safely operate within a memory budget, causing the user to receive an unexpected OOM error.

      As it turns out, the code path that does the slicing is used only for reads from disk. This ticket asks to remove the slicing step: just use the allocated buffer directly so that the after-read vector reports the correct memory usage; same as the before-spill vector.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                paul-rogers Paul Rogers
                Reporter:
                paul-rogers Paul Rogers
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: