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

Using the ngTable has slowed things down tremendously #3

Open
sebgoa opened this issue Oct 30, 2015 · 5 comments
Open

Using the ngTable has slowed things down tremendously #3

sebgoa opened this issue Oct 30, 2015 · 5 comments

Comments

@sebgoa
Copy link
Member

sebgoa commented Oct 30, 2015

we need to figure out what the issue is, if its inherent to ngTable we need to revert and find an alternative.
Right now the load time is terrible

@raynjamin
Copy link
Contributor

@Runseb TL;DR: The problem is not ngTable, you need to cache your service call results if you want faster rendering times. Alternatively, add a loading gif to the page to indicate the items are being refreshed.

I'm testing using the first tab, pods, but I believe that this same logic applies to other scenarios in which ngTable is being used.

The issue I'm seeing is definitely not inherent to ngTable, but rather the service that is giving ngTable data. In the refreshPods method, I replaced the service call to an array literal and the table came right up consistently.

I also noticed that the refreshPods method was getting called four times every time the page loaded. This was my initial suspicion as to the culprit of why the table was taking too long to load, but upon further investigation, once the first call to refreshPods() changes the podsReady variable to true, the view doesn't care about subsequent calls to refreshPods(). Nevertheless, it was concerning, so I figured out why.

The controller was being instantiated twice due to duplicated controller entries in the routes table as well as corresponding view partials. I removed all references to controllers from the routes file. Now we're down to 2 calls to refreshPods().

The second call is coming from the ws listener. For some reason, on page load, the websocket listener you have established is firing with data and resulting in another call to refreshPods().

Again, these aren't preventing the table from loading each time, but are patterns that will give you headaches.

@sebgoa
Copy link
Member Author

sebgoa commented Nov 6, 2015

Thanks a ton for checking this @raynjamin
The web socket connection is used to listen for changes in the underlying data.
If there is a change, the web socket will receive an event.

Ideally we could update all pods with the data received on the ws, but for now we are triggering a new refershPod().

Note that the refreshPod() should only be triggered if the ws receives something. it should not be triggered on every page load.

@raynjamin
Copy link
Contributor

So you have an option here.. currently refreshPods() is getting the latest data whenever the controller is instantiated, which is whenever the route calls for it.

I'm thinking the best bet would to change the controller to cache the list, and refreshWhatever() will asynchronously grab the latest data and update the list, while maybe having a progress indicator. Good?

@sebgoa
Copy link
Member Author

sebgoa commented Nov 6, 2015

sounds good, but updating the cached data based on what the ws sends might be a bit tricky/take time.

@raynjamin
Copy link
Contributor

I'll take a look. We might have to rethink how we uniquely identify the
entries in the table
On Fri, Nov 6, 2015 at 9:30 AM runseb notifications@github.com wrote:

sounds good, but updating the cached data based on what the ws sends might
be a bit tricky/take time.


Reply to this email directly or view it on GitHub
#3 (comment).

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

No branches or pull requests

2 participants