Skip to content

Show an estimated savings opportunity with a code-fix CTA - #84

Open
DanielAronovich wants to merge 5 commits into
dataflint:mainfrom
DanielAronovich:feature/oss-savings-opportunity
Open

DanielAronovich wants to merge 5 commits into
dataflint:mainfrom
DanielAronovich:feature/oss-savings-opportunity

Conversation

@DanielAronovich

Copy link
Copy Markdown
Contributor

Summary

Adds a rough savings estimate to the OSS Spark UI: how much of the app's compute cost (DCU) looks recoverable, with a low-key "Get the code fix · See it live" CTA to the DataFlint demo page. It also fixes the idle cores rate in local mode and adds a local dev loop.

Savings estimate (SavingsOpportunityReducer)

  • Query fixes: each alerted query saves its DCU × a per-alert runtime reduction. Several alerts on one query compound.
  • Idle cores and over-provisioned memory: right-sized on the cost that is left after the query fixes.
  • No double counting: skew fixes give back cores that sat idle, so their savings are taken out of the idle pool.
  • Calibration: the reductions for skew, small tasks, broadcast and small files come from before/after runs on a local standalone cluster (SavingsFixDemo), rounded down. The other alert reductions are heuristics.
  • Per-alert figures: each alert gets a savingsPercentage, shown on the Alerts tab.

UI

  • Summary page: a "Savings ~X%" tile, with a tooltip that breaks the number down.
  • Sidebar: a quiet "Get the code fix" card in the drawer's empty space, shown on every page. It collapses to an icon when the drawer is collapsed.
  • Alerts tab: a savings chip on each alert group, plus "Save ~X% of this app's cost" and a CTA on each alert.
  • Hidden in the SaaS UI: all CTAs (isDataFlintSaaSUI).
  • Tracking: clicks are tracked with the Mixpanel event SavingsBookDemoClicked. The link carries UTM tags, including the placement: summary-tile, sidebar or alert-<name>.

Idle cores fix

  • Local mode: idle cores now use stage task time. The driver's totalDuration is its uptime, so the rate was stuck at 1 - 1/cores.
  • Per query: the idle cores value was the busy % inverted; it now shows the idle %.

Dev loop

  • dev.sh: job, cluster-job, cluster-stop, ui, deploy-ui, shs and shs-ui, documented in CONTRIBUTING.md.
  • Examples: DevPlayground and the SavingsFixDemo before/after scenarios.

Test plan

  • npm test: 19 suites and 102 tests pass, including new specs for the estimator and the local-mode idle rate.
  • tsc is clean.
  • Before/after runs of each SavingsFixDemo scenario, local and on a standalone cluster, compared the estimate with the real cost difference.
  • Checked the UI in the history server at 1440, 1280 and 1024 px: the tile, the sidebar card (expanded and collapsed) and the alert CTAs. The CTA link is correct for every placement.

DanielAronovich and others added 5 commits November 1, 2026 15:08
dev.sh wraps the common local workflows: running an example job, the
hot-reload UI, deploying the UI into the plugin, a history server with
the plugin, and a local standalone cluster (cluster-job / cluster-stop).
DevPlayground runs a mix of workloads so most views and alerts have data,
then waits for Enter so the live UI stays up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In local mode Spark reports the driver's totalDuration as its uptime
rather than its task time, so the idle cores rate was always
1 - 1/cores (87.5% on local[8]). Use the stages' task time instead.

The per-query "Idle Cores" value was computed as task time / core time,
i.e. the busy share; it now reports the idle share its label describes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Estimates the share of the app's compute cost (DCU) that could be saved:
alerted queries save their DCU times a per-alert runtime reduction
(compounding when a query has several alerts), then idle cores and
over-provisioned memory are right-sized on the cost that is left. Skew
fixes are taken out of the idle pool so reclaimed idle isn't counted
twice. The calibrated factors come from SavingsFixDemo before/after runs
on a local standalone cluster.

The estimate shows as a Savings tile on the summary page, a banner on the
status page, and per-alert chips and buttons on the alerts tab. Clicks open
the book-a-demo page with UTM tags for placement and percentage and are
tracked in Mixpanel. Hidden in the DataFlint SaaS UI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lead with the outcome ("Get the code fix") instead of "Fix it with AI",
explain how in a secondary line (DataFlint's agent opens the PR from the
IDE via MCP), keep "Book a demo" on every button so the destination is
clear, and swap the sparkles icon for a code icon. The label and pitch
are shared from BookDemo.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the Status-page banner with a quiet "Get the code fix" card in the
drawer's empty space, shown on every page (an icon when collapsed), and say
"See it live" instead of "Book a demo" on all savings CTAs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DanielAronovich
DanielAronovich requested review from menishmueli and a balanced review from Copilot November 3, 2026 14:03
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved issues overstate and double-count savings, prevent keyboard access to the demo CTA, and override the submitted Spark master, leaving the intended cluster unused.

5 open issues
What changed in this PR

Adds estimated compute-cost savings to the OSS Spark UI, with tracked code-fix demo CTAs. It also corrects idle-core metrics and introduces local development workflows.

Changes:

  • Estimates query, idle-core, and memory savings, displayed in the summary, sidebar, and alerts.
  • Corrects local-mode and per-query idle-core calculations.
  • Adds development commands, sample workloads, and before/after calibration scenarios.
File Description
spark-ui/​src/​utils/​BookDemo.ts Shared CTA styling, formatting, tracking, and demo links.
spark-ui/​src/​tabs/​AlertsTab.tsx Adds savings chips and per-alert CTAs.
spark-ui/​src/​reducers/​StatusReducer.ts Uses stage task time for local-mode idle cores.
spark-ui/​src/​reducers/​StatusReducer.spec.ts Tests local-mode idle-core calculation and fallback.
spark-ui/​src/​reducers/​SparkSlice.ts Passes stage task time into executor status calculation.
spark-ui/​src/​reducers/​SavingsOpportunityReducer.ts Computes app-level and per-alert savings estimates.
spark-ui/​src/​reducers/​SavingsOpportunityReducer.spec.ts Tests savings calculations and missing-data handling.
spark-ui/​src/​reducers/​MetricsReducer.ts Corrects per-query idle percentage.
spark-ui/​src/​reducers/​AlertsReducer.ts Integrates savings estimation after alert filtering.
spark-ui/​src/​interfaces/​Mixpanel.ts Defines the savings CTA click event.
spark-ui/​src/​interfaces/​AppStore.ts Adds savings types and optional estimate fields.
spark-ui/​src/​components/​SummaryBar.tsx Displays the OSS savings tile.
spark-ui/​src/​components/​SavingsOpportunityBox.tsx Adds the savings tile, breakdown tooltip, and CTA.
spark-ui/​src/​components/​AppDrawer/​DrawerSavingsCard.tsx Adds expanded and collapsed sidebar CTAs.
spark-ui/​src/​components/​AppDrawer/​AppDrawer.tsx Integrates the sidebar savings card.
spark-plugin/​example_3_5_1/​src/​main/​scala/​io/​dataflint/​example/​SavingsFixDemo.scala Adds before/after savings calibration workloads.
spark-plugin/​example_3_5_1/​src/​main/​scala/​io/​dataflint/​example/​DevPlayground.scala Adds varied workloads for live UI development.
dev.sh Provides job, cluster, UI, and history-server commands.
CONTRIBUTING.md Documents the local development workflow.

Review effort: Balanced

.config("spark.eventLog.enabled", "true")
.config("spark.eventLog.dir", eventLogDir)
.config("spark.sql.maxMetadataStringLength", "10000")
.master("local[*]")
Comment on lines +43 to +46
<Paper
onClick={() => openBookDemo("summary-tile", savings.totalPercentage)}
sx={{
p: 2,
if (IDLE_RECLAIMING_ALERTS.has(alert.name)) {
idleReclaimingDCUBySqlId.set(
sqlId,
Math.max(idleReclaimingDCUBySqlId.get(sqlId) ?? 0, savingsDCU),
Comment on lines +93 to +97
remainingRuntimeBySqlId.forEach(
(remainingRuntime, sqlId) =>
(queriesDCU += (sqlDCUBySqlId.get(sqlId) ?? 0) * (1 - remainingRuntime)),
);
queriesDCU = Math.min(queriesDCU, totalDCU);
Comment on lines +69 to +72
grouped[alert.name].savingsPercentage = Math.min(
100,
grouped[alert.name].savingsPercentage + (alert.savingsPercentage ?? 0),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants