perf(ui): lazily render the alert list with Html.Lazy and Html.Keyed#5357
perf(ui): lazily render the alert list with Html.Lazy and Html.Keyed#5357wbh1 wants to merge 2 commits into
Conversation
The /alerts view rebuilt and re-diffed the entire alert-group tree on every model update, so interactions such as typing in the filter bar were sluggish when many alerts were loaded. Wrap the alert-group rendering in lazy4 so it is skipped while its inputs are unchanged, and render the group and alert lists with Html.Keyed keyed by group identity and alert fingerprint so list diffs are matched by identity rather than position. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Will Hegedus <whegedus@akamai.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Elm alert list view now memoizes the alert-groups section with ChangesKeyed/Lazy Rendering Optimization
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The v2 API can return two alert groups with an identical (receiver, labels) pair when sibling routes share a receiver and group_by but differ only by time intervals, so the group key derived from those fields is not guaranteed unique. Html.Keyed requires keys to be unique among siblings, so the collision could mis-associate DOM nodes. Render the group list with plain indexedMap again. The lazy4 wrapper still skips re-rendering while inputs are unchanged, and the alert list stays keyed by fingerprint, which is unique within a group. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Will Hegedus <whegedus@akamai.com>
Thanks @TheMeier! Good point. I dropped the group-level The main tweak that affects performance (the I also kept keyed rendering on the per-group alert list since fingerprint is unique within a group but can drop that if you'd prefer. |
The /alerts view rebuilt and re-diffed the entire alert-group tree on every model update, so interactions such as typing in the filter bar were sluggish when many alerts (10K+) were loaded.
This wraps the alert-group rendering in lazy4 so it is skipped while its inputs are unchanged, and render the group and alert lists with Html.Keyed keyed by group identity and alert fingerprint so list diffs are matched by identity rather than position.
It's similar to what is done for listing silences here.
Now, even though loading a 30MB+ response of all alerts is still slow on first load, typing in the filter box is at least responsive.
Pull Request Checklist
Please check all the applicable boxes.
Which user-facing changes does this PR introduce?