LazyFrame sort_by_multi does not spill; only single-key sort is an external merge sort
FactVerified 8 Oct 2026Holds project: dftracer-utils
Fact. A statement and the evidence for it.
Statement#
SortByMultiCursor (src/dftracer/utils/dataframe/lazyframe.cpp) buffers its input in a Spool, drains it into one frame and calls DataFrame::sort_by_multi, so peak memory is the whole input. Only SortMergeCursor (single key) is an external merge sort. For a multi-key sort of fixed-size records beyond memory, use ExternalSorter in core/common/external_sort.h.
Evidence#
The cursor's own comment says DataFrame::sort_by_multi has no external-merge form. Genesis (trace/genesis/process.cpp) uses ExternalSorter for this reason.
Also found by searching
- does sort_by_multi spill
- which lazyframe ops are out of core
- SortByMultiCursor memory