Skip to content

Latest commit

 

History

History
182 lines (155 loc) · 13.2 KB

File metadata and controls

182 lines (155 loc) · 13.2 KB

Performance Benchmarks

This page shows the latest dispatch-throughput and cross-library comparison numbers for DxMessaging. The tables are auto-generated by CI: every pull request and push re-runs the benchmark suite with the .NET Standard 2.1 API profile and a Release code-optimization build, then renders the results into the AUTOGENERATED region below. Throughput is measured in a built Standalone player under IL2CPP in the Release configuration (no development build, Release C++ code generation) -- the ahead-of-time backend and build shape shipped games actually run. The published workflow no longer adds an editor-only Mono leg for allocation data.

These numbers are for orientation, not a leaderboard. Real-world performance depends on what your handlers actually do; the benchmarks measure raw dispatch cost with minimal handler work. For the full methodology, CI mechanics, baseline capture, the regression smoke gate, and how to add or bump a comparison library, see the Perf Benchmark Methodology runbook.

See also: Performance optimizations for design details.

How to read these tables

  • Scopes. Each dispatch table is labeled by execution scope and backend. Standalone (IL2CPP) -- a Release player on the ahead-of-time backend shipped games run -- is the only published scope. The renderer also understands PlayMode and EditMode rows for local or manually dispatched runs; backends differ by design, so read each scope against its own backend.
  • Throughput. Reported as emits per second. Higher is better. Registration scenarios report wall-clock time instead, where lower is better. The published throughput numbers come from the Standalone (IL2CPP) leg.
  • Allocations. Reported as the COUNT of managed GC allocations (and a companion byte total) observed over one measurement batch (lower is better; 0 is best for hot-path dispatch). Both come from Unity's GC.Alloc profiler recorder, which is only available where the profiler is present. A Release IL2CPP player strips that recorder, so the Standalone tables would have nothing to put in their memory columns -- rather than publish a column of n/a, those tables omit the memory columns entirely and show only throughput. Local and manually dispatched editor runs can still report allocation counts and bytes. n/a appears only as an individual cell -- when a metric is measured for a scope or library in general but missing for that one row -- never as a whole vacuous column or matrix; it is never rendered as a misleading 0, and a measured 0 is a real zero-allocation result. (This replaces an earlier byte counter built on GC.GetAllocatedBytesForCurrentThread(), which returns 0 for every allocation under Unity's Boehm GC and so reported a vacuous 0 for every technology -- see the runbook.)
  • Comparison matrix N/A. The cross-library matrix has a column per scenario and a row per library. A cell shows N/A when that library does not idiomatically support that capability -- it is a capability gap, not a failure, and the value is never faked.
  • Comparison matrix winners. In the throughput matrix the fastest technology per scenario column is rendered in bold (ties are all bolded; N/A never wins). The GC-allocations and GC-allocated-bytes matrices are not bolded: an allocation count or byte total is a property to read, not a race.

Latest CI dispatch throughput

The block below is regenerated by the Performance Numbers workflow (.github/workflows/perf-numbers.yml) via scripts/unity/render-perf-doc.js. It contains the Standalone IL2CPP dispatch-throughput table and cross-library throughput matrix. The profiler-stripped player omits allocation columns and matrices rather than filling them with n/a. The block also carries a privacy-safe provenance line describing the runner hardware (CPU, cores, clock, RAM, GPU, OS), never a hostname or runner name. Eligible same-repository pull requests run the Standalone leg and receive a current-evidence comment linked to the exact measured commit and workflow attempt. The comment includes a historical Standalone delta, with + meaning better and - meaning worse, plus current TargetMap rows; fork and Dependabot pull requests skip licensed work. After a pull request merges, the workflow commits the refreshed tables -- and the sibling baseline perf-baseline.csv used for the diagnostic PR historical delta -- directly to the default branch when the auto-commit App is provisioned and the branch has not advanced past the measured commit. Do not edit it by hand. See the perf-numbers auto-commit runbook for the repo-settings prerequisite that lets CI push to the default branch.

Latest CI benchmark run: Unity 6000.3.16f1, commit 1b85786254dc47e2dd28669d899678d149227a03.

Runner: 13th Gen Intel(R) Core(TM) i9-13900KF, 24C/32T @ 3000MHz; 64GB DDR5@4200; NVIDIA GeForce RTX 3060; Microsoft Windows 11 Pro N (10.0.26200)

Dispatch throughput - Standalone (IL2CPP)

Platform: Standalone IL2CPP x64 Release (WindowsPlayer; Unity 6000.3.16f1).

Scenario Throughput / Wall clock
Empty Bus Dispatch 48.15 M emits/sec
Untargeted Flood (One Handler) 33.45 M emits/sec
Untargeted Flood (Two Handlers, One Priority) 31.21 M emits/sec
Untargeted Flood (Three Handlers, One Priority) 29.23 M emits/sec
Untargeted Flood (Four Handlers, One Priority) 27.46 M emits/sec
Untargeted Flood (Four Handlers, Four Priorities) 26.50 M emits/sec
Untargeted Flood (Sixteen Handlers, One Priority) 14.98 M emits/sec
Untargeted Flood (One Inactive Handler) 32.87 M emits/sec
Untargeted First Dispatch (Cold, Distinct Types) 0.191 ms
Targeted Flood (No Matching Target) 13.77 M emits/sec
Targeted Flood (One Listener) 11.05 M emits/sec
Targeted Flood (Sixteen Listeners) 7.47 M emits/sec
Targeted First Dispatch (Cold, Distinct Types) 0.187 ms
Broadcast Flood (One Handler) 22.98 M emits/sec
Broadcast First Dispatch (Cold, Distinct Types) 0.187 ms
Interceptor Heavy (Four Interceptors) 3.59 M emits/sec
Post-Processing Heavy (Four Post-Processors) 13.22 M emits/sec
Message Bus Construction (1000) 24.918 ms
Registration Token Construction (1000, Prebuilt Handler + Bus) 0.050 ms
Registration Flood (1000 Types, Cold Bus) 536.034 ms
Registration Flood (1000 Types, Warm JIT) 4.820 ms
Untargeted Registration (Marginal, 1000 Same-Type) 0.410 ms
Targeted Registration (Marginal, 1000 Same-Type) 0.450 ms
Broadcast Registration (Marginal, 1000 Same-Type) 0.451 ms
Deregistration Flood (1000 Types, Cold) 1.827 ms
Deregistration Flood (1000 Types, Warm JIT) 1.613 ms

Library comparison - throughput (Standalone (IL2CPP))

Technology Global -> 1 subscriber Global -> 16 subscribers Keyed/targeted -> 1 of many Priority-ordered dispatch Filtered/intercepted dispatch Post-processing dispatch Subscribe/unsubscribe churn Struct message (no boxing)
DxMessaging 32.38 M emits/sec 16.45 M emits/sec 11.27 M emits/sec 25.55 M emits/sec 7.80 M emits/sec 15.09 M emits/sec 0.91 M emits/sec 31.21 M emits/sec
MessagePipe 83.10 M emits/sec 15.82 M emits/sec 10.47 M emits/sec N/A 72.55 M emits/sec N/A 2.12 M emits/sec 86.88 M emits/sec
UniRx MessageBroker 4.71 M emits/sec 2.68 M emits/sec N/A N/A N/A N/A 0.76 M emits/sec 4.59 M emits/sec
Zenject SignalBus 2.18 M emits/sec 1.13 M emits/sec N/A N/A N/A N/A 1.52 M emits/sec 2.03 M emits/sec
Unity Atoms 111.49 M emits/sec 34.07 M emits/sec 111.91 M emits/sec N/A N/A N/A 10.70 M emits/sec N/A
ScriptableObject channel 150.56 M emits/sec 24.43 M emits/sec 180.92 M emits/sec N/A N/A N/A 31.10 M emits/sec 179.78 M emits/sec
UnityEvent 92.78 M emits/sec 10.92 M emits/sec 99.83 M emits/sec N/A N/A N/A 3.51 M emits/sec 93.76 M emits/sec
C# event 329.67 M emits/sec 45.62 M emits/sec 69.52 M emits/sec N/A N/A N/A 13.05 M emits/sec 352.39 M emits/sec
Unity SendMessage 7.54 M emits/sec 1.06 M emits/sec 7.78 M emits/sec N/A N/A N/A N/A N/A

Comparison libraries

The cross-library comparison matrices above measure DxMessaging against other common Unity messaging and eventing approaches on the same apples-to-apples scenarios:

  • External libraries: MessagePipe, UniRx MessageBroker, Zenject SignalBus, and Unity Atoms.
  • Zero-dependency baselines: plain C# event, UnityEvent, a ScriptableObject event channel, and Unity SendMessage.

Each library implements only the scenarios it idiomatically supports; unsupported cells render N/A. The comparison suite source lives in Tests/Runtime/Comparisons/. For a feature-by-feature discussion of when each approach wins, see the Comparisons guide.

Memory footprint and reclamation

Dispatch state is stored per message type and, for targeted and broadcast paths, per InstanceId. Long-running sessions accumulate slots for every type or entity ever touched unless something reclaims them. The memory reclamation system caps that growth without changing dispatch semantics or allocating during emit.

Reclamation runs on two paths:

  • An idle sweep that runs from emit-time clock samples and the Unity PlayerLoop, gated by DxMessagingRuntimeSettings.EvictionEnabled and EvictionTickIntervalSeconds. Empty slots become eligible only after remaining empty for at least IdleEvictionSeconds of wall time.
  • An explicit IMessageBus.Trim(force) and MessageHandler.TrimAll(force) pair that runs synchronously at scene boundaries, in tests, or in maintenance windows. The master switch EnableTrimApi controls whether the explicit calls perform work; idle sweeps remain controlled by EvictionEnabled independently.

Active registrations are never reclaimed. Only empty slots and shared pool entries are touched. Sweep work runs outside the hot handler loop, so emit throughput is unaffected; the per-emit overhead is one branch that samples the wall clock.

For tuning recommendations, the public Trim and diagnostic-counter API surface, and worked examples (scene transitions, leak diagnosis, mobile caps, shipped-title configurations), see the Memory Reclamation guide. For the parameter reference, see the Runtime Settings reference.