/

Performance Impact in AOT Scenarios

Shield optimizes all protections to work with the best structure for AOT and native assemblies, ensuring minimal performance impact while maintaining strong security.


Performance Characteristics of AOT Applications

AOT-compiled applications have different performance characteristics compared to JIT-compiled applications:

  • Faster startup time: No JIT compilation at runtime
  • More predictable execution: Less runtime overhead and garbage collection
  • Memory efficiency: Smaller working set in many scenarios
  • Static analysis optimization: Compiler can perform more advanced optimizations

Shield's protection strategies are designed to preserve these benefits while adding robust security.


Performance Impact of Different Protections

Each protection technique has different performance implications in AOT scenarios:

ProtectionImpactNotes
RenamerNoneNo runtime overhead
Control FlowMinimalCan be excluded from specific methods if needed
Invalid CodeNoneNo runtime overhead
Call HidingMinimalSmall overhead on method calls
EventsMinimalSmall overhead on event handling
VirtualizationMinimalSmall overhead on protected methods
Constants EncryptionMinimalSmall overhead on string decryption
DisintegrationMinimalSmall overhead on protected code
Resources ProtectionNoneNo runtime overhead
Anti-DebuggerNoneNo runtime overhead
Anti-DumpNoneNo runtime overhead
Anti-DisDumpNoneNo runtime overhead
Anti-JailbreakNoneNo runtime overhead
Invalid MetadataNot CompatibleShould not be used with AOT

Measuring Performance Impact

Benchmark Metrics to Monitor

When evaluating the performance impact of Shield protection on your AOT application, measure these key metrics:

  1. Startup time: Time from process start to first user interaction
  2. Memory usage: Working set size during operation
  3. Throughput: Operations per second for key workflows
  4. Response time: Latency for critical operations

Testing Methodology

Follow this approach to accurately assess performance impact:

  1. Create baseline measurements with unprotected AOT application
  2. Apply Shield protection with default settings
  3. Measure performance metrics
  4. Adjust protection configuration based on results
  5. Repeat measurements until optimal balance is achieved

Method-Level Exclusions

You can exclude specific methods from certain protections using the [Obfuscation] attribute:

[Obfuscation(Exclude = false, Feature = "-control_flow_advance")]
public void PerformanceCriticalMethod() 
{
    // Method will be protected by other techniques but not control flow
}

Best Practices

  1. Start with standard protections: Apply the basic protections before adding more intensive ones
  2. Test incrementally: Add protections gradually and test after each step
  3. Focus on what matters: Apply stronger protection to critical IP, lighter to performance-sensitive areas
  4. Test on target hardware: Performance impact may vary significantly between development and production environments
  5. Real-world testing: Synthetic benchmarks may not reflect actual user experience

Shield is designed to work optimally with AOT-compiled applications, automatically adjusting its protection techniques to minimize performance impact while maintaining strong security.

For more information on Native AOT support, see Native AOT Support.

Performance Benchmarks

We conducted extensive performance testing on a .NET 8 Native AOT application with the following specifications:

  • CPU: Intel Core i7-12700K
  • RAM: 32GB DDR4
  • OS: Windows 11 Pro

Startup Time Impact

ScenarioTimeOverhead
Unprotected45.2msBaseline
With All Protections45.8ms+0.6ms (1.3%)

Runtime Performance Impact

OperationUnprotectedProtectedOverhead
Method Call (100k iterations)0.8ms0.82ms+0.02ms
String Decryption (1k strings)1.2ms1.25ms+0.05ms
Event Handling (10k events)15.3ms15.5ms+0.2ms
Resource Loading (100 resources)45.1ms45.3ms+0.2ms

Memory Impact

MetricUnprotectedProtectedDifference
Working Set45.2MB45.8MB+0.6MB
Peak Memory52.1MB52.7MB+0.6MB

These benchmarks demonstrate that Shield's protections add minimal overhead to your AOT-compiled applications. The performance impact is typically measured in microseconds or even nanoseconds for most operations.

Previous
Native AOT Support