Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(dashboard): Improve perf of highlighting charts in scope of active filter #15424

Merged
merged 5 commits into from
Jun 29, 2021

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Jun 28, 2021

SUMMARY

Due to passing as a prop nativeFilters object (from redux), which changes on each focus/unfocus of native filters, from DashboardComponent, all dashboard components (tabs, rows, chart holders, dividers...) were being rerendered on each native filter focus. This PR optimizes that behaviour by passing nativeFilters only to Tabs component.
Also, I optimized rendering FiltersBadge component - due to passing complex objects as props, expensive calculations were being re-run multiple times.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

  1. Enable DASHBOARD_NATIVE_FILTERS feature flag
  2. Open a dashboard and add some native filters
  3. Focus on a native filter, verify that charts and tabs highlighting works as before (but it should be a bit faster on big dashboards, as only FilterFocusHighlight component gets rerendered).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

CC: @graceguo-supercat @villebro @junlincc

@codecov
Copy link

codecov bot commented Jun 28, 2021

Codecov Report

Merging #15424 (4eae3ca) into master (8205ea5) will increase coverage by 0.01%.
The diff coverage is 63.05%.

❗ Current head 4eae3ca differs from pull request most recent head 930108e. Consider uploading reports for the commit 930108e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15424      +/-   ##
==========================================
+ Coverage   76.99%   77.01%   +0.01%     
==========================================
  Files         975      974       -1     
  Lines       50634    50705      +71     
  Branches     6222     6238      +16     
==========================================
+ Hits        38988    39052      +64     
- Misses      11435    11440       +5     
- Partials      211      213       +2     
Flag Coverage Δ
javascript 71.78% <65.03%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rset-frontend/src/components/ErrorMessage/types.ts 100.00% <ø> (ø)
...src/components/FilterableTable/FilterableTable.tsx 82.26% <ø> (ø)
superset-frontend/src/components/Select/Select.tsx 0.00% <0.00%> (ø)
...frontend/src/dashboard/components/Header/index.jsx 67.15% <ø> (ø)
...c/dashboard/components/gridComponents/Markdown.jsx 82.82% <ø> (ø)
...d/src/dashboard/components/gridComponents/index.js 100.00% <ø> (ø)
...nd/src/dashboard/containers/DashboardComponent.jsx 100.00% <ø> (+7.69%) ⬆️
...uperset-frontend/src/explore/exploreUtils/index.js 66.45% <0.00%> (ø)
...ers/components/TimeGrain/TimeGrainFilterPlugin.tsx 0.00% <0.00%> (ø)
superset-frontend/src/setup/setupColors.ts 86.66% <0.00%> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8205ea5...930108e. Read the comment docs.

selectIndicatorsForChart(chartId, dashboardFilters, datasources, chart),
[
chartId,
JSON.stringify(chart),
Copy link
Member

Choose a reason for hiding this comment

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

Interesting dependency trick! Do we need to suppress linter warnings here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It turned out that it wasn't necessary here, but we do use that trick throughout our codebase. ESLint complains about that, but I think that we can live with that if we must use complex objects in the dependency array

dashboardLayout: Layout,
chartConfiguration: ChartConfiguration = {},
): Indicator[] => {
const chart = charts[chartId];
// no indicators before chart is rendered
if (chart.chartStatus !== 'rendered') return [];
Copy link
Member

Choose a reason for hiding this comment

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

This logic should probably be in a render function rather than in a selector

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@amitmiran137
Copy link
Member

#15420 could you also resolve that issue ?

Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

Awesome! The original work on this feature was kind of rushed so I'm really glad you were able to get these optimizations done!

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Great work! One minor problem noticed, other than that LGTM!

@kgabryje
Copy link
Member Author

#15420 could you also resolve that issue ?

Thanks for reporting that! I'll tackle it in a separate PR as it seems to be out of scope of this one

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@kgabryje kgabryje merged commit f109da4 into apache:master Jun 29, 2021
amitmiran137 pushed a commit that referenced this pull request Jul 4, 2021
…ve filter (#15424)

* perf(dashboard): Improve perf of highlighting charts in scope of active filter

* More optimizations

* fix tests

* Fix lint

* bug fix

(cherry picked from commit f109da4)
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
…ve filter (apache#15424)

* perf(dashboard): Improve perf of highlighting charts in scope of active filter

* More optimizations

* fix tests

* Fix lint

* bug fix
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
…ve filter (apache#15424)

* perf(dashboard): Improve perf of highlighting charts in scope of active filter

* More optimizations

* fix tests

* Fix lint

* bug fix
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
…ve filter (apache#15424)

* perf(dashboard): Improve perf of highlighting charts in scope of active filter

* More optimizations

* fix tests

* Fix lint

* bug fix
@mistercrunch mistercrunch added the 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XL v1.3 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants