Table of Contents

Class PerformanceOptions

Namespace
Excalibur.Dispatch.Options.Configuration
Assembly
Excalibur.Dispatch.dll

Configuration options for performance optimizations.

public sealed class PerformanceOptions
Inheritance
PerformanceOptions
Inherited Members
Extension Methods

Properties

AutoFreezeOnStart

Gets or sets a value indicating whether to automatically freeze caches when the application starts.

public bool AutoFreezeOnStart { get; set; }

Property Value

bool

true to automatically freeze caches on startup; otherwise, false. Defaults to true.

Remarks

PERF-22: When enabled (default), Dispatch will automatically freeze all internal caches when ApplicationStarted fires. This provides optimal production performance with zero configuration.

Auto-freeze is automatically disabled when hot reload is detected via the DOTNET_WATCH or DOTNET_MODIFIABLE_ASSEMBLIES environment variables. This ensures handler discovery works correctly during development.

AutoPromoteStatelessHandlersToSingleton

Gets or sets a value indicating whether to automatically promote stateless handlers to singleton lifetime.

public bool AutoPromoteStatelessHandlersToSingleton { get; set; }

Property Value

bool

false by default for safety. Set to true to enable auto-promotion.

Remarks

When enabled, Dispatch inspects handler constructor dependencies at registration time. Handlers whose dependencies are all singletons (or that have no dependencies) are automatically promoted from transient to singleton registration, eliminating per-dispatch DI resolution and handler allocation.

This follows the ASP.NET Core minimal API pattern where stateless delegates are effectively singleton. Handlers with scoped or transient dependencies (e.g., DbContext) are NOT promoted.

EmitDirectLocalResultMetadata

Gets or sets a value indicating whether direct-local success results should include full metadata.

public bool EmitDirectLocalResultMetadata { get; set; }

Property Value

bool

Remarks

When false (default), direct-local success uses minimal result objects for hot-path performance.

EnableTypeMetadataCaching

Gets or sets a value indicating whether to enable type metadata caching.

public bool EnableTypeMetadataCaching { get; set; }

Property Value

bool

The current EnableTypeMetadataCaching value.

MessagePoolSize

Gets or sets the size of the message pool for object reuse.

[Range(1, 2147483647)]
public int MessagePoolSize { get; set; }

Property Value

int

The current MessagePoolSize value.

UseAllocationFreeExecution

Gets or sets a value indicating whether to use allocation-free middleware execution.

public bool UseAllocationFreeExecution { get; set; }

Property Value

bool

The current UseAllocationFreeExecution value.