DotCompute.Plugins 0.6.2

dotnet add package DotCompute.Plugins --version 0.6.2
                    
NuGet\Install-Package DotCompute.Plugins -Version 0.6.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotCompute.Plugins" Version="0.6.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotCompute.Plugins" Version="0.6.2" />
                    
Directory.Packages.props
<PackageReference Include="DotCompute.Plugins" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotCompute.Plugins --version 0.6.2
                    
#r "nuget: DotCompute.Plugins, 0.6.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotCompute.Plugins@0.6.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotCompute.Plugins&version=0.6.2
                    
Install as a Cake Addin
#tool nuget:?package=DotCompute.Plugins&version=0.6.2
                    
Install as a Cake Tool

DotCompute Plugin System

A robust, extensible plugin system for DotCompute that enables dynamic loading of backend implementations with full isolation, hot-reload support, and comprehensive lifecycle management.

Features

  • Dynamic Loading: Load plugins at runtime from assemblies
  • Isolation: Each plugin runs in its own AssemblyLoadContext for complete isolation
  • Hot Reload: Support for reloading plugins without restarting the application
  • Lifecycle Management: Full control over plugin initialization, start, stop, and disposal
  • Health Monitoring: Built-in health checks and metrics collection
  • Configuration Support: Dynamic configuration with hot-reload capabilities
  • Dependency Management: Automatic resolution of plugin dependencies
  • Security: Sandboxing and permission management for plugins
  • Performance Tracking: Built-in metrics and telemetry

Installation

dotnet add package DotCompute.Plugins --version 0.5.3

Quick Start

1. Add Plugin Support to Your Host

var host = Host.CreateDefaultBuilder(args)
    .UsePlugins(builder => builder
        .SetPluginsDirectory("./plugins")
        .EnableHotReload()
        .SetHealthCheckInterval(TimeSpan.FromMinutes(1))
        .EnableMetrics())
    .Build();

2. Create a Plugin

[Plugin("my.plugin", "My Custom Plugin")]
[PluginCapability("compute.custom", Version = "1.0.0")]
public class MyPlugin : BackendPluginBase
{
    public override string Id => "my.plugin";
    public override string Name => "My Custom Plugin";
    public override Version Version => new(1, 0, 0);
    public override string Description => "A custom compute backend";
    public override string Author => "Your Name";
    public override PluginCapabilities Capabilities => 
        PluginCapabilities.ComputeBackend | PluginCapabilities.HotReloadable;

    protected override async Task OnInitializeAsync(CancellationToken cancellationToken)
    {
        // Initialize your plugin
        Logger?.LogInformation("Initializing My Plugin");
    }

    protected override Task OnStartAsync(CancellationToken cancellationToken)
    {
        // Start your plugin services
        return Task.CompletedTask;
    }

    protected override Task OnStopAsync(CancellationToken cancellationToken)
    {
        // Stop your plugin services
        return Task.CompletedTask;
    }
}

3. Configure Your Plugin

{
  "Plugins": {
    "PluginsDirectory": "./plugins",
    "EnableHotReload": true,
    "HealthCheckInterval": "00:01:00",
    "my.plugin": {
      "Enabled": true,
      "Settings": {
        "CustomOption": "value"
      }
    }
  }
}

Architecture

Core Components

  1. IBackendPlugin: Base interface for all plugins
  2. BackendPluginBase: Abstract base class providing common functionality
  3. PluginLoader: Handles assembly loading with isolation
  4. PluginManager: Manages plugin lifecycle and orchestration
  5. PluginLoadContext: Custom AssemblyLoadContext for isolation

Plugin Lifecycle

Unknown → Loading → Loaded → Initializing → Initialized → Starting → Running
                                                                         ↓
Unloaded ← Unloading ← Stopped ← Stopping ←─────────────────────────────┘

Plugin Capabilities

Plugins can declare various capabilities:

  • ComputeBackend: Provides compute functionality
  • StorageProvider: Provides storage services
  • NetworkProvider: Provides networking services
  • SecurityProvider: Provides security services
  • MonitoringProvider: Provides monitoring capabilities
  • HotReloadable: Supports hot reload
  • Scalable: Supports horizontal scaling
  • Clusterable: Supports clustering

Advanced Features

Hot Reload

Enable hot reload for development:

builder.EnableHotReload()
    .ConfigureLoader(options =>
    {
        options.EnableHotReload = true;
        options.ReloadDelay = TimeSpan.FromMilliseconds(500);
    });

Resource Limits

Set resource limits per plugin:

builder.SetResourceLimits(maxMemoryMB: 512, maxCpuPercent: 50);

Custom Dependencies

Add shared assemblies and probing paths:

builder.AddSharedAssemblies("MyShared.dll")
    .AddProbingPaths("./lib", "./dependencies");

Health Monitoring

Access plugin health and metrics:

