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

Reduce rerenders of the entity component #6

Merged
merged 3 commits into from Oct 18, 2022
Merged

Conversation

IdrissMahjoubi
Copy link
Contributor

@IdrissMahjoubi IdrissMahjoubi commented Oct 18, 2022

Recalculating all entities on each update is heavy work, thinking about this further, we don't really need to calculate them and store them in the plugin state. the main idea was to update them all, but we do that already without having to calculate all of them on each update.

Performance improvements:

  • Only calculate unique entities
  • Skip non-atom nodes in the search
  • Prevent descending into entity nodes (since they can't have entity nodes content)
  • unique entities are now only update if the actual unique entities change
  • we compare the attributes to memoize the entities array instead of comparing using JSON.stringify

improve calculating unique entities
remove unnecessary calculations of all entities
Copy link
Member

@ronnyroeller ronnyroeller left a comment

Choose a reason for hiding this comment

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

LGTM (pls see comment). Also, pls explain a bit further in the PR description why these changes help with performance. Esp removing the helper (which is an API change) would be good to explain why it's required (i.e. what's the benefit of it).
Reading through the code it seems to do sth with avoiding the positions, which allows for better caching (presumable because changing content around the entities doesn't impact the cached data any longer).

src/entity-extension.ts Outdated Show resolved Hide resolved
src/unique-entities-are-same.ts Outdated Show resolved Hide resolved
src/unique-entities-are-same.ts Outdated Show resolved Hide resolved
@IdrissMahjoubi IdrissMahjoubi merged commit 15103be into main Oct 18, 2022
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.

None yet

2 participants