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

perf: faster page navigation by speeding up createClientConfig. Up to 100x faster #9457

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AlessioGr
Copy link
Member

@AlessioGr AlessioGr commented Nov 22, 2024

If you had a lot of fields and collections, createClientConfig would be extremely slow, as it was copying a lot of memory. In my test config with a lot of fields and collections, it took 4 seconds(!!).

And not only that, it also ran between every single page navigation.

This PR significantly speeds up the createClientConfig function. In my test config, its execution speed went from 4 seconds to 50 ms.
Additionally, createClientConfig is now properly cached in both dev & prod. It no longer runs between every single page navigation. Even if you trigger a full page reload, createClientConfig will be cached and not run again. Despite that, HMR remains fully-functional.

This will make payload feel noticeably faster for large configs - especially if it contains a lot of richtext fields, as it was previously deep-copying the relatively large richText editor configs over and over again.

Before - 40 sec navigation speed

CleanShot.2024-11-22.at.15.35.52.mp4

After - 1 sec navigation speed

CleanShot.2024-11-22.at.15.31.47.mp4

Todo

  • Implement ClientSchemaMap and cache it, to remove createClientField call in our form state endpoint
  • Enable schemaMap caching for dev
  • Cache lexical clientField generation, or add it to the parent clientConfig

richText changes

Red: old.
Gree: new

CleanShot 2024-11-22 at 19 49 45@2x

…emoving deep copying and building client config from the ground up instead
…ly runs once, and does not re-run when refreshing the page or navigating. HMR still works despite caching in dev
… comes back, we should run it in the background
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant