Perf: Eliminate per-frame List allocations in SunburstChart SeriesView.OnDraw#374
Merged
Merged
Conversation
…w.OnDraw Replace OrderBy().ToList() / .ToList() allocations on every draw frame with zero-allocation two-pass iteration using indexed for-loops. Before: Every OnDraw call allocated a new List via LINQ (.ToList() or OrderBy().ToList()), creating GC pressure on every render frame. After: Iterate the existing Segments collection directly with for-loops. When selection is active, use two passes (unselected first, selected on top) to maintain the same visual z-order without any allocation. Also removes the now-unused System.Linq import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Removed exception related unit test cases
VimalaThirumalaikumar
approved these changes
Jun 6, 2026
VimalaThirumalaikumar
left a comment
There was a problem hiding this comment.
Source-level changes are fine.
Removed the AI suggested unit test cases, as they were only validating whether an exception was raised. Since the newly added test cases are not functional tests, they have been removed.
SaiyathAliFathima
approved these changes
Jun 6, 2026
SaiyathAliFathima
left a comment
Collaborator
There was a problem hiding this comment.
Changes are fine.
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Root Cause of the Issue
The
SeriesView.OnDrawmethod in the SunburstChart control allocates a newList<SunburstSegment>on every render frame via LINQ (.OrderBy().ToList()when selection is active, or.ToList()otherwise). SinceOnDrawis called at 60+ fps during animations and interactions, this creates significant GC pressure and unnecessary allocations in a hot path.Description of Change
forloops that iterate the existingSegmentscollection directly.System.Linqusing directive since LINQ is no longer used in this file.Performance Impact
Issues Fixed
N/A — Proactive performance improvement identified via code analysis.
Screenshots
N/A — Internal rendering logic change with no visual difference.