Skip to content

Add benchmarks for RDG #50266

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

Merged
merged 2 commits into from
Aug 22, 2023
Merged

Add benchmarks for RDG #50266

merged 2 commits into from
Aug 22, 2023

Conversation

captainsafia
Copy link
Member

Add microbenchmarks for RequestDelegateGenerator

@ghost ghost added needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically area-runtime labels Aug 22, 2023
@@ -0,0 +1,3 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
global using Xunit;
Copy link
Member Author

Choose a reason for hiding this comment

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

We need this because the shared RequestDelegateCreationTestBase has some asserts. I'm just importing Xunit into the context instead of adding if-defs to the shared code to avoid calling Assert all the time.

Copy link
Member

Choose a reason for hiding this comment

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

NIT: Can we add this explanation as a comment to this line 🙂

@@ -6,13 +6,34 @@
<ServerGarbageCollection>true</ServerGarbageCollection>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RootNamespace>Microsoft.AspNetCore.Http</RootNamespace>
<PreserveCompilationContext>true</PreserveCompilationContext>
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to enable this to support passing assembly info to the Roslyn compilation instance at runtime.

@captainsafia captainsafia added feature-rdg area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-runtime needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Aug 22, 2023
@adityamandaleeka
Copy link
Member

Approved for RC2

Comment on lines 18 to 22
var source = "";
for (var i = 0; i < EndpointCount; i++)
{
source += $"""app.MapGet("/route{i}", (int? id) => "Hello World!");""";
}
Copy link
Member

Choose a reason for hiding this comment

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

Move the source creation into:

[GlobalSetup]
public void Setup()
{
   // ..
}

so we aren't measuring string creation.

@@ -17,6 +17,7 @@

<ItemGroup>
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Extensions.Tests" />
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Microbenchmarks" />
Copy link
Member

Choose a reason for hiding this comment

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

Just curious: which internal types do we need this for? I had assumed that RunGenerator should just work by passing it a source and the generator.

Copy link
Member Author

Choose a reason for hiding this comment

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

The RequestDelegateCreationTestBase class that I'm source-sharing between our integration tests and our benchmarks dependencies on some types that are internal to the generator (e.g. the Endpoint type which represents the info we've derived vai Roslyn about a method invocation that maps to a minimal API).

I could've done work work to factor out the RequestDelegateCreationTestBase class here but I figured there was no harm in doing IVT between our benchmarks and generator.

Also, it'll help in the future if we decide to profile specific parts of the generator implementation.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks for the explanation. I know other repos like dotnet/runtime try to avoid IVT for these cases and prefer source sharing instead but I think both approaches are fine 😃

@captainsafia captainsafia enabled auto-merge August 22, 2023 17:52
@captainsafia captainsafia merged commit 1a83e39 into release/8.0 Aug 22, 2023
@captainsafia captainsafia deleted the safia/rdg-benchmarks branch August 22, 2023 18:42
@ghost ghost added this to the 8.0-rc2 milestone Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-rdg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants