Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/ITL-1464.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- Documented the storage cost of keeping provenance with function results and pipeline records, including Parquet encoding and local Arrow spill measurements.
8 changes: 8 additions & 0 deletions docs/dev/scripts/itl-1464-storage/column-sizes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
column_family,narrow_arrow_bytes_per_pipeline_row,narrow_delta_bytes_per_pipeline_row,narrow_zstd_prefix_bytes_per_pipeline_row,wide_arrow_bytes_per_pipeline_row,wide_delta_bytes_per_pipeline_row,wide_zstd_prefix_bytes_per_pipeline_row
Input data hash,100,75,65,100,75,65
Pipeline output data hash,52,37,32,52,37,32
Pipeline record and base entry IDs,100,75,65,100,75,65
Result record and pipeline data IDs,48,31,22,48,31,22
Pipeline system tags,52,6.4,0.3,52,6.4,0.3
Input provenance tokens,53,7,0.3,53,7,0.3
Output provenance tokens,140,31,13,1400,310,130
96 changes: 96 additions & 0 deletions docs/dev/scripts/itl-1464-storage/columns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""Summarize column families as rounded, normalized storage costs."""

from __future__ import annotations

import argparse
import csv
import json
import sys
from pathlib import Path
from typing import TypedDict, cast

Families = dict[str, list[int]]
PREFIX_SETTINGS = "zstd-3-prefix-131072"


class ByteCounts(TypedDict):
"""Bytes in one physical Parquet variant."""

bytes: int
rows: int
compressed: dict[str, int]


class TableCounts(TypedDict):
"""Measurement record for one Delta table."""

columns: list[str]
arrow: dict[str, int]
actual: ByteCounts
computed: dict[str, ByteCounts]


def column_family(table: str, column: str) -> str | None:
"""Group internal columns that carry the same kind of storage overhead."""
if column == "__input_data_hash":
return "Input data hash"
if column == "__output_data_hash":
return "Pipeline output data hash"
if table == "pdb_v1" and column in {"__record_id", "__pipeline_base_entry_id"}:
return "Pipeline record and base entry IDs"
if column in {"__record_id", "__data_id"}:
return "Result record and pipeline data IDs"
if column.startswith("_tag_"):
return "Pipeline system tags"
if column.startswith("_source_"):
return (
"Input provenance tokens"
if table == "pdb_v1"
else "Output provenance tokens"
)
return None


def summarize(path: Path) -> dict[str, list[str]]:
"""Normalize private measurements by the pipeline row count."""
tables = cast("dict[str, TableCounts]", json.loads(path.read_text()))
rows = tables["pdb_v1"]["actual"]["rows"]
sizes: Families = {}
for name, table in tables.items():
for index, column in enumerate(table["columns"]):
family = column_family(name, column)
if family is None:
continue
key = str(index)
summed = sizes.setdefault(family, [0, 0, 0])
summed[0] += table["arrow"][key]
summed[1] += table["actual"]["compressed"].get(key, 0)
summed[2] += table["computed"][PREFIX_SETTINGS]["compressed"].get(key, 0)
return {
family: [format(float(format(size / rows, ".2g")), "g") for size in variants]
for family, variants in sizes.items()
}


def main() -> None:
"""Write only rounded ratios, without source labels or absolute counts."""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("narrow", type=Path, help="local metrics for a narrow result")

Check warning on line 78 in docs/dev/scripts/itl-1464-storage/columns.py

View workflow job for this annotation

GitHub Actions / Ruff and basedpyright

Result of call expression is of type "Action" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
parser.add_argument("wide", type=Path, help="local metrics for a wide result")

Check warning on line 79 in docs/dev/scripts/itl-1464-storage/columns.py

View workflow job for this annotation

GitHub Actions / Ruff and basedpyright

Result of call expression is of type "Action" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
args = parser.parse_args()
narrow, wide = summarize(args.narrow), summarize(args.wide)

Check warning on line 81 in docs/dev/scripts/itl-1464-storage/columns.py

View workflow job for this annotation

GitHub Actions / Ruff and basedpyright

Argument type is Any   Argument corresponds to parameter "path" in function "summarize" (reportAny)

Check warning on line 81 in docs/dev/scripts/itl-1464-storage/columns.py

View workflow job for this annotation

GitHub Actions / Ruff and basedpyright

Type of "narrow" is Any (reportAny)
writer = csv.writer(sys.stdout, lineterminator="\n")
writer.writerow(
["column_family"]
+ [
f"{width}_{variant}_bytes_per_pipeline_row"
for width in ("narrow", "wide")
for variant in ("arrow", "delta", "zstd_prefix")
]
)
for family in narrow:
writer.writerow([family, *narrow[family], *wide[family]])


if __name__ == "__main__":
main()
Loading
Loading