PG1204 commented on code in PR #6213: URL: https://github.com/apache/texera/pull/6213#discussion_r3888058612
########## frontend/src/app/workspace/service/heatmap/heatmap-scoring.ts: ########## @@ -0,0 +1,159 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { OperatorPerformanceMetrics } from "../workflow-status/performance-metrics"; + +/** + * The three heat-map views. Each answers a different "where should I look?" + * question; see {@link rawMetricForView} for the per-operator cost each uses. + * String-valued so the selection serializes readably (e.g. to localStorage). + */ +export enum HeatmapView { + Runtime = "runtime", + // Seconds per output row — the reciprocal of throughput, so it grows (hotter) as throughput + // falls. Named directionally rather than "throughput" to match how the ramp reads. + TimePerRow = "time-per-row", + IoImbalance = "io-imbalance", +} + +/** + * Per-operator raw cost for a view, BEFORE normalization. Higher = hotter (more + * worth a look). + * + * - Runtime: data + control processing time — slower operators are hotter. + * - TimePerRow: seconds per output tuple — slow producers (low throughput) are + * hotter; no output -> 0 (cold). + * - IoImbalance: |out - in| / (out + in) — operators that drop OR amplify rows are + * hotter; a balanced operator or missing input -> 0 (cold). Normalized + * to [0, 1] so an extreme amplifier can't dominate the scale. + */ +export function rawMetricForView(metrics: OperatorPerformanceMetrics, view: HeatmapView): number { + switch (view) { + case HeatmapView.Runtime: + return metrics.dataProcessingTimeNs + metrics.controlProcessingTimeNs; + case HeatmapView.TimePerRow: { + const timeSec = (metrics.dataProcessingTimeNs + metrics.controlProcessingTimeNs) / 1e9; + return metrics.outputRows > 0 ? timeSec / metrics.outputRows : 0; Review Comment: fixed, i put the change in rawMetricForView itself rather than filtering in heatmapScores: it now returns undefined when the view isn't measurable (no output yet for Time/row, no input for I/O imbalance), so the canvas colors, the legend range, and the hover tooltip all inherit the same "no signal" handling, the operator paints the no-data color, stays out of the scale min/max, and shows "—" on hover. Also, updated the two specs that pinned the old behavior. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
