-
Notifications
You must be signed in to change notification settings - Fork 432
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
perf(core): memoize prepareFormState
#7498
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work and really impressive numbers @ricokahler – left a few comments, mostly minor stuff.
packages/sanity/src/core/form/store/conditional-property/createCallbackResolver.ts
Outdated
Show resolved
Hide resolved
f26a12f
to
47cd411
Compare
8c7b898
to
199df15
Compare
199df15
to
35c17a7
Compare
Component Testing Report Updated Sep 17, 2024 6:29 PM (UTC) ✅ All Tests Passed -- expand for details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-iterating Bjoerge's approval after the rebase and change to make tests pass!
Description
This PR introduces memoization to the
prepareFormState
function to significantly improve performance, especially for complex documents with multiple large objects in arrays.Key changes:
prepareFormState
and its sub-functions for improved performance for complex documents, with up to 10x improvements in some caseshidden
andreadOnly
. TheirStateTree
s are calculated outside ofprepareFormState
to remove the dependency of thedocument
to the inputs ofprepareFormState
.This addresses performance issues with form state computation, particularly for large and complex documents.
Note: Dependes on #7407
What to review
prepareFormState
Testing
Automated tests are not yet complete. Manual testing has been performed:
Before:
After:
TODO: Complete automated tests
Notes for release
This change introduces significant performance improvements for form state computation in Sanity, especially for complex documents:
Limitations:
hidden
andreadOnly
states still adds significant computation time, especially for very large documentsNote: This is a significant performance enhancement that will benefit most users, especially those working with complex document structures.