Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_code-sorting-and-merging

Sorting, Partitioning, External K-Way Merge & Timsort

6 COMPONENTS · 6 FLOWS · UPDATED 2026-11-24
GITHUB README / PR PREVIEW CARD
[![Sorting, Partitioning, External K-Way Merge & Timsort — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_code-sorting-and-merging/opengraph-image)](https://archos.sageideas.dev/d/dgm_code-sorting-and-merging)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_code-sorting-and-merging)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_code-sorting-and-merging" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Sorting, Partitioning, External K-Way Merge & Timsort — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  client_0["Dataset / Spill Files"]
  n1_1["In-RAM Sorter"]
  n2a_2[("Partitioner / Spill")]
  n2b_3[("K-Way Merge Heap")]
  n3_4[("Sorted Output Stream")]
  downstream_5["Downstream & OTel"]
  client_0 -->|"1. Sort · ON log N"| n1_1
  n1_1 -->|"2a. Spill runs · Seq IO"| n2a_2
  n1_1 -->|"2b. Merge K · ON log K"| n2b_3
  n2a_2 -->|"3a. Write out · Seq IO"| n3_4
  n2b_3 -->|"3b. Merge · RAM"| n3_4
  n3_4 -.->|"4. Emit / · OTLP/API"| downstream_5

COMPONENT STACK (6)

  • Dataset / Spill FilesSTATELESS
    In-RAM or TB Disk Runs
  • In-RAM SorterSTATELESS
    Timsort / Introsort
  • Partitioner / SpillSTATEFUL
    Writes sorted NVMe run files
  • K-Way Merge HeapSTATEFUL
    Tournament tree / Min-Heap
  • Sorted Output StreamSTATEFUL
    Stable ordered Parquet/SSTable
  • Downstream & OTelSTATELESS
    Consumers, metrics & SLOs

REQUEST & DATA FLOW (6)

  1. Dataset / Spill Files → In-RAM Sorter (Sort)[ON log N]
  2. In-RAM Sorter → Partitioner / Spill (Spill runs)[Seq IO]
  3. In-RAM Sorter → K-Way Merge Heap (Merge K)[ON log K]
  4. Partitioner / Spill → Sorted Output Stream (Write out)[Seq IO]
  5. K-Way Merge Heap → Sorted Output Stream (Merge)[RAM]
  6. Sorted Output Stream → Downstream & OTel (Emit /)[OTLP/API]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →