#772·Harmony

Benchmark delegate creation strategies before changing MethodDelegate

Author: pardeikeCreated Sep 8, 2026Updated Sep 8, 2026
Labelsenhancementneeds more info/work

Investigation for the Harmony 3 backlog.

#586 asks whether BUTR's delegate compiler is better or faster. That remains unmeasured. Harmony uses Delegate.CreateDelegate and generated IL for particular cases; BUTR's implementation uses expression compilation and has a different behavior contract.

Compare equivalent supported cases before proposing a replacement.

Completion criteria:

  • Establish behavioral parity first, including static/instance, open/bound, virtual/non-virtual, interface, struct and ref/out cases.
  • Measure delegate construction cost separately from steady-state invocation cost and allocations. Record warm-up, runtime, architecture and benchmark source.
  • Include representative Mono/.NET Framework and modern .NET lanes; do not generalize one runtime's result to the entire matrix.
  • Account for current Mono workarounds and failure behavior.
  • Publish a bounded adopt/retain recommendation supported by reproducible results.

This ticket is complete with a useful comparison and decision. No performance regression or improvement has been established.

Follow-up to #586. Current implementation; BUTR source.