From 61924e9130aaac2a0f7e4cce98d3354ec3cf21c2 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Sun, 9 Dec 2018 13:23:44 +0100 Subject: [PATCH] Explore: dont pass all rows to all rows, fixes profiler - react profiler seems to evaluate all props of all components down the tree - this becomes slow when 1000 rows are passed to 1000 rows and their labels - use getter function instead to ask for rows on demand --- public/app/features/explore/LogLabels.tsx | 17 +++++++++-------- public/app/features/explore/Logs.tsx | 16 ++++++++++------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/public/app/features/explore/LogLabels.tsx b/public/app/features/explore/LogLabels.tsx index eb9c39050f6..8aa1789017e 100644 --- a/public/app/features/explore/LogLabels.tsx +++ b/public/app/features/explore/LogLabels.tsx @@ -69,7 +69,7 @@ export class Stats extends PureComponent<{ class Label extends PureComponent< { - allRows?: LogRow[]; + getRows?: () => LogRow[]; label: string; plain?: boolean; value: string; @@ -98,13 +98,14 @@ class Label extends PureComponent< if (state.showStats) { return { showStats: false, stats: null }; } - const stats = calculateLogsLabelStats(this.props.allRows, this.props.label); + const allRows = this.props.getRows(); + const stats = calculateLogsLabelStats(allRows, this.props.label); return { showStats: true, stats }; }); }; render() { - const { allRows, label, plain, value } = this.props; + const { getRows, label, plain, value } = this.props; const { showStats, stats } = this.state; const tooltip = `${label}: ${value}`; return ( @@ -115,12 +116,12 @@ class Label extends PureComponent< {!plain && ( )} - {!plain && allRows && } + {!plain && getRows && } {showStats && ( LogRow[]; labels: LogsStreamLabels; plain?: boolean; onClickLabel?: (label: string, value: string) => void; }> { render() { - const { allRows, labels, onClickLabel, plain } = this.props; + const { getRows, labels, onClickLabel, plain } = this.props; return Object.keys(labels).map(key => ( -