var manager = serviceProvider.GetRequiredService<PluginManager>();
var stats = manager.GetStatistics();
var metrics = manager.GetPlugin("my.plugin")?.GetMetrics();

Plugin Discovery

Discover plugins in a directory:

var discoveries = await pluginLoader.DiscoverPluginsAsync("./plugins");
foreach (var discovery in discoveries.Where(d => d.Success))
{
    Console.WriteLine($"Found: {discovery.AssemblyName}");
    foreach (var plugin in discovery.PluginTypes)
    {
        Console.WriteLine($"  - {plugin.Id}: {plugin.Name} v{plugin.Version}");
    }
}

Security

Sandboxing

Enable sandboxing for untrusted plugins:

builder.EnableSandboxing()
    .ConfigureManager(options =>
    {
        options.ValidateSignatures = true;
        options.TrustedCertificateThumbprints.Add("THUMBPRINT");
    });

Permissions

Configure plugin permissions:

{
  "PluginSecurity": {
    "my.plugin": {
      "AllowFileSystemAccess": false,
      "AllowNetworkAccess": true,
      "AllowedNetworkEndpoints": ["https://api.example.com"]
    }
  }
}

Best Practices

  1. Implement IDisposable: Always clean up resources in your plugins
  2. Use Logging: Leverage the provided logger for debugging
  3. Handle Cancellation: Respect cancellation tokens in async operations
  4. Update Metrics: Keep metrics updated for monitoring
  5. Validate Configuration: Implement proper validation in your plugins
  6. Document Dependencies: Clearly document external dependencies
  7. Version Carefully: Use semantic versioning for your plugins
  8. Test Isolation: Test plugins in isolation before deployment

Examples

See the Examples folder for complete plugin examples:

  • ExampleBackendPlugin.cs: Basic plugin implementation
  • ComputePlugin.cs: Compute backend plugin
  • StoragePlugin.cs: Storage provider plugin
  • MonitoringPlugin.cs: Monitoring provider plugin

Troubleshooting

Plugin Won't Load

  1. Check the plugin implements IBackendPlugin
  2. Verify the [Plugin] attribute is present
  3. Ensure all dependencies are available
  4. Check platform requirements are met

Hot Reload Not Working

  1. Ensure the plugin has SupportsHotReload = true
  2. Check file permissions on the plugin directory
  3. Verify no file locks on the plugin assembly

Performance Issues

  1. Monitor plugin metrics for high CPU/memory usage
  2. Check for memory leaks in plugin disposal
  3. Review plugin health status
  4. Enable performance profiling

Documentation & Resources

Comprehensive documentation is available for DotCompute:

Architecture Documentation

Developer Guides

API Documentation

Support

Contributing

When contributing plugins:

  1. Follow the established patterns
  2. Include comprehensive tests
  3. Document all public APIs
  4. Provide configuration examples
  5. Test hot reload scenarios
  6. Validate cross-platform compatibility
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on DotCompute.Plugins:

Package Downloads
DotCompute.Backends.CUDA

Production-ready NVIDIA CUDA GPU backend for DotCompute. Provides GPU acceleration (21-92x speedup) through CUDA with NVRTC compilation, P2P transfers, Ring Kernels with NCCL support, and unified memory. Requires CUDA 12.0+ and Compute Capability 5.0+ NVIDIA GPU. Benchmarked on RTX 2000 Ada (CC 8.9).

DotCompute.Backends.CPU

Production-ready CPU compute backend for DotCompute. Provides SIMD vectorization (3.7x faster) using AVX2/AVX512/NEON instructions, multi-threaded kernel execution, and Ring Kernel simulation. Benchmarked: Vector Add (100K elements) 2.14ms → 0.58ms. Native AOT compatible with sub-10ms startup.

DotCompute.Backends.OpenCL

Production-ready OpenCL backend for DotCompute. Cross-platform GPU acceleration for NVIDIA, AMD, Intel, ARM Mali, and Qualcomm Adreno GPUs. Supports OpenCL 1.2+, Ring Kernels with atomic message queues, runtime kernel compilation, and multi-device workload distribution. Works with nvidia-opencl-icd, ROCm, intel-opencl-icd, and vendor drivers.

DotCompute.Backends.Metal

Metal backend for DotCompute with GPU acceleration for Apple Silicon (macOS/iOS). Foundation complete with native API bindings, device management, unified memory support, and command buffer execution. MSL (Metal Shading Language) compilation in development. Supports M1/M2/M3/M4 and A-series chips.

DotCompute.Algorithms

GPU-accelerated algorithms for DotCompute. Includes FFT, AutoDiff, sparse matrix operations, signal processing, and cryptographic primitives.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.2 181 2/9/2026
0.5.3 365 2/2/2026
0.5.2 710 12/8/2025
0.5.1 661 11/28/2025
0.5.0 274 11/27/2025
0.4.2-rc2 455 11/11/2025
0.4.1-rc2 406 11/6/2025