KEMBAR78
Convert ReRegisterForFinalize to QCALL by AustinWise · Pull Request #103211 · dotnet/runtime · GitHub
Skip to content

Conversation

@AustinWise
Copy link
Contributor

Contributes to #95695

Benchmark with both finalizable and non-finalizable objects:

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;

BenchmarkRunner.Run<Perf_ReRegisterForFinalize>(args: args);

public class Perf_ReRegisterForFinalize
{
    private static readonly object notFinializableObject = new();
    private static readonly object finializableObject = new FinializableObject();

    [Benchmark]
    public void NotFinializable() => GC.ReRegisterForFinalize(notFinializableObject);

    [Benchmark]
    public void Finializable() => GC.ReRegisterForFinalize(finializableObject);
}

class FinializableObject
{
    ~FinializableObject() {}
}
BenchmarkDotNet v0.13.12, macOS Sonoma 14.5 (23F79) [Darwin 23.5.0]
Apple M2, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.300
  [Host]     : .NET 8.0.5 (8.0.524.21615), Arm64 RyuJIT AdvSIMD
  Job-UXNDHB : .NET 9.0.0 (42.42.42.42424), Arm64 RyuJIT AdvSIMD

Toolchain=CoreRun  

Finializable

Version Mean Error StdDev
main 15.057 ns 0.1719 ns 0.2466 ns
PR 12.4418 ns 0.1961 ns 0.2812 ns

NotFinializable

Version Mean Error StdDev
main 1.315 ns 0.0019 ns 0.0017 ns
PR 0.3360 ns 0.0024 ns 0.0021 ns

@ghost ghost added the area-VM-coreclr label Jun 9, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 9, 2024
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

AustinWise added a commit to AustinWise/attachments that referenced this pull request Jun 9, 2024
Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jkotas
Copy link
Member

jkotas commented Jun 10, 2024

/ba-g OSX timeout

@jkotas jkotas merged commit e6c2e53 into dotnet:main Jun 10, 2024
@AustinWise AustinWise deleted the austin/RegisterForFinalization branch June 10, 2024 15:04
@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-VM-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants