[GUI] Avoid per-command clip array cloning and redundant SKPath allocations in SurfaceRecorder
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- performance
Research direction
Read sources/Cairo/wrapper/SurfaceRecorder.cs and sources/Cairo/wrapper/RecordedGuiDrawing.cs, then inspect RecomposeBenchmark to understand the reported GPU and CPU allocation measurements. The issue proposes sharing clip snapshots and fast paths for axis-aligned rectangles, but a linked pull request is already open. Done means reducing the reported allocations while preserving recorded drawing behavior.
Written by the indexing model from the issue text.
Description
Problem
In RecomposeBenchmark, 10 inventory recompositions allocate 117.5 MB on the managed heap in Skia GPU mode (~3.9 MB per recompose, exceeding the 78.6 MB allocated by the CPU fallback path). Key contributors in sources/Cairo/wrapper/SurfaceRecorder.cs and sources/Cairo/wrapper/RecordedGuiDrawing.cs include:
CaptureClips()andSave()cloneclips.ToArray()across recorded draw commands even when the active clip stack has not changed since the previous command.SurfaceRecorder.TrySealcopiescommands.ToArray()andresources.ToArray().- Simple geometry primitives (axis-aligned rectangles and lines) allocate full
SKPathclones for recording and replay.
Proposed Fix
- Use copy-on-write sharing for
RecordedGuiClip[]snapshots so consecutive draw commands that share the same clip state reference the same immutable array instance. - Fast-path axis-aligned rectangle fill/stroke/clip commands in
SurfaceRecorderandRecordedGuiDrawingwithout allocating intermediateSKPathinstances.
- Dominant language
- C#
- Stars
- 22
- Forks
- 4
- Avg merge
- 1h 11m
- Merged PRs (30d)
- 40
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from StratumServer/Optimum
-
complexity: hard enhancement performance rendering
Difficulty 5/5 Over a week Newbie friendliness 25/100
StratumServer/Optimum#230 ·
Maintainers usually reply within 1 day
-
complexity: easy performance rendering
Difficulty 4/5 3-5 days Newbie friendliness 52/100
StratumServer/Optimum#228 ·
Maintainers usually reply within 1 day
-
complexity: medium performance rendering
Difficulty 5/5 Over a week Newbie friendliness 32/100
StratumServer/Optimum#227 ·
Maintainers usually reply within 1 day
-
complexity: medium enhancement rendering
Difficulty 5/5 Over a week Newbie friendliness 24/100
StratumServer/Optimum#226 ·
Maintainers usually reply within 1 day
-
complexity: hard performance rendering
Difficulty 5/5 Over a week Newbie friendliness 35/100
StratumServer/Optimum#225 ·
Maintainers usually reply within 1 day
All issues in StratumServer/Optimum
Similar issues
-
Incorrect loop bound in SizeOptIListSelectIterator.ToListPossibly taken @equmagg claimed this today. Openarea-System.Collections untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
dotnet/runtime#137126 · 1 comment ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 1/5 1-3 hours Newbie friendliness 76/100
Azure/azure-sdk-for-net#64658 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dotnet/aspnetcore#70370 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NethermindEth/nethermind#15684 ·
Maintainers usually reply within 1 day
-
area/ai-assistant squad/flyt
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Altinn/altinn-studio#21798 ·
Maintainers usually reply within 1 day