You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(ui): significantly optimize form state component rendering, up to 96% smaller and 75% faster (#11946)
Significantly optimizes the component rendering strategy within the form
state endpoint by precisely rendering only the fields that require it.
This cuts down on server processing and network response sizes when
invoking form state requests **that manipulate array and block rows
which contain server components**, such as rich text fields, custom row
labels, etc. (results listed below).
Here's a breakdown of the issue:
Previously, when manipulating array and block fields, _all_ rows would
render any server components that might exist within them, including
rich text fields. This means that subsequent changes to these fields
would potentially _re-render_ those same components even if they don't
require it.
For example, if you have an array field with a rich text field within
it, adding the first row would cause the rich text field to render,
which is expected. However, when you add a second row, the rich text
field within the first row would render again unnecessarily along with
the new row.
This is especially noticeable for fields with many rows, where every
single row processes its server components and returns RSC data. And
this does not only affect nested rich text fields, but any custom
component defined on the field level, as these are handled in the same
way.
The reason this was necessary in the first place was to ensure that the
server components receive the proper data when they are rendered, such
as the row index and the row's data. Changing one of these rows could
cause the server component to receive the wrong data if it was not
freshly rendered.
While this is still a requirement that rows receive up-to-date props, it
is no longer necessary to render everything.
Here's a breakdown of the actual fix:
This change ensures that only the fields that are actually being
manipulated will be rendered, rather than all rows. The existing rows
will remain in memory on the client, while the newly rendered components
will return from the server. For example, if you add a new row to an
array field, only the new row will render its server components.
To do this, we send the path of the field that is being manipulated to
the server. The server can then use this path to determine for itself
which fields have already been rendered and which ones need required
rendering.
## Results
The following results were gathered by booting up the `form-state` test
suite and seeding 100 array rows, each containing a rich text field. To
invoke a form state request, we navigate to a document within the
"posts" collection, then add a new array row to the list. The result is
then saved to the file system for comparison.
| Test Suite | Collection | Number of Rows | Before | After | Percentage
Change |
|------|------|---------|--------|--------|--------|
| `form-state` | `posts` | 101 | 1.9MB / 266ms | 80KB / 70ms | ~96%
smaller / ~75% faster |
---------
Co-authored-by: James <james@trbl.design>
Co-authored-by: Alessio Gravili <alessio@gravili.de>
|`admin`| The configuration options for the Admin Panel. [More details](#admin-options). |
66
-
|`access`| Provide Access Control functions to define exactly who should be able to do what with Documents in this Collection. [More details](../access-control/collections). |
67
-
|`auth`| Specify options if you would like this Collection to feature authentication. [More details](../authentication/overview). |
68
-
|`custom`| Extension point for adding custom data (e.g. for plugins) |
69
-
|`disableDuplicate`| When true, do not show the "Duplicate" button while editing documents within this Collection and prevent `duplicate` from all APIs. |
70
-
|`defaultSort`| Pass a top-level field to sort by default in the Collection List View. Prefix the name of the field with a minus symbol ("-") to sort in descending order. Multiple fields can be specified by using a string array. |
71
-
|`dbName`| Custom table or Collection name depending on the Database Adapter. Auto-generated from slug if not defined. |
72
-
|`endpoints`| Add custom routes to the REST API. Set to `false` to disable routes. [More details](../rest-api/overview#custom-endpoints). |
73
-
|`fields`\*| Array of field types that will determine the structure and functionality of the data stored within this Collection. [More details](../fields/overview). |
74
-
|`graphQL`| Manage GraphQL-related properties for this collection. [More](#graphql)|
75
-
|`hooks`| Entry point for Hooks. [More details](../hooks/overview#collection-hooks). |
76
-
|`orderable`| If true, enables custom ordering for the collection, and documents can be reordered via drag and drop. Uses [fractional indexing](https://observablehq.com/@dgreensp/implementing-fractional-indexing) for efficient reordering. |
77
-
|`labels`| Singular and plural labels for use in identifying this Collection throughout Payload. Auto-generated from slug if not defined. |
78
-
|`enableQueryPresets`| Enable query presets for this Collection. [More details](../query-presets/overview). |
79
-
|`lockDocuments`| Enables or disables document locking. By default, document locking is enabled. Set to an object to configure, or set to `false` to disable locking. [More details](../admin/locked-documents). |
80
-
|`slug`\*| Unique, URL-friendly string that will act as an identifier for this Collection. |
81
-
|`timestamps`| Set to false to disable documents' automatically generated `createdAt` and `updatedAt` timestamps. |
82
-
|`typescript`| An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. |
83
-
|`upload`| Specify options if you would like this Collection to support file uploads. For more, consult the [Uploads](../upload/overview) documentation. |
84
-
|`versions`| Set to true to enable default options, or configure with object properties. [More details](../versions/overview#collection-config). |
85
-
|`defaultPopulate`| Specify which fields to select when this Collection is populated from another document. [More Details](../queries/select#defaultpopulate-collection-config-property). |
86
-
|`indexes`| Define compound indexes for this collection. This can be used to either speed up querying/sorting by 2 or more fields at the same time or to ensure uniqueness between several fields. |
87
-
|`forceSelect`| Specify which fields should be selected always, regardless of the `select` query which can be useful that the field exists for access control / hooks |
|`admin`| The configuration options for the Admin Panel. [More details](#admin-options). |
66
+
|`access`| Provide Access Control functions to define exactly who should be able to do what with Documents in this Collection. [More details](../access-control/collections). |
67
+
|`auth`| Specify options if you would like this Collection to feature authentication. [More details](../authentication/overview). |
68
+
|`custom`| Extension point for adding custom data (e.g. for plugins) |
69
+
|`disableDuplicate`| When true, do not show the "Duplicate" button while editing documents within this Collection and prevent `duplicate` from all APIs. |
70
+
|`defaultSort`| Pass a top-level field to sort by default in the Collection List View. Prefix the name of the field with a minus symbol ("-") to sort in descending order. Multiple fields can be specified by using a string array. |
71
+
|`dbName`| Custom table or Collection name depending on the Database Adapter. Auto-generated from slug if not defined. |
72
+
|`endpoints`| Add custom routes to the REST API. Set to `false` to disable routes. [More details](../rest-api/overview#custom-endpoints). |
73
+
|`fields`\*| Array of field types that will determine the structure and functionality of the data stored within this Collection. [More details](../fields/overview). |
74
+
|`graphQL`| Manage GraphQL-related properties for this collection. [More](#graphql)|
75
+
|`hooks`| Entry point for Hooks. [More details](../hooks/overview#collection-hooks). |
76
+
|`orderable`| If true, enables custom ordering for the collection, and documents can be reordered via drag and drop. Uses [fractional indexing](https://observablehq.com/@dgreensp/implementing-fractional-indexing) for efficient reordering. |
77
+
|`labels`| Singular and plural labels for use in identifying this Collection throughout Payload. Auto-generated from slug if not defined. |
78
+
|`enableQueryPresets`| Enable query presets for this Collection. [More details](../query-presets/overview). |
79
+
|`lockDocuments`| Enables or disables document locking. By default, document locking is enabled. Set to an object to configure, or set to `false` to disable locking. [More details](../admin/locked-documents). |
80
+
|`slug`\*| Unique, URL-friendly string that will act as an identifier for this Collection. |
81
+
|`timestamps`| Set to false to disable documents' automatically generated `createdAt` and `updatedAt` timestamps. |
82
+
|`typescript`| An object with property `interface` as the text used in schema generation. Auto-generated from slug if not defined. |
83
+
|`upload`| Specify options if you would like this Collection to support file uploads. For more, consult the [Uploads](../upload/overview) documentation. |
84
+
|`versions`| Set to true to enable default options, or configure with object properties. [More details](../versions/overview#collection-config). |
85
+
|`defaultPopulate`| Specify which fields to select when this Collection is populated from another document. [More Details](../queries/select#defaultpopulate-collection-config-property). |
86
+
|`indexes`| Define compound indexes for this collection. This can be used to either speed up querying/sorting by 2 or more fields at the same time or to ensure uniqueness between several fields. |
87
+
|`forceSelect`| Specify which fields should be selected always, regardless of the `select` query which can be useful that the field exists for access control / hooks |
88
88
89
89
_\* An asterisk denotes that a property is required._
0 commit comments