Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use double.ConvertToIntegerNative where safe to do in System.Random #112046

Merged
merged 1 commit into from
Feb 1, 2025

Conversation

tannergooding
Copy link
Member

This resolves #108096

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 31, 2025
@tannergooding
Copy link
Member Author

(Thanks Egor! Makes it a lot easier to get the perf numbers shared)

@EgorBo
Copy link
Member

EgorBo commented Jan 31, 2025

@EgorBot -amd -arm -profiler --envvars JitDisasm:InversionMutation

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;

public class Benchmarks
{
    private const int Seed = 100;

    private static readonly int[] Chromosome = new int[59];
    private static readonly Random Random = new(Seed);

    public Benchmarks()
    {
        var genes = Enumerable.Range(1, 59).ToArray();
        Random.Shuffle(genes);
        genes.CopyTo(Chromosome.AsSpan());
    }

    [Benchmark]
    public int[] InversionMutation()
    {
        var idx1 = 0;
        var idx2 = 0;

        var chromosomeLength = Chromosome.Length;

        while (idx1 == idx2)
        {
            idx1 = Random.Next(chromosomeLength);
            idx2 = Random.Next(chromosomeLength);
        }

        if (idx1 > idx2)
        {
            (idx1, idx2) = (idx2, idx1);
        }

        Array.Reverse(Chromosome, idx1, idx2 - idx1 + 1);

        return Chromosome;
    }
}

@tannergooding tannergooding merged commit bc191c9 into dotnet:main Feb 1, 2025
142 of 144 checks passed
@tannergooding tannergooding deleted the fix-108096 branch February 1, 2025 19:03
grendello added a commit to grendello/runtime that referenced this pull request Feb 3, 2025
* main:
  System.Net.Http.WinHttpHandler.StartRequestAsync assertion failed (dotnet#109799)
  Keep test PDB in helix payload for native AOT (dotnet#111949)
  Build the RID-specific System.IO.Ports packages in the VMR (dotnet#112054)
  Always inline number conversions (dotnet#112061)
  Use Contains{Any} in Regex source generator (dotnet#112065)
  Update dependencies from https://github.com/dotnet/arcade build 20250130.5 (dotnet#112013)
  JIT: Transform single-reg args to FIELD_LIST in physical promotion (dotnet#111590)
  Ensure that math calls into the CRT are tracked as needing vzeroupper (dotnet#112011)
  Use double.ConvertToIntegerNative where safe to do in System.Random (dotnet#112046)
  JIT: Compute `fgCalledCount` after synthesis (dotnet#112041)
  Simplify boolean logic in `TimeZoneInfo` (dotnet#112062)
  JIT: Update type when return temp is freshly created (dotnet#111948)
  Remove unused build controls and simplify DotNetBuild.props (dotnet#111986)
  Fix case-insensitive JSON deserialization of enum member names (dotnet#112028)
  WasmAppBuilder: Remove double computation of a value (dotnet#112047)
  Disable LTCG for brotli and zlibng. (dotnet#111805)
  JIT: Improve x86 unsigned to floating cast codegen (dotnet#111595)
  simplify x86 special intrinsic imports (dotnet#111836)
  JIT: Try to retain entry weight during profile synthesis (dotnet#111971)
  Fix explicit offset of ByRefLike fields. (dotnet#111584)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance regression on .NET 9, compared to .NET 8
3 participants