tdfs4ds.sizing¶
tdfs4ds.sizing
¶
Sizing and scalability of a data domain: what one refresh costs, how storage grows, and a forecast (0.3.8.7).
One refresh of a domain is one step of its clock (what roll_out(data_domain=...) runs). This module
answers four questions from what the store already keeps, and changes nothing in it:
- what does a step cost, in elapsed time, CPU, I/O and peak spool, per process and for the domain, and how
does it evolve? (
FS_EXECUTION_RESOURCESand the live follow-up <-> DBQL join, one row per execution); - how long is a refresh when the processes run one after the other (
sequential, what a plainroll_outcosts), when the independent ones run together (by_waves, the floor withroll_out(max_workers=)or the generated script) and what really happened (measured, first start to last end in the logs); - how many rows (and how many bytes) does each step add? Every stored value carries
ValidStart(the business date of the run that wrote it) andFEATURE_VERSION(the process), so oneGROUP BYper storage table rebuilds the history of the growth with no new table; - where does this lead: the forecast of each series over a horizon, and the date a refresh no longer fits in the time between two steps of the clock.
Three layers, like the other reports:
- :func:
collect_domain_sizing- the only I/O, fail-open, TWO grouped requests (see its docstring); - :func:
build_domain_sizing- pure: frames -> one JSON-friendly model; - :func:
render_domain_sizing_html/ :func:render_domain_sizing_markdown/ :func:domain_sizing_csv.
Public: :func:domain_sizing and :func:write_domain_sizing_report (exported lazily on tdfs4ds).
Read only: a source guard (tests/test_domain_sizing.py) keeps every write out of this file.
STORAGE_SHAPE
module-attribute
¶
SERIES_KEYS
module-attribute
¶
_METHOD
module-attribute
¶
_METHOD = ['Time steps are the business dates of the domain clock (the valid time of each run). The segments of a process in one step are summed; a step recomputed counts once (its latest execution).', 'Sequential = the sum of the run times of the processes of a step (what a plain roll_out costs). By waves = the sum over the waves of the lineage graph of the longest process of each wave: the floor when independent processes run together, assuming each wave runs fully in parallel and the platform has room (processes that write the same storage table must still run one after the other, which this ignores). Measured = first start to last end of the step in the logs.', 'Rows added are the stored rows whose ValidStart is the step (a value that changed, or a new entity). The first step of a process is its initial load and is shown apart: it is not growth. Bytes are an estimate: the rows times the average bytes per row of their table (DBC.TableSizeV CurrentPerm divided by the rows of the table, history included).', 'A forecast is a Theil-Sen line over the step index with a band from the 10th-90th percentile of the residuals. It extends the past: a new process version, a change of data volume or of calendar breaks it. Under 6 usable steps there is no forecast. Steps with a failed or missing process are left out of the fit.', 'Elapsed time depends on the platform (AMPs, concurrent workload, ACC / OFS); CPU and I/O far less. CPU seconds divided by the number of AMPs is a lower bound of the elapsed time of a CPU-bound refresh on another platform, not a prediction.']
CSS
module-attribute
¶
CSS = '\n.td-sz{--navy:#00233C;--orange:#FF5F00;--slate:#5A6B7B;--bg:#FFFFFF;--surface:#FFFFFF;--soft:#F5F7FA;--border:#E2E8F0;--teal:#0E7C86;\n--td-navy:#00233C;--td-orange:#FF5F00;--td-slate:#5A6B7B;--td-border:#E2E8F0;--td-surface:#FFFFFF;\nfont-family:"Segoe UI",system-ui,sans-serif;color:var(--navy);background:var(--bg);max-width:1100px;margin:0 auto;padding:20px 16px 40px;line-height:1.45}\n@media (prefers-color-scheme: dark){:root:not([data-theme="light"]) .td-sz{--navy:#E6EDF5;--slate:#9AA9B8;--bg:#0B1622;--surface:#111F2E;--soft:#16273A;--border:#24384E;--teal:#4FC3CE;\n--td-navy:#E6EDF5;--td-slate:#9AA9B8;--td-border:#24384E;--td-surface:#111F2E}}\n:root[data-theme="dark"] .td-sz{--navy:#E6EDF5;--slate:#9AA9B8;--bg:#0B1622;--surface:#111F2E;--soft:#16273A;--border:#24384E;--teal:#4FC3CE;\n--td-navy:#E6EDF5;--td-slate:#9AA9B8;--td-border:#24384E;--td-surface:#111F2E}\nbody{margin:0;background:var(--bg,#fff)}\n@media (prefers-color-scheme: dark){:root:not([data-theme="light"]) body{background:#0B1622}}\n:root[data-theme="dark"] body{background:#0B1622}\n.td-sz h1{margin:0 0 4px;font-size:26px}.td-sz h2{font-size:18px;margin:28px 0 8px;border-left:4px solid var(--orange);padding-left:10px}\n.td-sz h3{font-size:15px;margin:16px 0 6px}\n.td-sz .hero{background:linear-gradient(135deg,#00233C,#0B3A5E);color:#fff;border-radius:12px;padding:22px 24px;margin-bottom:16px}\n.td-sz .hero .kicker{color:#FF9A5C;font-size:12px;letter-spacing:.08em;text-transform:uppercase}\n.td-sz .hero .meta{margin-top:8px;font-size:13px;opacity:.9}.td-sz .hero .meta span{margin-right:16px}\n.td-sz .kpis{display:flex;flex-wrap:wrap;gap:10px;margin:12px 0}\n.td-sz .kpi{flex:1 1 150px;background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:10px 14px}\n.td-sz .kpi b{display:block;font-size:21px}.td-sz .kpi span{font-size:12px;color:var(--slate)}\n.td-sz table{border-collapse:collapse;width:100%;font-size:12.5px;background:var(--surface)}\n.td-sz th{background:var(--soft);text-align:left;padding:6px 8px;border-bottom:2px solid var(--border)}\n.td-sz td{padding:5px 8px;border-bottom:1px solid var(--border);vertical-align:top}\n.td-sz tr:nth-child(even) td{background:var(--soft)}\n.td-sz .num{text-align:right;white-space:nowrap}.td-sz .bad{color:#dc2626;font-weight:600}\n.td-sz .note{color:var(--slate);font-size:12.5px;margin:6px 0}\n.td-sz .card{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:12px 14px;margin:12px 0}\n.td-sz ul.findings{margin:6px 0;padding-left:20px}.td-sz ul.findings li{margin:4px 0}\n.td-sz li.warning{color:#b45309;font-weight:600}\n.td-sz .grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(360px,1fr));gap:10px}\n.td-sz .grid .cell{border:1px solid var(--border);border-radius:8px;padding:6px 8px;background:var(--surface)}\n.td-sz .bar{display:block;height:8px;background:var(--orange);border-radius:4px}\n.td-sz .shr{display:flex;align-items:center;justify-content:flex-end;gap:8px}\n.td-sz .shr-t{min-width:36px;text-align:right}\n.td-sz .shr-bg{display:block;width:60px;height:8px;background:var(--border);border-radius:4px;overflow:hidden;flex:none}\n.td-sz footer{color:var(--slate);font-size:12.5px;text-align:center;margin-top:30px}\n.td-sz .scroll{overflow-x:auto}\n'.strip()
processes_sql
¶
The processes of the data domain (the public process catalog view applies the valid time).
process_ids_sql
¶
The ids of the domain's processes as a sub-select that stands for the id list of the execution readers.
features_sql
¶
The features of the domain at the current valid time (their storage tables).
calendar_rules_sql
¶
The calendar rules stored for the tables of dates (small table).
table_sizes_sql
¶
The size of every storage table of the store, summed over the AMPs (narrowed in Python).
storage_sql
¶
Rows of a storage table per (process, ValidStart), read in one pass of the table.
The rows of the domain's processes are grouped by (FEATURE_VERSION, ValidStart); every other row falls in one
group ('*', NULL), so the sum of the counts is the number of rows of the table, history included (what the bytes
per row are divided by) and no second pass is needed. O counts the rows still open now.
first_statements
¶
R1: {name: statement} of everything read before the storage tables are known (pure but for the
one cached available() probe of the execution tables).
collect_domain_sizing
¶
collect_domain_sizing(data_domain, *, days: int = 365, horizon: str = 'quarter', storage: bool = True, emit=None) -> dict
Read what :func:build_domain_sizing needs. Only I/O, fail-open, TWO grouped requests.
- R1 (nothing is known yet): the processes of the domain, its features (storage tables), the clock
setting, the calendar rules, the executions (stored history + the live follow-up <-> DBQL join, for the
domain's processes through a sub-select, the SQL of
read_execution_resources), the lineage rows, the size of the store'sFS_T_*tables and the platform (AMPs, version). - R2 (needs R1's tables and clock): the dates of the clock and, when storage is true, one statement per
storage table of the domain (see :func:
storage_sql).
The storage shape was chosen on Vantage 20 by reading the EXPLAIN steps (not counting them): see
STORAGE_SHAPE (top of this module) for the measured choice.
Every failed read is recorded whole in errors ({"what", "message"}) and the part is left empty: nothing
is raised. A statement that fails alone splits its request (degraded: more requests, requests_sent says
how many were really sent). Returns a dict of frames and rows (not JSON-safe by design).
_wall_seconds
¶
Epoch seconds (zone dropped) of a list of dates, NaN where unreadable.
_waves
¶
{available, reason, waves, wave_of, unknown, cycle} from the lineage rows and the process frame.
_theil_sen_trend
¶
Slope per step of the usable values (None under MIN_STEPS values).
_forecast_at
¶
Forecast of points at the given future times (epoch seconds). Same method and summary keys as
:func:process_evolution.forecast_series, but the dates come from the clock's calendar.
_future_times
¶
(future epoch seconds, gap_days, source): the clock's next dates within the horizon, else one
median gap apart.
_step_tables
¶
{metric: {pid: {t: point}}} and the measured span per step, from the timed executions.
build_domain_sizing
¶
The sizing model from :func:collect_domain_sizing's data. Pure; JSON-friendly. See the module docstring.
Never fabricates: under :data:MIN_STEPS usable steps a series has no forecast, with the reason.
_storage
¶
Rows and bytes per step from the stored GROUP BY rows: {by_step, summary}.
_scheduling
¶
The refresh against the time between two steps of the clock.
_processes_table
¶
One row per process: share of a step, trend, rows and bytes per step, tables, wave.
_svg_lines
¶
_svg_lines(lines, *, unit='sec', title='', width=860, height=300, now_label='now (last step)') -> str
Several series over time. lines: [{name, color, points: [(t, y)], future: [{t, y, lo, hi}], dash}].
render_domain_sizing_html
¶
One self-contained HTML document (inline SVG and CSS, no script) from :func:build_domain_sizing.
app=True returns a fragment (scoped style + the report) for the admin app, with process names that open the
object menu; the exported file (default) is unchanged.
_fragment
¶
The scoped style (without the page-level body rules) and the report body of :func:_page.
_obj_attrs
¶
Attributes that make a process name open the app's object menu (only when rendered for the app).
render_domain_sizing_markdown
¶
The same model as Markdown tables (no chart).
domain_sizing_csv
¶
CSV of the per-step table (what='steps') or of the process table (what='processes').
domain_sizing
¶
domain_sizing(data_domain=None, horizon: str = 'quarter', days: int = 365, storage: bool = True, emit=None) -> dict
Size a data domain: the cost of one refresh (one step of its clock), how it evolves, the storage each step
adds and a forecast over horizon ('month', 'quarter', 'semester', 'year'). Read only: two
grouped requests, nothing is written. storage=False skips the storage scan (the expensive part: one pass
over each storage table). Returns the model :func:build_domain_sizing builds (see :func:render_domain_sizing_html).
write_domain_sizing_report
¶
write_domain_sizing_report(data_domain=None, out_path: Optional[str] = None, fmt: str = 'html', *, model: Optional[dict] = None, what: str = 'steps', **kwargs) -> str
Write the sizing report of a data domain and return its path. fmt: 'html' (default, self-contained),
'md' or 'csv' (what='steps' or 'processes'). kwargs go to :func:domain_sizing; model
renders a model already built. Default folder: tdfs4ds.DASHBOARD_REPORT_DIR.