Skip to content

Conversation

@stephentoub
Copy link
Member

And avoiding leaving the last invalid one for finalization.

Fixes #44382
cc: @bartonjs

Method Toolchain Mean Error Ratio Allocated
Enumerate \master\corerun.exe 2.426 ms 0.0408 ms 1.00 3.9 KB
Enumerate \pr\corerun.exe 2.391 ms 0.0175 ms 0.99 3.4 KB
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Running;
using System.Security.Cryptography.X509Certificates;

[MemoryDiagnoser]
public class Program
{
    static void Main(string[] args) => BenchmarkSwitcher.FromAssemblies(new[] { typeof(Program).Assembly }).Run(args);

    [Benchmark]
    public int Enumerate()
    {
        int count = 0;
        using var store = new X509Store(StoreLocation.CurrentUser);
        store.Open(OpenFlags.ReadOnly);
        foreach (var cert in store.Certificates)
        {
            count++;
            cert.Dispose();
        }
        return count;
    }
}

Contributes to #44598

And avoiding leaving the last invalid one for finalization.
@stephentoub stephentoub added this to the 6.0.0 milestone Nov 24, 2020
@ghost
Copy link

ghost commented Nov 24, 2020

Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @jeffhandley
See info in area-owners.md if you want to be subscribed.

Issue Details

And avoiding leaving the last invalid one for finalization.

Fixes #44382
cc: @bartonjs

Method Toolchain Mean Error Ratio Allocated
Enumerate \master\corerun.exe 2.426 ms 0.0408 ms 1.00 3.9 KB
Enumerate \pr\corerun.exe 2.391 ms 0.0175 ms 0.99 3.4 KB
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Running;
using System.Security.Cryptography.X509Certificates;

[MemoryDiagnoser]
public class Program
{
    static void Main(string[] args) => BenchmarkSwitcher.FromAssemblies(new[] { typeof(Program).Assembly }).Run(args);

    [Benchmark]
    public int Enumerate()
    {
        int count = 0;
        using var store = new X509Store(StoreLocation.CurrentUser);
        store.Open(OpenFlags.ReadOnly);
        foreach (var cert in store.Certificates)
        {
            count++;
            cert.Dispose();
        }
        return count;
    }
}

Contributes to #44598

Author: stephentoub
Assignees: -
Labels:

area-System.Security, tenet-performance

Milestone: 6.0.0

@stephentoub
Copy link
Member Author

netfx failure is #45168

@stephentoub stephentoub merged commit e04274e into dotnet:master Nov 24, 2020
@stephentoub stephentoub deleted the certsafehandle branch November 24, 2020 22:59
@ghost ghost locked as resolved and limited conversation to collaborators Dec 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

X509Store.Certificates.Find() results in surprisingly large finalized object counts

2 participants