Cache the column list per table and requester - #206
Merged
Merged
Conversation
`columns.for(table)` walked the plugin chain and returned a new array on every call, so reading it once per rendered row cost O(rows x columns) per render. Nothing at the call site said so, and a row component that takes the table and reads the list itself has the same cost without looking like it. `createCache` participates in autotracking, so the list is recomputed when the columns, their order or their visibility change, and reused otherwise. Cowritten by Claude
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.
columns.for(table)returns a new array on every call, so reading it once per rendered row costs O(rows × columns) per render. Nothing at the call site says so, and a row component that takes@tableand reads the list itself has the same cost without looking like it — that is the shape I hit in our app.This caches the list per table and requester.
createCacheparticipates in autotracking, so it recomputes when the columns, their order or their visibility change.lib=a, 10k rows virtualized, 5 plugins, medians, one build per column:
The data path is unaffected.
@cachedonColumnReordering's own getters is not equivalent — that moves identity-swap 1.9 → 2.4 ms, which is why this caches at the accessor instead.test-app: 189 of 189 pass.tsc, prettier and eslint clean.Cowritten by Claude