Skip to content

Conversation

lucas-koehler
Copy link
Contributor

Calculate Angular layout renderer child props via a pure pipe

Increase rendering and on change performance for all forms including nultiple layouts:

  • Avoid unnecessary recalculation of the child render props.
  • In turn, avoid some unnecessary change detection cycles in children.

Add service method to get global config

When querying the state from the JsonFormsAngularService via its getState method, the whole state is cloned.
This lead to a heavy performance penalty because the JsonFormsAbstractControl queried the state on every change detection cycle to get the global config. Thus, the whole state was cloned for every control on every change.
As the config is only a small part of the state, this problem can be alleviated by adding a getConfig method to the service that only clones the config.

  • Extend JsonFormsAngularService with a getConfig method that returns a clone of the global config
  • Use the new method in JsonFormsAbstractControl

Add service method to get locale

When querying the state from the JsonFormsAngularService via its getState method, the whole state is cloned.
This could lead to performance issues with the angular material renderer set because the NumberControlRenderer queried the state on every change detection cycle to get the locale. Thus, the whole state was cloned for every control of these types on every change.
To fix this, the JsonFormsAngularService now allows to query the locale directly without cloning the state

  • Add method getLocale to JsonFormsAngularService that does not clone the state
  • Use new method in NumberControlRenderer

Fix #1946

Increase rendering and on change performance for all forms including nultiple layouts:
* Avoid unnecessary recalculation of the child render props.
* In turn, avoid some unnecessary change detection cycles in children.
When querying the state from the `JsonFormsAngularService` via its `getState` method, the whole state is cloned.
This lead to a heavy performance penalty because the `JsonFormsAbstractControl` queried the state on every change detection cycle to get the global config. Thus, the whole state was cloned for every control on every change.
As the config is only a small part of the state, this problem can be alleviated by adding a getConfig method to the service that only clones the config.

* Extend `JsonFormsAngularService` with a `getConfig` method that returns a clone of the global config
* Use the new method in `JsonFormsAbstractControl`

Signed-off-by: Lucas Koehler <lkoehler@eclipsesource.com>
When querying the state from the `JsonFormsAngularService` via its `getState` method, the whole state is cloned.
This could lead to performance issues with the angular material renderer set because the `NumberControlRenderer` queried the state on every change detection cycle to get the locale. Thus, the whole state was cloned for every control of these types on every change.
To fix this, the `JsonFormsAngularService` now allows to query the locale directly without cloning the state

* Add method `getLocale` to `JsonFormsAngularService` that does not clone the state
* Use new method in `NumberControlRenderer`

Signed-off-by: Lucas Koehler <lkoehler@eclipsesource.com>
@lucas-koehler lucas-koehler requested a review from sdirix September 8, 2022 14:53
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 84.451% when pulling 867789c on angular-performance-improvements into 79e1c56 on master.

@FredUK
Copy link

FredUK commented Oct 24, 2022

Please can we get this reviewed by an approver? The angular component at the moment is very slow and laggy when we have more than a dozen components.

@sdirix
Copy link
Member

sdirix commented Oct 24, 2022

Hi @FredUK, yes will review soonish and if there are no issues this will be part of the next (pre)release.

Copy link
Member

@sdirix sdirix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Did not find any regression

@sdirix sdirix merged commit 708ab2d into master Oct 31, 2022
@sdirix sdirix deleted the angular-performance-improvements branch October 31, 2022 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Angular performance
4 participants