Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Web portal: optimize jobs-table. #691

Merged
merged 3 commits into from
Jun 11, 2018
Merged

Conversation

Gerhut
Copy link
Member

@Gerhut Gerhut commented Jun 8, 2018

Here are some perf profiles:

500 jobs in Edge

  Request Process Draw Total Process + Draw
Origin 585 183 206 974 389
DataTables Ajax 594 34 249 877 283
Disable AutoWidth 604 45 198 847 243
Lazy calculate 609 46 176 831 222

500 jobs in Chrome

  Request Process Draw Total Process + Draw
Origin 595 91 31 717 122
DataTables Ajax 600 55 21 676 76
Disable AutoWidth 608 22 35 665 57
Lazy calculate 607 29 28 644 57

350,000 jobs in Edge

  Request Process Draw Total Process + Draw
Origin 3265 24351 612 28228 24963
DataTables Ajax 3155 16488 5343 24986 21831
Disable autoWidth 3064 17219 590 20873 17809
Lazy calculate 3002 10931 684 14617 11615

350,000 jobs in Chrome

  Request Process Draw Total Process + Draw
Origin 2818 10919 61 13798 10980
DataTables Ajax 3015 9393 56 12464 9449
Disable autoWidth 3084 9028 64 12176 9092
Lazy calculate 2961 2996 70 6027 3066

{type: 'num', targets: [3, 4]},
],
'deferRender': true,
'autoWidth': false,
Copy link
Contributor

@hwuu hwuu Jun 8, 2018

Choose a reason for hiding this comment

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

What does autoWidth mean and what will happen if it is disabled?

Copy link
Member Author

Choose a reason for hiding this comment

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

When autoWidth is enabled, DataTables will layout all possible rows (which means 350,000 rows in the benchmarks). collect widths of every cell and calculate the most suitable width of each column. When it is disabled, widths of each column will be decided by the browser, based on data in the current page. So this will cause different page have different column widths (but total will remain 100% of table width, which is set explicitly in CSS)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Sounds good.

},
});
'columns': [
{title: 'Job', data: 'name', render(name, type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this ‘render’ function play the trick of lazy calculation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly, render function, especially heavy "display" branch will be calculated only when it is needed to render to the page, which runs pageSize times(as well as "autoWidth" is disabled).

Copy link
Contributor

Choose a reason for hiding this comment

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

Marked and learnt :)

@hwuu
Copy link
Contributor

hwuu commented Jun 8, 2018

Could you explain why DataTables Ajax is faster than the original method (sending http request outside datatables object)? What optimization’s does it make?

@Gerhut
Copy link
Member Author

Gerhut commented Jun 8, 2018

@hwuu

Using DataTables Ajax will make the network request (which is Async and does not block the JavaScript event loop) & layout initialization run in parallel. Currently, layout initialization runs just after ajax response.

@hwuu
Copy link
Contributor

hwuu commented Jun 11, 2018

Please merge at will.

@Gerhut
Copy link
Member Author

Gerhut commented Jun 11, 2018

Due to big changes of code, merge after coming next release?

@fanyangCS
Copy link
Contributor

@Gerhut , you can merge the PR after approval and we have a window to test the code in INT.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants