tdfs4ds.serve.framework_cost¶
tdfs4ds.serve.framework_cost
¶
Framework cost report (Performance > Framework cost, 0.3.8.0): what tdfs4ds itself costs per call.
Three layers, like efs_map and time_manager_report:
- :func:
collect_framework_cost: the only I/O (readsFS_V_CALL_PHASES, and on demand measures the round trip withSELECT 1on its own connection); - :func:
build_framework_cost_model: pure, on a pandas frame; - :func:
render_framework_cost_html(+ :func:steps_csv): inline SVG and scoped CSS, no external script, light and dark through the shell's--td-*tokens (the standalone file defines them itself).
The eight angles¶
- fixed against variable cost (
cost = a + b x rowsper process, robust fit, break-even rows); - where the fixed cost goes (phases, safety highlighted);
- latency against work (statements x round trip against database time, with a what-if);
- volume classes; 5. per call kind; 6. trend by package version;
- the heaviest framework phases, each with its fix; 8. anomalies (robust z, median / MAD).
What a "step" is, and which numbers are honest, is stated in :mod:tdfs4ds.call_phases: rows are the
feature rows written (an unchanged re-run writes none), a call's steps are its executions (at least 1),
and the fit and the anomalies use only the calls that touched a single process (the others cannot split
their call-level statements between processes).
VOLUME_CLASSES
module-attribute
¶
FIXES
module-attribute
¶
FIXES = {'catalog': 'Metadata reads: fewer processes per roll_out call, or run closer to the database.', 'options': 'Settings reads: one per process per call; roll_out already reads them once.', 'upstream': 'check_upstream=True reads the lineage once per call; leave it False when the order is guaranteed elsewhere (the guard is a safety check: its cost is the price of the refusal).', 'clock': 'TimeManager reads and cursor moves: one clock per data domain (set_domain_time_manager), roll_out(data_domain=...) moves it once per date for all processes.', 'history_guard': 'The history guard reads the stored history once per run; skipped for valid_time_column processes.', 'skip_check': 'nothing_to_compute / final_runs_at: one COUNT per process-date; a date already COMPLETED costs only this check.', 'filter': 'FilterManager: fewer, larger segments (each segment is a full ingestion), or none.', 'followup': 'Follow-up rows (open, close): two statements per execution; fewer executions = fewer segments or dates.', 'entity_refresh': 'track_entity_refresh=False on processes that do not need the last-seen date per entity.', 'lineage': 'Lineage is re-recorded at registration only; register once, not per run.', 'sql_capture': 'Process SQL versions are captured at registration and per run; PROCESS_SQL_VERSIONING=False turns it off (the versions are then not kept).', 'registration': 'A registration that computes nothing still pays its metadata: register once, then run().', 'documentation': 'document=False (the default for a fast loop): documentation is an LLM step.', 'optimize': 'optimize_query=False: the optimizer is an LLM step.', 'history': 'The copy of DBQL into FS_EXECUTION_RESOURCES / FS_CALL_PHASES: throttled to once per 10 minutes per process; EXECUTION_RESOURCES=False and PHASE_TAGS=False stop the copies.', 'query_band': 'tdfs4ds.QUERY_BAND=False removes the band statements (and the profile with them).', 'other': 'Statements outside any phase block, plus CREATE/REPLACE VIEW (a TimeManager or FilterManager cursor move): they are never tagged.', 'uniqueness': 'The duplicate-key check scans the staged rows once; on a very large process it is the cost of a correct primary index.', 'null_key': 'The NULL-key check is one aggregate over the staged rows.', 'row_count': 'The staged row count is one aggregate over the staged rows.', 'truncation': 'The VARCHAR truncation check runs only for registered VARCHAR features.'}
_CSS
module-attribute
¶
_CSS = '<style>\n.fc-wrap{--fc-ink:var(--td-navy,#00233C);--fc-mute:var(--td-slate,#5A6B7B);--fc-card:var(--td-surface,#fff);\n --fc-soft:var(--td-soft,#F5F7FA);--fc-line:var(--td-border,#E2E8F0);--fc-work:#2563EB;--fc-fw:#64748B;\n --fc-sf:#FF5F00;--fc-bad:#B42318;--fc-ok:#027A48;color:var(--fc-ink);font-family:inherit}\n@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .fc-wrap{--fc-work:#60A5FA;--fc-fw:#94A3B8;\n --fc-sf:#FF8A3D;--fc-bad:#F97066;--fc-ok:#47CD89}}\n:root[data-theme="dark"] .fc-wrap{--fc-work:#60A5FA;--fc-fw:#94A3B8;--fc-sf:#FF8A3D;--fc-bad:#F97066;--fc-ok:#47CD89}\n.fc-wrap .fc-kpis{display:flex;flex-wrap:wrap;gap:10px;margin:8px 0 14px}\n.fc-wrap .fc-kpi{background:var(--fc-card);border:1px solid var(--fc-line);border-radius:10px;padding:8px 14px;min-width:130px}\n.fc-wrap .fc-kpi b{display:block;font-size:1.25rem}.fc-wrap .fc-kpi span{font-size:.78rem;color:var(--fc-mute)}\n.fc-wrap details{border:1px solid var(--fc-line);border-radius:8px;margin:8px 0;background:var(--fc-card)}\n.fc-wrap summary{cursor:pointer;padding:8px 12px;font-weight:600}\n.fc-wrap .fc-body{padding:4px 12px 12px}\n.fc-wrap table{border-collapse:collapse;width:100%;font-size:.84rem}\n.fc-wrap th{background:var(--fc-soft);text-align:left;padding:5px 8px;border-bottom:1px solid var(--fc-line)}\n.fc-wrap td{border-top:1px solid var(--fc-line);padding:5px 8px;vertical-align:top}\n.fc-wrap td.n,.fc-wrap th.n{text-align:right;font-variant-numeric:tabular-nums}\n.fc-wrap .fc-note{font-size:.82rem;color:var(--fc-mute);margin:4px 0 8px}\n.fc-wrap .fc-empty{background:var(--fc-soft);border:1px dashed var(--fc-line);border-radius:10px;padding:14px;margin:10px 0}\n.fc-wrap .fc-tag{display:inline-block;border-radius:9px;padding:0 8px;font-size:.74rem;font-weight:700;color:#fff}\n.fc-wrap .t-work{background:var(--fc-work)}.fc-wrap .t-framework{background:var(--fc-fw)}.fc-wrap .t-safety{background:var(--fc-sf)}\n.fc-wrap .fc-bad{color:var(--fc-bad);font-weight:700}.fc-wrap .fc-ok{color:var(--fc-ok)}\n.fc-wrap svg{max-width:100%;height:auto}.fc-wrap svg text{fill:var(--fc-ink);font-size:11px}\n.fc-wrap svg .ax{stroke:var(--fc-line)}.fc-wrap svg .mute{fill:var(--fc-mute)}\n.fc-wrap .s-work{fill:var(--fc-work)}.fc-wrap .s-framework{fill:var(--fc-fw)}.fc-wrap .s-safety{fill:var(--fc-sf)}\n.fc-wrap .pt{fill:var(--fc-work);opacity:.85}.fc-wrap .ln{stroke:var(--fc-sf);stroke-width:2;fill:none}\n.fc-wrap .flag{fill:var(--fc-bad)}\n.fc-wrap code{font-size:.8rem;word-break:break-all}\n.fc-wrap input[type=range]{width:260px;vertical-align:middle}\n</style>'
_STANDALONE_TOKENS
module-attribute
¶
_STANDALONE_TOKENS = '<style>\n:root{--td-navy:#00233C;--td-slate:#5A6B7B;--td-surface:#fff;--td-soft:#F5F7FA;--td-border:#E2E8F0;--td-bg:#fff}\n@media (prefers-color-scheme:dark){:root{--td-navy:#E6EDF5;--td-slate:#9AA9B8;--td-surface:#111F2E;--td-soft:#16273A;\n--td-border:#24384E;--td-bg:#0B1622}}\nbody{background:var(--td-bg);color:var(--td-navy);font-family:Segoe UI,system-ui,sans-serif;margin:0;padding:16px}\n</style>'
_SLIDER_JS
module-attribute
¶
_SLIDER_JS = "<script>(function(){var r=document.getElementById('fc-rtt');if(!r)return;\nfunction go(){var ms=parseFloat(r.value);document.getElementById('fc-rtt-v').textContent=ms+' ms';\ndocument.querySelectorAll('[data-fc-stm]').forEach(function(td){var s=parseFloat(td.dataset.fcStm),d=parseFloat(td.dataset.fcDb);\nvar w=s*ms/1000,t=d+w;td.textContent=t.toFixed(1)+' s ('+(t?Math.round(100*w/t):0)+'% wire)';});}\nr.addEventListener('input',go);go();})();</script>"
collect_framework_cost
¶
Read the facts. Never raises: {"state", "facts", "error", "hint", "round_trip_ms", "days"}.
run: run(sql) -> DataFrame (tests); default the teradataml session.
measure_round_trip_ms
¶
Median of n SELECT 1 on a connection of our own (never the shared one). None when it cannot.
robust_line
¶
Theil-Sen line y = a + b x (median of the pairwise slopes), robust to outliers. Needs 3 points and
2 distinct x. {"a", "b", "n"} or None. Pure.
break_even_rows
¶
Rows at which the variable cost b x rows equals the fixed cost a; None without a positive
a and b. Pure.
robust_z
¶
Robust z of each value: 0.6745 (x - median) / MAD; a zero MAD falls back to the mean absolute
deviation ((x - median) / (1.2533 meanAD)); a constant series gives 0. Pure.
what_if
¶
Estimated step time at a given round trip: db + statements x rtt. Pure.
_steps_frame
¶
One row per (call, process): the step table (the FS_V_FRAMEWORK_COST_RUN view, rebuilt in pandas
so the model works on the facts alone).
build_framework_cost_model
¶
The report's data. inputs is :func:collect_framework_cost's result. Pure.
_short
¶
A view name without its database and quotes (process ids are kept whole).
_svg_scatter
¶
_svg_scatter(points, line, width=420, height=220, xlabel='rows written per step', ylabel='DB seconds per step') -> str
_svg_timeline
¶
Anomaly strip: one dot per flagged step along the time of the window.
render_framework_cost_html
¶
The report body (or a whole page with standalone=True: theme tokens included).
steps_csv
¶
The step table (one row per call and process) as CSV, for analytics outside the app.