Improve TreeTable performance
Hi, I tried to use Treetable to load json file which 4mb. While the whole browser is becomes so slow. The single selection of the one row will have wait 10 seconds to respond.
I record the profile from the chrome to record one table row selection time.
4.5 ms0.02 % 17257.1 ms64.38 % _View_TreeTable0.detectChangesInternalTreeTable.ngfactory.js:168 6.3 ms0.02 % 14.7 ms0.05 % _View_TreeTable2.detectChangesInternalTreeTable.ngfactory.js:386 1.4 ms0.01 % 2.9 ms0.01 % _View_TreeTable3.detectChangesInternalTreeTable.ngfactory.js:479 12.9 ms0.05 % 17207.4 ms64.19 % _View_TreeTable9.detectChangesInternalTreeTable.ngfactory.js:893 1100.0 ms4.10 % 17188.1 ms64.12 % _View_UITreeRow0.detectChangesInternalUITreeRow.ngfactory.js:81 0.2 ms0.00 % 11.6 ms0.04 % _View_UITreeRow1._handle_click_0_2UITreeRow.ngfactory.js:311 12.2 ms0.05 % 12.3 ms0.05 % _View_UITreeRow1._handle_mouseenter_0_0UITreeRow.ngfactory.js:297 3984.4 ms14.86 % 10854.1 ms40.49 % _View_UITreeRow1.detectChangesInternalUITreeRow.ngfactory.js:231 659.5 ms2.46 % 1450.3 ms5.41 % _View_UITreeRow2.detectChangesInternalUITreeRow.ngfactory.js:364 2104.0 ms7.85 % 3407.9 ms12.71 % _View_UITreeRow3.detectChangesInternalUITreeRow.ngfactory.js:439 527.0 ms1.97 % 16697.8 ms62.29 % _View_UITreeRow5.detectChangesInternalUITreeRow.ngfactory.js:573 396.4 ms1.48 % 16650.1 ms62.11 % _View_UITreeRow6.detectChangesInternalUITreeRow.ngfactory.js:637
My package json is
"dependencies": { "@angular/common": "^2.0.0", "@angular/compiler": "^2.0.0", "@angular/core": "^2.0.0", "@angular/forms": "^2.0.0", "@angular/http": "^2.0.0", "@angular/platform-browser": "^2.0.0", "@angular/platform-browser-dynamic": "^2.0.0", "@angular/router": "^3.0.0", "@angular/upgrade": "^2.0.0", "@angular2-material/button": "^2.0.0-alpha.8-2", "@angular2-material/card": "^2.0.0-alpha.8-2", "@angular2-material/core": "^2.0.0-alpha.8-2", "@angular2-material/icon": "^2.0.0-alpha.8-2", "@angular2-material/input": "^2.0.0-alpha.8-2", "@angular2-material/progress-bar": "^2.0.0-alpha.8-2", "@angular2-material/progress-circle": "^2.0.0-alpha.8-2", "@angular2-material/sidenav": "^2.0.0-alpha.8-2", "@angular2-material/toolbar": "^2.0.0-alpha.8-2", "@angular2-material/list": "^2.0.0-alpha.8-2", "angular2-in-memory-web-api": "0.0.20", "bootstrap": "^3.3.7", "chart.js": "^2.1.6", "core-js": "^2.4.1", "font-awesome": "^4.6.3", "material-icons": "^0.1.0", "primeng": "^1.0.0-beta.16", "es-module-loader": "^1.0.0", "reflect-metadata": "^0.1.8", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.39", "zone.js": "^0.6.25" }
Does treetable will improve the performance soon?
Thanks
Are your nodes all expanded by default?
I had similar problem with the Tree component in summer, solved it forking the Tree component and changing the strategy of changeDetection for databinding to ChangeDetectionStrategy.OnPush. In addition to this you have to make some changes, manually call changeDetectorRef.markForCheck () for example if you want to update the table from the model. With that i remember it could handle really large json (+100,000 nodes if i remember correctly). I can paste full source if you need. For more info you can check this http://blog.thoughtram.io/angular/2016/02/22/angular-2-change-detection-explained.html
Will be nice if prime-tree component support both strategies by configuration (it was my intention but I did not have time)
@galsas Can you please paste the code snippet for this? Especially, for changeDetectorRef.markForCheck(). What is "changeDetectorRef" variable of? Thank you.
I was able to put ChangeDetectionStrategy.OnPush and do changeDetectorRef.markForCheck() as well, but the tree is still slow for drag and drop when the json/data is big (2000+ nodes). How is everyone getting the slowness resolved? Please suggest!
Update -- enableProdMode helped with performance big time.
+1