Skip to content

OBPIH-6742 Performance: Virtualize table on receiving workflow#4935

Merged
awalkowiak merged 2 commits intodevelopfrom
OBPIH-6742
Nov 12, 2024
Merged

OBPIH-6742 Performance: Virtualize table on receiving workflow#4935
awalkowiak merged 2 commits intodevelopfrom
OBPIH-6742

Conversation

@alannadolny
Copy link
Collaborator

✨ Description of Change

A concise summary of what is being changed. Please provide enough context for reviewers to be able to understand the change and why it is necessary. If the issue/ticket already provides enough information, you can put "See ticket" as the description.

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-6742

Description:

The virtualization in this workflow uses one container as one “row”. This means that if we have more containers the better the performance of this table will be. So, when we have everything under one container all lines will be loaded at once, so there won’t be any performance changes. That implies that in the worst case, there is no improvement, but in the best case there will be rather big improvement. As an additional thing - we should remember that the current implementation of our virtualized components is not ideal, so when we are scrolling a little bit faster we will see empty lines, but it will be loaded in a few milliseconds.

Reminder: performance issues in this workflow are caused by rendering too many DOM elements simultaneously (table renders too many rows). Phases of detecting changes in React look the following:

  • triggering phase - at this step React detects changes in states, so he knows that there is a probability for changes in displaying content. In our case, it is marking checkboxes, adding comments, etc.

  • rendering phase - at this step, React calls all of the nested components and checks whether any of the properties were changed, and then React applies them to the virtual DOM.

  • commit phase - at this step, React applies all of the required changes to the DOM using a minimal amount of operations.

To make the measures more relevant I measured the calculation times a few times and then I calculated the average time of the operations. All of the operations were triggered on a receiving page with 200 items. Everything is split between containers including from 1 item to 11 at max.

To compare the changes in rendering components I created a table:

Action Before virtualization After virtualization
Initial page loading 18.21s (includes fetching time) 6.13s (includes fetching time)
Autofill quantities (Checking checkboxes) 12.09s 1.76s
Adding comment 22.86s 3.41s
Changing “Receiving now” quantity 17.55s 2.64s

@alannadolny alannadolny self-assigned this Nov 12, 2024
@github-actions github-actions bot added the domain: frontend Changes or discussions relating to the frontend UI label Nov 12, 2024
@ewaterman
Copy link
Member

thanks for the in-depth explanation! It definitely makes sense to want to reload rows one at a time instead of the whole table at once. Great job!

@awalkowiak awalkowiak merged commit 677abb2 into develop Nov 12, 2024
@awalkowiak awalkowiak deleted the OBPIH-6742 branch November 12, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: frontend Changes or discussions relating to the frontend UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants