Merge ~blr/maas:performance-tweaks into maas:master

Proposed by Kit Randel
Status: Merged
Approved by: Kit Randel
Approved revision: 01dfd83597221e7882318204d42e66675c550295
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~blr/maas:performance-tweaks
Merge into: maas:master
Diff against target: 62 lines (+11/-2)
3 files modified
src/maasserver/static/js/angular/directives/machines_table.js (+9/-1)
src/maasserver/static/partials/machines-table.html (+1/-1)
src/maasserver/static/partials/nodes-list.html (+1/-0)
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+366968@code.launchpad.net

Commit message

Improve initial load performance of machine listing after data has been loaded (e.g. when navigating from other tabs).

Description of the change

This branch make several performance improvements to the machine listing view:

1. Add a guard to the machines $watch expression (and a new loading binding to the machines-table directive), only updating grouping on status changes after machines have finished loading.

2. Add a track by expression for the parent groupby ng-repeat.

3. Clear machines from the manager on init. While this may feel like a step backwards, with all cached machines the initial digest cycle is slow and grows linearly slower with the number of machines. When the cached machine data is available to the directive, angular will block until the digest cycle is complete, leaving the user with an unresponsive UI. This way at least, the user sees a heading, some markup and a loading indicator. Unfortunately we are not likely to workaround this inefficiency in the performance of nested ng-repeats without a rewrite.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/static/js/angular/directives/machines_table.js b/src/maasserver/static/js/angular/directives/machines_table.js
2index 56666d2..89b7ff1 100644
3--- a/src/maasserver/static/js/angular/directives/machines_table.js
4+++ b/src/maasserver/static/js/angular/directives/machines_table.js
5@@ -22,6 +22,7 @@ function maasMachinesTable(
6 return {
7 restrict: "E",
8 scope: {
9+ loading: "=",
10 search: "=",
11 groupByLabel: "=",
12 actionOption: "=",
13@@ -72,6 +73,11 @@ function maasMachinesTable(
14 NodeStatus.TESTING
15 ];
16
17+ // This is an performance optimisation to unblock initial rendering,
18+ // otherwise when there are many machines, due to numerous nested
19+ // ng-repeats the initial digest cycle is slow and the UI is
20+ // blocked on first navigation.
21+ MachinesManager.clear();
22 const machines = MachinesManager.getItems();
23
24 // Scope variables.
25@@ -537,9 +543,11 @@ function maasMachinesTable(
26 }
27
28 // Check if status has changed, then run function to regroup machines
29+ // if machines have been loaded
30 if (
31 newMachine.status !== oldMachine.status &&
32- $scope.groupByLabel !== "none"
33+ $scope.groupByLabel !== "none" &&
34+ !$scope.loading
35 ) {
36 $scope.updateGroupedMachines($scope.groupByLabel);
37 }
38diff --git a/src/maasserver/static/partials/machines-table.html b/src/maasserver/static/partials/machines-table.html
39index 062e784..d5e9aab 100644
40--- a/src/maasserver/static/partials/machines-table.html
41+++ b/src/maasserver/static/partials/machines-table.html
42@@ -53,7 +53,7 @@
43 </tr>
44 </thead>
45 </table>
46-<table data-ng-repeat="group in groupedMachines" data-ng-if="group.machines.length" class="p-table--machines" role="grid">
47+<table data-ng-repeat="group in groupedMachines track by group.label" data-ng-if="group.machines.length" class="p-table--machines" role="grid">
48 <thead>
49 <tr
50 class="p-table__group p-table__row"
51diff --git a/src/maasserver/static/partials/nodes-list.html b/src/maasserver/static/partials/nodes-list.html
52index 27813fa..17c5781 100644
53--- a/src/maasserver/static/partials/nodes-list.html
54+++ b/src/maasserver/static/partials/nodes-list.html
55@@ -982,6 +982,7 @@ sudo maas-rack register --url {$ tabs.controllers.registerUrl $} --secret {$ tab
56 </div>
57 <div>
58 <maas-machines-table id="machines-listing"
59+ loading="loading"
60 search="tabs.machines.search"
61 group-by-label="tabs.machines.groupByLabel"
62 action-option="tabs.machines.actionOption"

Subscribers

People subscribed via source and target branches