perf: Chart control performance improvements#390
Open
PaulAndersonS wants to merge 2 commits into
Open
Conversation
- Replace LINQ .Reverse() with backward for loop in SfCartesianChart - Replace .Where().ToList() with direct iteration in CartesianChartArea - Cache .Values.ToList() outside loops in CartesianChartArea - Replace LINQ query syntax with pre-sized List loops in CartesianSeries - Remove .Where().ToList() allocation in CartesianSeries.UpdateSbsSeries - Cache yPropertyAccessor.Count in data binding loops in ChartSeriesPartial - Cache StrokeDashArray.ToFloatArray() result in AreaSegment - Replace multiple LINQ .Min()/.Max() scans with single loop in AreaSegment.SetData Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
EPS87
approved these changes
Jun 8, 2026
EPS87
approved these changes
Jun 8, 2026
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
Multiple hot paths in the Chart control allocate unnecessary temporary collections (via LINQ
.Reverse(),.Where().ToList(),.Values.ToList(), LINQ query syntax) and perform redundant scans (multiple.Min()/.Max()calls) on every frame or data update.Description of Change
This PR implements 8 performance improvements targeting allocation reduction and redundant computation elimination in the Chart control:
.Reverse()with backwardforloopSfCartesianChart.cs.Where().ToList()with direct iterationCartesianChartArea.cs.Values.ToList()outside loopsCartesianChartArea.csyPropertyAccessor.Countin data binding loopsChartSeriesPartial.csList<double>loopsCartesianSeries.cs.Where().ToList()allocation inUpdateSbsSeriesCartesianSeries.csStrokeDashArray.ToFloatArray()result per segmentAreaSegment.cs.Min()/.Max()/.Where()scans with single loopAreaSegment.csKey benefits:
.Reverse()and.ToList()in hit-testing and rendering pathsSetDatafrom 5+ collection scans to a single passIssues Fixed
Performance improvement - no specific issue
Screenshots
N/A - performance-only changes with no visual impact