Commit 8f6a5ce
Optimize nested assign change tracking (#4225)
* Optimize nested assign change tracking
This avoids redundant nested assign change checks when a parent assign is already tracked. Overall render speedup depends on how much time a template spends in those checks.
Benchmarked template:
```heex
<nav class="actions">
<button disabled={!(@current_user && @current_user.permissions.projects.create)}>
New project
</button>
<button disabled={!(@current_user && @current_user.permissions.projects.archive)}>
Archive
</button>
<button disabled={!(@current_user && @current_user.permissions.billing.manage)}>
Billing
</button>
<button disabled={!(@current_user && @current_user.profile.account.plan.features.exports)}>
Export
</button>
<button disabled={!(@current_user && @current_user.profile.account.settings.security.sso)}>
SSO
</button>
</nav>
```
Benchmark measured the generated dynamic change-check path with assigns.__changed__ = %{} by repeatedly calling dynamic.(true).
| Run | Before | After | Speedup |
| --- | ---: | ---: | ---: |
| 1 | 24,913/s | 69,647/s | 2.80x |
| 2 | 22,138/s | 62,867/s | 2.84x |
| 3 | 19,470/s | 52,347/s | 2.69x |
* add test
---------
Co-authored-by: Steffen Deusch <steffen@deusch.me>1 parent 52a2e79 commit 8f6a5ce
2 files changed
Lines changed: 42 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
695 | | - | |
| 695 | + | |
| 696 | + | |
696 | 697 | | |
697 | 698 | | |
698 | 699 | | |
| |||
736 | 737 | | |
737 | 738 | | |
738 | 739 | | |
739 | | - | |
| 740 | + | |
740 | 741 | | |
741 | 742 | | |
742 | 743 | | |
743 | 744 | | |
744 | | - | |
745 | | - | |
| 745 | + | |
| 746 | + | |
746 | 747 | | |
747 | | - | |
| 748 | + | |
748 | 749 | | |
749 | 750 | | |
750 | | - | |
751 | | - | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
752 | 763 | | |
753 | 764 | | |
754 | 765 | | |
| |||
1025 | 1036 | | |
1026 | 1037 | | |
1027 | 1038 | | |
1028 | | - | |
| 1039 | + | |
1029 | 1040 | | |
1030 | 1041 | | |
1031 | 1042 | | |
| |||
1035 | 1046 | | |
1036 | 1047 | | |
1037 | 1048 | | |
1038 | | - | |
| 1049 | + | |
1039 | 1050 | | |
1040 | 1051 | | |
1041 | 1052 | | |
| |||
1047 | 1058 | | |
1048 | 1059 | | |
1049 | 1060 | | |
1050 | | - | |
| 1061 | + | |
1051 | 1062 | | |
1052 | 1063 | | |
1053 | 1064 | | |
| |||
1059 | 1070 | | |
1060 | 1071 | | |
1061 | 1072 | | |
1062 | | - | |
| 1073 | + | |
1063 | 1074 | | |
1064 | 1075 | | |
1065 | 1076 | | |
| |||
1138 | 1149 | | |
1139 | 1150 | | |
1140 | 1151 | | |
1141 | | - | |
| 1152 | + | |
1142 | 1153 | | |
1143 | 1154 | | |
1144 | 1155 | | |
| |||
1149 | 1160 | | |
1150 | 1161 | | |
1151 | 1162 | | |
1152 | | - | |
| 1163 | + | |
1153 | 1164 | | |
1154 | 1165 | | |
1155 | 1166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
462 | 480 | | |
463 | 481 | | |
464 | 482 | | |
| |||
0 commit comments