Improve Angular digest performance by watching dtOptions more shallowly #144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
$watch
with third argument set totrue
causes a deep search for changes on every$digest
cycle. Meaning every time any Angular event happens (ng-clicks, etc.), the entire array, each of it's children, it's children's children, and so forth gets compared to a cached copy.This seems unnecessary for
dtOptions
, and can cause some slowdown when dealing with very large datasets (or otherwise just if the dataset has a lot of deeply nested fields to traverse).I left
columns
andcolumnDefs
in full watch because they're typically much smaller, didn't seem as immediately important.This change allowed several pages on a current project of mine to move from ~750ms to ~20ms digest cycles.
Flame charts from Chrome profiling to show the difference attached below:
Before:
After: