Skip to content

Snapstart Minimal API Performance Improvements #2010

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

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from

Conversation

ppittle
Copy link
Member

@ppittle ppittle commented Mar 12, 2025

Issue #, if available:
It is not feasible for users to warm up the asp.net and lambda pipelines via SnapshotRestore.RegisterBeforeSnapshot when using .NET MinimalAPI Lambda.

Description of changes:
Creates a new extension method, AddAWSLambdaBeforeSnapshotRequest that allows users to add a function meant to initialize the asp.net and lambda pipelines during SnapshotRestore.RegisterBeforeSnapshot, improving the performance gains offered by SnapStart.

Example:

var builder = WebApplication.CreateSlimBuilder(args);

builder.Services.AddAWSLambdaHosting(LambdaEventSource.HttpApi);

// Initialize asp.net pipeline before Snapshot
builder.Services.AddAWSLambdaBeforeSnapshotRequest(async httpClient =>
{
     await httpClient.GetAsync($"/test");
});

var app = builder.Build();
 
app.MapGet($"/test", () => "Success");
 
app.Run();

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ppittle ppittle changed the base branch from master to dev March 12, 2025 18:25
@ppittle ppittle changed the title Snapstart Minimal API Performance Improvements [DRAFT] Snapstart Minimal API Performance Improvements Mar 12, 2025
@ppittle ppittle marked this pull request as draft March 12, 2025 18:25
@ppittle ppittle force-pushed the snapstart-minapi-perf-improvements branch from 520905f to 784e195 Compare March 12, 2025 22:52
@ppittle ppittle marked this pull request as ready for review March 13, 2025 05:48
@philasmar philasmar requested a review from normj March 13, 2025 13:12
@philasmar
Copy link
Contributor

@ppittle ppittle changed the title [DRAFT] Snapstart Minimal API Performance Improvements Snapstart Minimal API Performance Improvements Mar 14, 2025
@ppittle ppittle requested a review from philasmar March 19, 2025 19:06
@ppittle ppittle force-pushed the snapstart-minapi-perf-improvements branch 3 times, most recently from fa3658e to fc98552 Compare March 26, 2025 22:13
@ppittle ppittle force-pushed the snapstart-minapi-perf-improvements branch 2 times, most recently from c7d6057 to b476fcd Compare April 9, 2025 19:39
@ppittle ppittle requested a review from normj April 9, 2025 19:39
Copy link
Member

@normj normj left a comment

Choose a reason for hiding this comment

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

My reading is there are 2 different solutions being implemented here. One for AspNetCoreServer.Hosting and one for just using AspNetCoreServer. I would rather we not have different solutions and it seems like the subclasses in AspNetCoreServer.Hosting could override the virtual method for getting the list or requests to run and the service collection extension method could provide a way to get the request into that collection returned in the override.

Plus if you do it that way you can remove any changes you did to RuntimeSupport.

@ppittle ppittle force-pushed the snapstart-minapi-perf-improvements branch 3 times, most recently from 0d66f1c to 7915449 Compare April 21, 2025 21:59
@ppittle ppittle force-pushed the snapstart-minapi-perf-improvements branch from 7915449 to 723672b Compare April 21, 2025 22:06
@ppittle ppittle force-pushed the snapstart-minapi-perf-improvements branch 4 times, most recently from d4fa9a3 to da5a6e6 Compare April 21, 2025 22:17
@ppittle ppittle force-pushed the snapstart-minapi-perf-improvements branch from da5a6e6 to 2297048 Compare April 21, 2025 22:19
@ppittle
Copy link
Member Author

ppittle commented Apr 21, 2025

My reading is there are 2 different solutions being implemented here. One for AspNetCoreServer.Hosting and one for just using AspNetCoreServer. I would rather we not have different solutions and it seems like the subclasses in AspNetCoreServer.Hosting could override the virtual method for getting the list or requests to run and the service collection extension method could provide a way to get the request into that collection returned in the override.

Plus if you do it that way you can remove any changes you did to RuntimeSupport.

I have unified the 2 approaches so now AspNetCoreServer.Hosting uses the virtual method in AbstractAspNetCoreFunction as you suggested.

@ppittle ppittle requested a review from normj April 21, 2025 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants