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

[core] Simplify rows cache management #4933

Merged
merged 6 commits into from
May 20, 2022

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented May 19, 2022

While working on #4927, I noticed that our cache structure had some complex legacy structure that was not useful anymore.

  • Rename convertRowsPropToState into createRowsInternalCache
  • Don't have branch behavior in createRowsInternalCache that was basically "do nothing", only call it when we do want to regenerate the cache
  • Move all the utils in gridRowUtils
  • Make apiRef.current.unstable_caches.rows non nullable, like for the state we can rely on the fact that the stat init is being done before the rest
  • Flatten GridRowsInternalCache instead of having a value key storing almost everything
  • Clean the naming, no variable related to the cache should be named state (otherwise we can have misunderstandings between what leaves in the state and in the cache)

@flaviendelangle flaviendelangle added core Infrastructure work going on behind the scenes component: data grid This is the name of the generic UI component, not the React module! labels May 19, 2022
@flaviendelangle flaviendelangle self-assigned this May 19, 2022
@flaviendelangle flaviendelangle marked this pull request as ready for review May 19, 2022 11:47
@mui-bot
Copy link

mui-bot commented May 19, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 286.5 618.9 529.3 460.08 135.4
Sort 100k rows ms 667.4 1,140.4 667.4 928.16 167.89
Select 100k rows ms 154.4 271.9 196.6 202.12 40.455
Deselect 100k rows ms 113.2 209.4 178.8 168.34 38.766

Generated by 🚫 dangerJS against 5faa5bd

Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

Looks good to me but I never had to use the cache

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 19, 2022
@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 19, 2022
Copy link
Member

@m4theushw m4theushw left a comment

Choose a reason for hiding this comment

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

Much better with the values flattened.

Comment on lines 51 to 53
getRowId: DataGridProcessedProps['getRowId'];
loadingProp: DataGridProcessedProps['loading'];
rows: GridRowsProp;
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of making explicit that they are props? Pick could also be used.

Suggested change
getRowId: DataGridProcessedProps['getRowId'];
loadingProp: DataGridProcessedProps['loading'];
rows: GridRowsProp;
getRowIdProp: DataGridProcessedProps['getRowId'];
loadingProp: DataGridProcessedProps['loading'];
rowsProp: DataGridProcessedProps['rows'];

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@flaviendelangle flaviendelangle merged commit b6e1baa into mui:master May 20, 2022
@flaviendelangle flaviendelangle deleted the rows-cache branch May 20, 2022 07:49
flaviendelangle added a commit to flaviendelangle/mui-x that referenced this pull request May 20, 2022
alexfauquette pushed a commit to alexfauquette/mui-x that referenced this pull request Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants