-
Notifications
You must be signed in to change notification settings - Fork 183
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
Prejit support on FunctionsNetHost #2711
Open
kshyju
wants to merge
13
commits into
main
Choose a base branch
from
shkr/2637_fnh_prejit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fb4bd15
FNH-WIP for prejit support
kshyju 450b956
Install net9 rc1
kshyju 7068487
Switching back to .NET9 preview 6
kshyju 1833452
fix YAML to install preview6
kshyju 8f02352
Changed a trace level log to Info level.
kshyju 4c51c4e
Updating build YAML file to include the pre-jit artifacts in the nuge…
kshyju 76651aa
PR review fixes
kshyju 4d8d4a4
Replaced "AZURE_FUNCTIONS_FUNCTIONSNETHOST" prefix with "AZURE_FUNCTI…
kshyju 2dd4703
Added linux.coldstart jittrace and removed removed R2R from placehold…
kshyju e884965
Fixed incorrect output path for prelaunch apps
kshyju c1a449c
Switching to named pipes for communication between FNH and StartupHoo…
kshyju 1e58d2f
Merge branch 'shkr/2637_fnh_prejit' of https://github.com/Azure/azure…
kshyju 7377750
Merge branch 'main' into shkr/2637_fnh_prejit
liliankasem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
eng/ci/templates/official/jobs/build-host-prejit-artifacts.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
jobs: | ||
|
||
- job: BuildPreJitApp | ||
displayName: Build Pre-jit placeholder app artifacts | ||
|
||
templateContext: | ||
outputParentDirectory: $(Build.ArtifactStagingDirectory) | ||
outputs: | ||
- output: pipelineArtifact | ||
displayName: Publish Pre-jit placeholder app artifacts | ||
path: $(Build.ArtifactStagingDirectory)/_preJitAppPackages | ||
artifact: _preJitAppPackages | ||
|
||
variables: | ||
dotnetVersions: 'net8.0,net9.0' | ||
|
||
steps: | ||
- template: /eng/ci/templates/steps/install-dotnet.yml@self | ||
|
||
- ${{ each version in split(variables.dotnetVersions, ',') }}: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small nit: use |
||
- task: DotNetCoreCLI@2 | ||
displayName: ${{ version }} publish of pre-jit app | ||
inputs: | ||
command: publish | ||
publishWebProjects: false | ||
zipAfterPublish: false | ||
modifyOutputPath: false | ||
arguments: -c Release -o $(Build.ArtifactStagingDirectory)/_preJitAppPackages/${{ replace(version, 'net', '') }} -f ${{ version }} -p:UseAppHost=false -p:DebugType=None -p:DebugSymbols=false | ||
projects: host/src/PlaceholderApp/FunctionsNetHost.PlaceholderApp.csproj | ||
workingDirectory: host/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,13 @@ jobs: | |
displayName: Download prelaunch artifacts | ||
inputs: | ||
artifactName: _preLaunchAppPackages | ||
path: $(Build.SourcesDirectory)/host/dist/portable | ||
path: $(Build.SourcesDirectory)/host/dist/portable/prelaunchapps | ||
|
||
- task: DownloadPipelineArtifact@2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we supposed to use |
||
displayName: Download pre-jit artifacts | ||
inputs: | ||
artifactName: _preJitAppPackages | ||
path: $(Build.SourcesDirectory)/host/dist/portable/prejit-placeholder-app | ||
|
||
- task: DownloadPipelineArtifact@2 | ||
displayName: Download host artifacts - linux | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
namespace FunctionsNetHost.Shared | ||
{ | ||
public static class Constants | ||
{ | ||
public const string LogCategory = "FunctionsNetHost"; | ||
public const string DefaultLogPrefix = "LanguageWorkerConsoleLog"; | ||
public const string NetHostWaitHandleName = "AzureFunctionsNetHostSpecializationWaitHandle"; | ||
public const string LogTimeStampFormat = "yyyy-MM-dd HH:mm:ss.fff"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
namespace FunctionsNetHost.Shared | ||
{ | ||
public static class EnvironmentVariables | ||
{ | ||
/// <summary> | ||
/// The environment variable which is used to specify the specialized (function app payload) entry assembly. | ||
/// </summary> | ||
public const string SpecializedEntryAssembly = "AZURE_FUNCTIONS_FUNCTIONSNETHOST_SPECIALIZED_ENTRY_ASSEMBLY"; | ||
kshyju marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// <summary> | ||
/// The environment variable which is used to specify the path to the jittrace file which will be used for prejitting. | ||
/// </summary> | ||
public const string PreJitFilePath = "AZURE_FUNCTIONS_FUNCTIONSNETHOST_PREJIT_FILE_PATH"; | ||
kshyju marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// <summary> | ||
/// The .NET startup hooks environment variable. | ||
/// </summary> | ||
public const string DotnetStartupHooks = "DOTNET_STARTUP_HOOKS"; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
host/src/FunctionsNetHost.Shared/FunctionsNetHost.Shared.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using FunctionsNetHost.Grpc; | ||
|
||
namespace FunctionsNetHost | ||
{ | ||
/// <summary> | ||
/// Encapsulates various configuration options required to run the FunctionsNetHost application. | ||
/// </summary> | ||
internal sealed class NetHostRunOptions | ||
{ | ||
//.NET 8.0 is the minimum version that supports pre-jitting. | ||
private const int MinimumNetTfmToSupportPreJit = 8; | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether pre-jitting is supported. | ||
/// </summary> | ||
public bool IsPreJitSupported { get; } | ||
|
||
/// <summary> | ||
/// Gets the worker startup options. | ||
/// </summary> | ||
public GrpcWorkerStartupOptions WorkerStartupOptions { get; } | ||
|
||
/// <summary> | ||
/// Gets the runtime version. This usually corresponds to the .NET runtime version. | ||
/// Example value: 8.0. | ||
/// </summary> | ||
public string RuntimeVersion { get; } | ||
|
||
/// <summary> | ||
/// Gets the directory where the FunctionsNetHost executable is located. | ||
/// </summary> | ||
public string ExecutableDirectory { get; } | ||
|
||
public NetHostRunOptions(GrpcWorkerStartupOptions workerStartupOptions, string executableDirectory) | ||
{ | ||
WorkerStartupOptions = workerStartupOptions; | ||
ExecutableDirectory = executableDirectory; | ||
RuntimeVersion = EnvironmentUtils.GetValue(EnvironmentVariables.FunctionsWorkerRuntimeVersion)!; | ||
IsPreJitSupported = IsPrejitSupported(RuntimeVersion); | ||
} | ||
|
||
private static bool IsPrejitSupported(string runtimeVersion) | ||
{ | ||
if (string.IsNullOrEmpty(runtimeVersion)) | ||
{ | ||
return false; | ||
} | ||
|
||
var disablePrejitEnvironmentVaValue = EnvironmentUtils.GetValue(EnvironmentVariables.DisablePrejit); | ||
if (string.Equals(disablePrejitEnvironmentVaValue, "1")) | ||
{ | ||
Logger.Log($"PreJitting is disabled due to the environment variable '{EnvironmentVariables.DisablePrejit}' being set to '{disablePrejitEnvironmentVaValue}'."); | ||
return false; | ||
} | ||
|
||
return decimal.TryParse(runtimeVersion, out var value) && value >= MinimumNetTfmToSupportPreJit; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider making this a variable