Skip to content

AesEngine uses more memory and takes more time in .NET 10.0 than in .NET Framework 4.8.1 #661

@paulomorgado

Description

@paulomorgado

I'm detecting that AesEngine uses more memory and takes more time in .NET 10.0 than in .NET Framework 4.8.1.

I've created this benchmark:

[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net10_0)]
[SimpleJob(RuntimeMoniker.Net481)]
[HideColumns(Column.Error, Column.StdDev, Column.Mean)]
public class AesEngineBenchmarks
{
    private KeyParameter key;
    private AesEngine aesForInit;
    private AesEngine aesForEncrypt;
    private byte[] output = new byte[256];
    private byte[] iv = new byte[] { 0x59, 0x5B, 0x69, 0x9B, 0xBD, 0x3B, 0xC0, 0xDF, 0x26, 0x06, 0x20, 0x93, 0xC1, 0xAD, 0x8F, 0x73 };

    [IterationSetup]
    public void IterationSetup()
    {
        key = new KeyParameter(new byte[] { 0x23, 0x48, 0x29, 0x00, 0x84, 0x67, 0xbe, 0x18, 0x6c, 0x3d, 0xe1, 0x4a, 0xae, 0x72, 0xd6, 0x2c });

        aesForInit = new AesEngine();

        aesForEncrypt = new AesEngine();
        aesForEncrypt.Init(true, key);
    }

    [Benchmark]
    public void Init()
    {
        aesForInit.Init(true, key);
    }

    [Benchmark]
    public void ProcessBlock()
    {
        aesForEncrypt.ProcessBlock(iv, 0, output, 16);
    }
}

and the results were:

BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.7705/25H2/2025Update/HudsonValley2)
13th Gen Intel Core i9-13900K 3.00GHz, 1 CPU, 32 logical and 24 physical cores
.NET SDK 10.0.102
  [Host]               : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3
  .NET 10.0            : .NET 10.0.2 (10.0.2, 10.0.225.61305), X64 RyuJIT x86-64-v3
  .NET Framework 4.8.1 : .NET Framework 4.8.1 (4.8.9325.0), X64 RyuJIT VectorSize=256

InvocationCount=1  UnrollFactor=1
Method Job Runtime Median Allocated
Init .NET 10.0 .NET 10.0 1,300.0 ns 832 B
ProcessBlock .NET 10.0 .NET 10.0 800.0 ns -
Init .NET Framework 4.8.1 .NET Framework 4.8.1 1,200.0 ns -
ProcessBlock .NET Framework 4.8.1 .NET Framework 4.8.1 100.0 ns -

What could be causing this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions