Skip to content

Slow table performance #8617

@Cyral

Description

@Cyral

Provide a general summary of the issue here

Tables from react-aria-components are slow to render and make the application UI feel laggy when an action triggers a re-render (e.g. sorting or filtering the table, changing rows, etc.)

🤔 Expected Behavior?

React Aria tables should not be significantly slower than a native table.

😯 Current Behavior

Table re-renders very slowly

💁 Possible Solution

No response

🔦 Context

I have some tables in my application displaying up to 500 rows, usually much less, but still up to that amount occasionally. HTML table elements can handle this fine, and virtualization isn't something to worry about yet. (Especially because these tables extend the page, e.g. are not constrained by a scrollable container that would allow for virtualization).

The application has various buttons that trigger re-renders of the table. For example, users can click a column to toggle the sort direction, use a react-aria menu to filter rows by value, and change the customer or date that is being displayed. When clicking on any of these actions, there is a noticeable delay when using React Aria's Table element (upwards of a second), which makes the UI feel laggy. When using a regular table element, the action takes effect immediately and feels snappy as expected.

🖥️ Steps to Reproduce

CodeSandbox: https://codesandbox.io/p/devbox/react-aria-table-performance-q5mrvq

With this sandbox you can toggle showing a native and react-aria table. Show the native table, and notice how clicking the generate button feels snappy. Then, click the toggle button to show the react-aria table, and you will feel a delay when replacing the rows with new rows (to simulate a filter or sort operation).

I also added a button to try the same experiment with a native list element and react-aria's GridList. You can see GridList is a bit slower, but not noticeable like it is with tables. This was to help determine if react-aria's internal collection elements/logic are to blame, or if it's more table related.

Performance Results - Dev
In dev mode, I am seeing:

  • 20ms for native table rendering
  • 200ms for react-aria table rendering (this is a ~12 frame delay which is very noticeable)

Performance Results - Prod Build
When compiling the react app and running it, I get:

  • 15ms for native table rendering
  • 110ms for react-aria table rendering

This is with 500 rows, a more extreme case, but you will see a few frame delay even with something like 50 rows. Also try clicking the headers to sort the columns, I think this "feels" more realistic and you can feel how the lag affects the perceived performance

This related issue suggests performance is better (if not resolved) in production builds. In the sandbox, open the terminal and run pnpm run build && pnpm run preview to open a production build. Performance is improved, but still notably laggy.

Version

1.11.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

MacOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    🔬 To Investigate / Verify

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions