Repository navigation
Add interactive Graphite performance lab - #4885
mattleibow wants to merge 2 commits into
Conversation
Add a macOS Metal sample that compares Ganesh's serial command preparation with Graphite's worker-owned Recorders using the same onscreen workloads. Separate present rate from content-update rate, provide isolated A/B and explicitly contended side-by-side modes, and document the CPU recording, serialized submission, and GPU execution model. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 9c660d23-bc1a-4e17-b1f3-b6d1072ed0df
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 9c660d23-bc1a-4e17-b1f3-b6d1072ed0df
📦 Try the packages from this PRWarning Do not run these scripts without first reviewing the code in this PR. Step 1 — Download the packages bash / macOS / Linux: curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 4885PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 4885"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-4885/packages --name skiasharp-pr-4885More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-4885 |
|
📖 Documentation Preview The documentation for this PR has been deployed and is available at: 🔗 View Staging Site This preview will be updated automatically when you push new commits to this PR. This comment is automatically updated by the documentation staging workflow. |
📊 SkiaSharp benchmarks — PR #4885No ⭐ source-build ( |
📦 Artifact size reportPackages from this PR (build Total Packages
+39 package(s) unchanged (< 50.0 KB). Per-file changes
|
| File | Size |
|---|---|
runtimes/win-arm64/native/libGLESv2.pdb |
64.5 MB → 64.4 MB (🟢 −128.0 KB) |
runtimes/win-x86/native/libGLESv2.pdb |
67.3 MB → 67.2 MB (🟢 −80.0 KB) |
runtimes/win-x64/native/libGLESv2.pdb |
66.6 MB → 66.6 MB (🟢 −64.0 KB) |
Informational only — this never blocks the PR. Native binaries are labelled by os/arch.
Description
Adds Graphite Performance Lab, a native macOS/Metal sample for exploring what Skia Graphite parallel recording does—and does not—improve in an onscreen UI workload.
This began as a request to demonstrate a credible “10x” Graphite improvement. The investigation found that a blanket throughput claim would be misleading: Ganesh remains faster for many mature UI primitives, while Graphite’s architectural advantage is moving independent CPU command preparation off the UI/submission thread and making GPU pipeline behavior more predictable. The final app therefore reports the work honestly instead of optimizing a hidden microbenchmark.
Research trail and conclusions
DrawAtlasworkload. Parallel Recorders recovered roughly 20% on suitable vector scenes but hurt text-heavy scenes where shared glyph resources contend.MTKViewdrawables, real Metal command queues, onscreen composition, and interactive workloads.What parallel recording actually means
flowchart LR subgraph CPU["CPU: parallel command preparation"] W1["Worker 1<br/>SKCanvas.Draw*"] --> R1["Recorder 1<br/>Snap()"] W2["Worker 2<br/>SKCanvas.Draw*"] --> R2["Recorder 2<br/>Snap()"] WN["Worker N<br/>SKCanvas.Draw*"] --> RN["Recorder N<br/>Snap()"] end R1 --> C["AppKit / Context thread<br/>InsertRecording in dependency order<br/>record composition<br/>Submit"] R2 --> C RN --> C C --> Q["One ordered<br/>MTLCommandQueue"] Q --> G["GPU command processor"] G --> P["Many shader lanes,<br/>raster units, samplers,<br/>and fixed-function stages"]Each worker exclusively owns an
SKGraphiteRecorder, Graphite surface, and painter.Snap()produces a transferableSKGraphiteRecordingcontaining prepared Graphite tasks/resources—not a native Metal command buffer. The AppKit/Context thread serially inserts completed recordings, records the final tile composition, submits one ordered Metal stream, and presents the drawable.Multiple Recorders do not create multiple GPU queues. One ordered queue also does not mean a single GPU execution thread: queue ordering preserves dependencies while the GPU executes shaders and fixed-function stages across many hardware lanes. The useful overlap is:
The companion lifecycle/architecture documentation is in #4566.
UI-framework mapping
The default dashboard models an Uno/Avalonia-style retained UI compositor conceptually; it does not claim existing Uno controls use Graphite. Each tile represents an independently invalidated raster root such as a scrolling region, popup, chart, window, or expensive visual subtree. Workers prepare dirty roots, the Context thread inserts completed recordings in dependency order, and the compositor combines updated and cached roots into the window.
This pattern is strongest when work divides into several substantial independent roots. Dependencies, tiny jobs, shared text/image caches, or an already GPU-bound scene can erase the benefit.
Included workloads and controls
DrawRoundRect,DrawOval,DrawLine, andDrawArcstate churn.DrawAtlassprites—the clearest outright Graphite win in the earlier investigation.--screenshotmode captures the app-owned window without terminal screen-recording permission.Exploratory observations
Host: Apple M3 Pro (36 GB), macOS 26.6.1.
These are exploratory device-specific observations, not BenchmarkDotNet claims. The app exists so results can be reproduced across hardware, workload types, partition counts, and future Skia milestones.
Related issues
None. Related documentation: #4566.
Required skia PR
None.
Areas affected
binding/)externals/skia/src/c,include/c)Changes
None — sample-only change. No public API, ABI, package behavior, or existing application behavior changes.
Testing
dotnet cake --target=externals-download(no native/C API changes in this PR).origin/main(6386960c2a4) into the branch.net10.0-macos; build completed with 0 warnings and 0 errors..app, exercised isolated A/B and live rendering, and sampled the process. Runtime stacks showedgr_direct_context_flush_and_submit, six namedGraphite tile RecorderOS threads, GraphiteSnap/recording activity, Context insertion, and Metal presentation.ganesh-gl/DiagonalLinesmacOS golden mismatch reproduces independently and is unrelated to this sample-only diff; this branch changes no binding or test code.Screenshots (before / after)
Checklist
Changesabove lists all public API and behavioral changes (or "None.")