Improve Performance in Row Grouping#924
Merged
lukasmasuch merged 2 commits intoglideapps:mainfrom Jun 18, 2025
Merged
Conversation
|
@jassmith I'm curious if this has been reviewed? I'm also having issues with large resource clogs when using row grouping |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a fast lookup for group rows by introducing a rowIndex in each flattened group, replaces expensive path mapping in height/theming calcs with a map lookup, updates tests to assert the new behavior, and scales the example story to demonstrate performance at high row counts.
- Added
rowIndexto eachFlattenedRowGroupand built aflattenedRowGroupsMapfor O(1) row-header checks - Updated
rowHeightandgetRowThemeOverrideto use the new map instead ofmapRowIndexToPathfor better scrolling perf - Extended tests for grouping hooks and expanded the docs story to simulate 100 000 rows with many groups
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/data-editor/row-grouping.ts | Introduced rowIndex, built a lookup map, switched rowHeight to map-based logic |
| packages/core/test/row-grouping.test.ts | Added rowIndex assertions and new tests for theming and heights |
| packages/core/src/docs/examples/row-grouping.stories.tsx | Scaled story to 100 000 rows and auto-generated groups |
Comments suppressed due to low confidence (4)
packages/core/src/docs/examples/row-grouping.stories.tsx:37
- The story now renders 100 000 rows but still generates mock data for only 100 rows. Consider passing
rowsintouseMockDataGeneratorso that cell lookups beyond the first 100 don’t return undefined.
const { cols, getCellContent } = useMockDataGenerator(100);
packages/core/test/row-grouping.test.ts:237
- We have tests for non-group-header theming but no assertions for group headers (should return
options.themeOverrideor undefined). Adding a test for a known header row will lock in the intended behavior.
it("returns correct theme for non-group-header rows when some groups collapsed according to getRowThemeOverrideIn", () => {
packages/core/test/row-grouping.test.ts:355
- There are no tests for
rowNumberMapperoutput. Adding cases to verify mapping from visible row index to actual data index will ensure correct behavior when groups are collapsed or expanded.
describe("useRowGroupingInner - rows", () => {
packages/core/src/data-editor/row-grouping.ts:257
- [nitpick] The name
flattenedRowGroupsMapis a bit generic. Renaming to something likerowGroupByRowIndexorrowIndexToGroupMapcould improve readability and clarify that keys are row indices.
const flattenedRowGroupsMap = React.useMemo(() => {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is a performance bottleneck when using the row grouping feature. It is noticeable with a large number of rows and about >~20 groups or so.
Profiler showed that the call to
mapRowIndexToPathduring row height resolution takes most of the time, and it gets slower scrolling towards the end of the list.rowIndexproperty was added to identify the exact position of the group in the list. This allowed to create a map that then could be looked up to identify whether the row is a group row or not and resolve the height accordingly, avoiding the expensive call tomapRowIndexToPath.For further performance improvements, with
rowIndexproperty functions likerowNumberMapperOutandmapRowIndexToPathcould be changed to do a binary search, becausemapRowIndexToPathcan be used asmapperfunction in thegetCellContentconsumer code.scrolling profiler recordings:
before change

after

related to #823