You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "kgabryje (via GitHub)" <gi...@apache.org> on 2024/11/18 12:50:46 UTC
[PR] perf: Improve dashboard performance by decreasing rerenders [superset]
kgabryje opened a new pull request, #30958:
URL: https://github.com/apache/superset/pull/30958
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] 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
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on PR #30958:
URL: https://github.com/apache/superset/pull/30958#issuecomment-2483482704
These PRs from Kamil always make me soo happy! ❤️
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "fisjac (via GitHub)" <gi...@apache.org>.
fisjac commented on code in PR #30958:
URL: https://github.com/apache/superset/pull/30958#discussion_r1847118166
##########
superset-frontend/src/dashboard/components/SyncDashboardState/index.tsx:
##########
@@ -55,36 +52,43 @@ const updateDashboardTabLocalStorage = (
const dashboardsContexts = getDashboardContextLocalStorage();
setItem(LocalStorageKeys.DashboardExploreContext, {
...dashboardsContexts,
- [dashboardPageId]: dashboardContext,
+ [dashboardPageId]: { ...dashboardContext, dashboardPageId },
});
};
+const selectDashboardContextForExplore = createSelector(
+ [
+ (state: RootState) => state.dashboardInfo.metadata,
+ (state: RootState) => state.dashboardInfo.id,
+ (state: RootState) => state.dashboardState?.colorScheme,
+ (state: RootState) => state.nativeFilters?.filters,
+ (state: RootState) => state.dataMask,
+ ],
+ (metadata, dashboardId, colorScheme, filters, dataMask) => {
+ // Building nativeFilters object without spreading in reduce
+ const optimizedNativeFilters = Object.keys(filters).reduce((acc, key) => {
Review Comment:
Nice improvement. Nit: should this be named `nativeFilters` outside of the context of this PR, I don't think "optimized" make sense.
##########
superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx:
##########
@@ -593,33 +634,7 @@ const DashboardBuilder: FC<DashboardBuilderProps> = () => {
maxWidth={OPEN_FILTER_BAR_MAX_WIDTH}
initialWidth={OPEN_FILTER_BAR_WIDTH}
>
- {adjustedWidth => {
- const filterBarWidth = dashboardFiltersOpen
- ? adjustedWidth
- : CLOSED_FILTER_BAR_WIDTH;
- return (
- <FiltersPanel
- width={filterBarWidth}
- hidden={isReport}
- data-test="dashboard-filters-panel"
- >
- <StickyPanel ref={containerRef} width={filterBarWidth}>
- <ErrorBoundary>
- <FilterBar
- orientation={FilterBarOrientation.Vertical}
- verticalConfig={{
- filtersOpen: dashboardFiltersOpen,
- toggleFiltersBar: toggleDashboardFiltersOpen,
- width: filterBarWidth,
- height: filterBarHeight,
- offset: filterBarOffset,
- }}
- />
- </ErrorBoundary>
- </StickyPanel>
- </FiltersPanel>
- );
- }}
+ {renderChild}
Review Comment:
Nice!
##########
superset-frontend/src/dashboard/components/DashboardBuilder/state.ts:
##########
@@ -43,24 +43,28 @@ export const useNativeFilters = () => {
const nativeFiltersEnabled =
canEdit || (!canEdit && filterValues.length !== 0);
- const requiredFirstFilter = filterValues.filter(
- filter => filter.requiredFirst,
+ const requiredFirstFilter = useMemo(
+ () => filterValues.filter(filter => filter.requiredFirst),
+ [filterValues],
);
const dataMask = useNativeFiltersDataMask();
- const missingInitialFilters = requiredFirstFilter
- .filter(({ id }) => dataMask[id]?.filterState?.value === undefined)
- .map(({ name }) => name);
+ const missingInitialFilters = useMemo(
+ () =>
+ requiredFirstFilter
+ .filter(({ id }) => dataMask[id]?.filterState?.value === undefined)
+ .map(({ name }) => name),
+ [requiredFirstFilter, dataMask],
+ );
+
const showDashboard =
isInitialized ||
!nativeFiltersEnabled ||
missingInitialFilters.length === 0;
- const toggleDashboardFiltersOpen = useCallback(
- (visible?: boolean) => {
- setDashboardFiltersOpen(visible ?? !dashboardFiltersOpen);
- },
- [dashboardFiltersOpen],
- );
+
+ const toggleDashboardFiltersOpen = useCallback((visible?: boolean) => {
+ setDashboardFiltersOpen(prevState => visible ?? !prevState);
+ }, []);
Review Comment:
nice!
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on PR #30958:
URL: https://github.com/apache/superset/pull/30958#issuecomment-2484062854
/testenv up
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje commented on PR #30958:
URL: https://github.com/apache/superset/pull/30958#issuecomment-2486680361
@villebro unfortunately the ephemeral environments have been broken for some time now 🙁
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje commented on PR #30958:
URL: https://github.com/apache/superset/pull/30958#issuecomment-2486707449
Neat AI summary provided by @rusackas 🙂
Key changes include:
1. Memoization optimizations:
- Added useMemo/useCallback hooks throughout components
- Memoized selectors with createSelector
- Reduced unnecessary re-renders
2. Component modernization:
- Converted class components to functional components with hooks
- Removed redundant Redux connections in favor of useSelector/useDispatch
- Simplified prop passing and state management
3. Architecture improvements:
- Moved Chart container logic directly into component
- Simplified data flow and prop drilling
- Better separation of concerns
The main potential risk areas to watch:
1. FilterBar and native filtering changes - ensure filter state management remains consistent with previous behavior
2. Chart component refactoring - verify chart rendering and updates work correctly, especially around:
- Data loading states
- Filter interactions
- Resize handling
3. Tab/Dashboard navigation - confirm tab state management and routing remains intact
Recommend thorough testing of:
- Filter interactions
- Chart loading/rendering
- Dashboard navigation
- Cross-filter functionality
- Dashboard state persistence
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30958:
URL: https://github.com/apache/superset/pull/30958#issuecomment-2486621503
@villebro Ephemeral environment spinning up at http://35.91.239.242:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje closed pull request #30958: perf: Improve dashboard performance by decreasing rerenders
URL: https://github.com/apache/superset/pull/30958
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #30958:
URL: https://github.com/apache/superset/pull/30958#discussion_r1861005039
##########
superset-frontend/src/dashboard/components/gridComponents/Chart.jsx:
##########
@@ -32,13 +34,30 @@ import {
LOG_ACTIONS_EXPORT_XLSX_DASHBOARD_CHART,
LOG_ACTIONS_FORCE_REFRESH_CHART,
} from 'src/logger/LogUtils';
-import { areObjectsEqual } from 'src/reduxUtils';
import { postFormData } from 'src/explore/exploreUtils/formData';
import { URL_PARAMS } from 'src/constants';
+import { enforceSharedLabelsColorsArray } from 'src/utils/colorScheme';
import SliceHeader from '../SliceHeader';
import MissingChart from '../MissingChart';
-import { slicePropShape, chartPropShape } from '../../util/propShapes';
+import {
+ addDangerToast,
+ addSuccessToast,
+} from '../../../components/MessageToasts/actions';
+import {
+ setFocusedFilterField,
+ toggleExpandSlice,
+ unsetFocusedFilterField,
+} from '../../actions/dashboardState';
+import { changeFilter } from '../../actions/dashboardFilters';
+import { refreshChart } from '../../../components/Chart/chartAction';
Review Comment:
Can we use absolute paths?
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on PR #30958:
URL: https://github.com/apache/superset/pull/30958#issuecomment-2486599864
/testenv up
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] perf: Improve dashboard performance by decreasing rerenders [superset]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30958:
URL: https://github.com/apache/superset/pull/30958#issuecomment-2484078401
@villebro Ephemeral environment spinning up at http://52.38.80.189:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org