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

Poor data performance in LWC applications #1899

Open
bmblb opened this issue Nov 18, 2020 · 3 comments
Open

Poor data performance in LWC applications #1899

bmblb opened this issue Nov 18, 2020 · 3 comments
Labels
bug Something isn't working salesforce Salesforce integration

Comments

@bmblb
Copy link

bmblb commented Nov 18, 2020

Reported here: https://www.bryntum.com/forum/viewtopic.php?f=51&t=15916&p=79421

We have noticed some performance issues when using the Grid in a Salesforce LWC with high volumes of data. Specifically, loading in 5000 records into the grid is taking roughly 20 seconds.

Our investigations have shown that this issue will occur when the data being set on the Grid is a proxied array from the Lightning Locker Service. This is due to a limitation with how proxied arrays are implemented in the Salesforce Lightning Locker Service. We have identified that when you access a single element from a proxied array, then the whole array is iterated over. This means that if you implement a standard

Code: Select all

for (let i = 0; i < count; i++)

loop over an array, then the total number of operations is count * count. For an array with 5000 elements, this results in 25,000,000 operations.

It is therefore much more efficient to iterate over arrays using other methods such as forEach() or map().

изображение

@bmblb bmblb added bug Something isn't working salesforce Salesforce integration labels Nov 18, 2020
@bmblb bmblb self-assigned this Nov 18, 2020
@bmblb
Copy link
Author

bmblb commented Nov 18, 2020

Potential workaround: clone data, provided by Salesforce, to a simple array of objects without side effects, using effective forEach, and then provide that data to the grid.

const data = [];
this.array.forEach(x => data.push(cloneRecord(x)))

new Grid({
  data : data
})

@bmblb
Copy link
Author

bmblb commented Nov 19, 2020

There are suggestions to replace data loading loop with a for..of. In case problem is only in iterating the incoming array, that could do the trick. Need to decide if for..of performance loss is tolerable, forEach loss is surely not.
Ideally this would be an LWC specific override.
изображение

@bmblb
Copy link
Author

bmblb commented Nov 20, 2020

UPD: Salesforce cannot fix the for loop:

Salesforce responded that they have been able to replicate the performance issue on their end but due to the fundamental design of their data proxying feature they are not going to do anything to fix it

@bmblb bmblb removed their assignment Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working salesforce Salesforce integration
Projects
None yet
Development

No branches or pull requests

1 participant