Giter VIP home page Giter VIP logo

jitbench's Introduction

JitBench

A repository for aspnet workloads suitable for testing the JIT.

Right now there is only one workload app here, at src/MusicStore

Branches

This repo uses branches that target various releases for comparison purposes. Please make sure to follow the instructions in the readme for that particular branch that you are using. dev in particular is special.

Branch ASP.NET version Status
dev latest Build Status
master 2.0.0 Build Status
rel/2.0.0 2.0.0 Build Status

Instructions for JIT testing:

Step 0:

Clone the JitBench Repo

git clone <JitBench repo>

cd JitBench

Step 1:

Get the newest dotnet Shared Runtime as 'repo local'

Windows

.\Dotnet-Install.ps1 -SharedRuntime -InstallDir .dotnet -Channel master -Architecture x64

.\Dotnet-Install.ps1 -InstallDir .dotnet -Channel master -Architecture x64

OSX

./dotnet-install.sh -sharedruntime -runtimeid osx.10.12-x64 -installdir .dotnet -channel master -architecture x64

source ./dotnet-install.sh -installdir .dotnet -channel master -architecture x64

Linux

./dotnet-install.sh -sharedruntime -runtimeid linux-x64 -installdir .dotnet -channel master -architecture x64

source ./dotnet-install.sh -installdir .dotnet -channel master -architecture x64

You need to run both of these commands in this particular order. This will grab the latest shared runtime and SDK and copy them to <JitBench>\.dotnet. Note you need to source the second script so that it can update your $PATH.

You should also have this version of dotnet on your path at this point. dotnet --info will print the version and it should match what you see in the output of the above commands.

Step 2:

Modify the shared framework (if necessary).

If you need to use a private build of the JIT or other CoreCLR components, now is a good time to update the shared framework with your bits. Copy any binaries you need to use into the shared framework in <JitBench>\.dotnet\shared\Microsoft.NETCore.App\<version>. The version should match the version that downloaded in step 1.

Step 3a:

Generate Crossgen/R2R binaries locally

Windows

.\AspNet-GenerateStore.ps1 -InstallDir .store -Architecture x64 -Runtime win7-x64

OSX

source ./aspnet-generatestore.sh -i .store --arch x64 -r osx.10.12-x64

This will generate new crossgen/R2R images locally using the same shared framework version

This step will also set some environment variables that affect the behavior of the subsequent commands. You'll see in the console output some of the information about the environment variables that were set.

This step assumes the latest version of ASP.NET and the shared framework. Use the -AspNetVersion and -FrameworkVersion parameters to override these.

Step 4:

Restore dependency packages

cd src\MusicStore

dotnet restore

You should see that all of the ASP.NET dependencies that get restored during this stage have the same version number as the output of step 3.

Step 5:

Build/publish MusicStore

Windows

dotnet publish -c Release -f netcoreapp2.1 --manifest $env:JITBENCH_ASPNET_MANIFEST (powershell)

OR

dotnet publish -c Release -f netcoreapp2.1 --manifest %JITBENCH_ASPNET_MANIFEST% (cmd)

OSX

dotnet publish -c Release -f netcoreapp2.1 --manifest $JITBENCH_ASPNET_MANIFEST

This will publish the app to bin\Release\netcoreapp2.1\publish. You should only see the MusicStore.dll and a few other project related assest here if you passed the --manifest argument.

Step 6:

Run the app

cd bin\Release\netcoreapp2.1\publish

dotnet MusicStore.dll

You should see console output like:

Server started in 1723ms

Starting request to http://localhost:5000
Response: OK
Request took 3014ms

Cold start time (server start + first request time): 4737ms


Running 100 requests
Steadystate min response time: 4ms
Steadystate max response time: 15ms
Steadystate average response time: 4ms

Other things you can do

View Compilation

MVC can pre-compile the view files on publish.

To do this change up your step 5 publish command

dotnet publish -c Release -f netcoreapp2.1 --manifest $env:JITBENCH_ASPNET_MANIFEST /p:MvcRazorCompileOnPublish=true (powershell)

After doing a publish this way you shouldn't have a Views folder in the publish output.


This is interesting to do because view compilation at runtime eats up about 50% our startup time. So by excluding it we measure a much different subset of the application.

Compile on publish is the default for publishing for new applications. We expect most users to use runtime compilation for local inner-loop and publish-time compilation for production.

FAQ

What about x86?

You can do x86! Just substitute x86 for x64 in step 1 and step 3.

You need to do a git clean -xdf and start over at step 1 if you are switching architectures.

Things are failing what do I do?

Do a git clean -xdf and get back to a clean state. Then start over at step 1.

If you still have a problem, open an issue on this repo. Opening an issue here is the best way to get a quick response.

Powershell Errors

The scripts in this repo use powershell. If you're not a powershell user you will have to do some first-time setup on your machine.

Open powershell as admin and run Set-ExecutionPolicy Unrestricted, accept the prompt. By default powershell does not allow you to run scripts ๐Ÿ‘Ž

What is Microsoft.AspNetCore.All

This is a meta-package that contains all of the ASP.NET libraries. This is the easiest way to just pull in the whole platform as a reference. We expect that this will be the common way to build applications in ASP.NET going forward.

What is Build.RuntimeStore?

This is a big zip file of pre-optimized ASP.NET libraries. This is the best way for us to test the JIT because this is very close to what customers will use for local development or on a shared host like Azure in 2.0.0. Think of it like an add-on to the shared framework. Read the Explanation section below for a description of how this is wired up.

About MusicStore

MusicStore is a good sample of what a typical but small customer app would look like for a browser-based LOB app or public website. Notably it uses auth, logging, databases, ORM, caching, and dynamic view content. It's a good representation of the concerns a typical production app needs to address.

We've modified the app to start up the server and perform a single HTTP request with timing information. Then it will perform 100 requests (single threaded) and print some statistics. We feel like this is a good benchmark for both server cold start and local development cold start, and is suitable for iterating on quickly due to the ease of running.

Explanation (what does this do?)

For an intro to dotnet CLI I suggest referring to their docs. We'll describe some of the steps here, but you should refer to the CLI docs as the primary source of information about CLI. If you have issues with the CLI please log them here.

Step 3a: .\AspNet-GenerateStore.ps1 -InstallDir .store -Architecture x64 -Runtime win7-x64

This uses dotnet store to generate an optimized package store under .store. If you want to get an updated set of ASP.NET libraries, start at this step.


This command will also output some messages about environment variables that it sets. Here's a quick guide:

Setting JITBENCH_ASPNET_VERSION to 2.0.0-preview1-24493

This means that the latest build of ASP.NET available at this time is 2.0.0-preview1-24493. This environment variable will 'pin' the versions of the ASP.NET dependencies in the .csproj to match exactly the binaries that we just pulled down. There's no magic here, look at the .csproj to see how this works.

Setting JITBENCH_FRAMEWORK_VERSION to 2.0.0-preview2-002062-00

This means that the version of the shared framework that was selected was 2.0.0-preview2-002062-00. This environment variable will 'pin' the versions of the shared framework in the .csproj to match exactly the binaries that we just pulled down. There's no magic here, look at the .csproj to see how this works.

Setting JITBENCH_ASPNET_MANIFEST to D:\k\JitBench\.aspnet\AspNet.win-2.0.0-preview1-24493\x86\netcoreapp2.0\artifact.xml

This file artifact.xml is a listing of all of the packages that are included in the payload. If you look in this directory, you'll find a hierarchy that's very similar to a NuGet package hive. This environment variable will be used later by publishing to filter the set of packages that are copied to the publish output.

Setting DOTNET_SHARED_STORE to D:\k\JitBench\.aspnet\AspNet.win-2.0.0-preview1-24493

This variable is probed by the dotnet host as an additional set of packages that the runtime can use. Note that the binaries here will only be used if they match and if they are not present in 'bin'. That's why the two other environment variables are important! See here for a more thorough description.

Step 3b: .\AspNet-Install.ps1 -InstallDir .aspnet -Architecture x64

This downloads pre-optimized ASP.NET binaries and unzips them under .aspnet. If you want to get an updated set of ASP.NET libraries, start at this step.


This command will also set the same environment variables as step 3a.

Step 4: dotnet restore

This will restore package and runtime dependencies. In general we already have these on the machine, we just need to update the generated files.

This step will use the environment variables JITBENCH_ASPNET_VERSION and JITBENCH_FRAMEWORK_VERSION to pin the version of the ASP.NET libraries and shared framework based on Step 3.

Step 5: dotnet publish -c Release -f netcoreapp2.1 --manifest $env:JITBENCH_ASPNET_MANIFEST

This will build and publish the application in the Release configuration and targeting netcoreapp20 as the target framework. netcoreapp20 is what we refer to as the shared framework.

The --manifest argument specifies a list of binaries that are already present in a 'shared' location. Now this 'shared' location was created by step 2, and the list of files is stored in the JITBENCH_ASPNET_MANIFEST environment variable. Since these binaries weren't copied to the publish output, they will be loaded instead from DOTNET_SHARED_STORE. See here for a more thorough description.

Step 6: dotnet MusicStore.dll

Runs the app. We're using the shared framework so the actual .exe that runs here is dotnet.exe. The app itself is a .dll with a Main(...) method. It's very important that you do this with pwd set to the publish folder. The app will use the pwd to determine where view templates are located.

jitbench's People

Contributors

andyayersms avatar davmason avatar josephtremoulet avatar kichalla avatar michellemcdaniel avatar noahfalk avatar rynowak avatar sbomer avatar terrajobst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jitbench's Issues

JitBench failing on latest dotnet

Currently seeing the following failure with 2.0.0-preview2-002093-00

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Encoding.CodePages, V
ersion=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

Version mismatch in System.Diagnostics.StackTrace

Currently the dev branch will fail to crossgen anything referencing System.Diagnostics.StackTrace. The command will fail with a message about an assembly version not matching the manifest for version 4.0.2.0.

Running .\.crossgen\crossgen.exe /Platform_Assemblies_Paths "D:\k\JitBench\.dotnet\shared\Microsoft.NETCore.App\1.2.0-beta-001133-00" /App_Paths "D:\k\JitBench\src\MusicStore\bin\Release\netcoreapp1.2\publish";"D:\k\JitBench\src\MusicStore\bin\Release\netcoreapp1.2\publish\runtimes\win\lib\netstandard1.3" /out "D:\k\JitBench\src\MusicStore\bin\Release\netcoreapp1.2\publish\Microsoft.AspNetCore.Diagnostics.ni.dll" "D:\k\JitBench\src\MusicStore\bin\Release\netcoreapp1.2\publish\Microsoft.AspNetCore.Diagnostics.dll"
Microsoft (R) CoreCLR Native Image Generator - Version 4.5.22220.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Error: Could not load file or assembly 'System.Diagnostics.StackTrace, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Error compiling D:\k\JitBench\src\MusicStore\bin\Release\netcoreapp1.2\publish\Microsoft.AspNetCore.Diagnostics.dll: Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
Error: compilation failed for "D:\k\JitBench\src\MusicStore\bin\Release\netcoreapp1.2\publish\Microsoft.AspNetCore.Diagnostics.dll" (0x80131621)

I've added a workaround to the crossgen script to skip the assemblies that are having issues: https://github.com/aspnet/JitBench/blob/dev/src/MusicStore/Invoke-Crossgen.ps1#L15

We should determine the root cause and remove this workaround asap because it causes about 5 assemblies to be skipped.

Support latest 3.0 preview

I'm trying to build MusicStore with the latest dotnet preview (version info at the bottom).
The Microsoft.AspNetCore.All reference isn't supported on netcoreapp3.0 and above:

/Users/sven/bin/sdk/3.0.100-preview-010184/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.targets(133,5): error NETSDK1079: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher.  A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web. [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]

If I remove the reference I get other compilation errors:

Areas/Admin/Controllers/StoreManagerController.cs(9,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Components/GenreMenuComponent.cs(5,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Controllers/CheckoutController.cs(8,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Controllers/HomeController.cs(6,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Controllers/ShoppingCartController.cs(5,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Controllers/StoreController.cs(5,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(2,37): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft.AspNetCore.Identity' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(3,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(4,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/SampleData.cs(8,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/ShoppingCart.cs(6,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Startup.cs(4,37): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft.AspNetCore.Identity' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Startup.cs(5,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(10,38): error CS0246: The type or namespace name 'IdentityDbContext<>' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(17,47): error CS0246: The type or namespace name 'DbContextOptionsBuilder' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(25,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(26,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(27,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(28,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(29,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(30,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]
Models/MusicStoreContext.cs(12,34): error CS0246: The type or namespace name 'DbContextOptions<>' could not be found (are you missing a using directive or an assembly reference?) [/Users/sven/src/aspnet/JitBench/src/MusicStore/MusicStore.csproj]

Version info:

 Version:   3.0.100-preview-010184
 Commit:    c57bde4593

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /Users/sven/src/dotnet/linker_arcade/.dotnet/sdk/3.0.100-preview-010184/

Host (useful for support):
  Version: 3.0.0-preview-27324-5
  Commit:  63a01b08e5

.NET Core SDKs installed:
  2.0.0 [/Users/sven/src/dotnet/linker_arcade/.dotnet/sdk]
  2.1.403 [/Users/sven/src/dotnet/linker_arcade/.dotnet/sdk]
  3.0.100-preview-010184 [/Users/sven/src/dotnet/linker_arcade/.dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [/Users/sven/src/dotnet/linker_arcade/.dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [/Users/sven/src/dotnet/linker_arcade/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview-19075-0444 [/Users/sven/src/dotnet/linker_arcade/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.0 [/Users/sven/src/dotnet/linker_arcade/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [/Users/sven/src/dotnet/linker_arcade/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview-27324-5 [/Users/sven/src/dotnet/linker_arcade/.dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Announcement: Updating to netcoreapp2.1

Some code and project changes are needed to consume the new .net builds.

I'm currently chasing down one last issue with netcoreapp2.1 that's a total blocker from updating. I have this done in a branch right now (rel/2.0.0) but it's blocked by one issue.

If I don't hear from anyone that this would be disruptive, I plan to merge these changes to master as soon as everything is working end to end.

Enable CI

I've added CI support via travis to run each of the branches we actively maintain every 24 hours.

This means that the status links on the readme should be up to date
image

MusicStore fails with System.Net.Http.HttpRequestException error

I'm trying to do some experiments, and started with just doing a stock build/run of MusicStore on Windows. After following all of the instructions, MusicStore fails to run with the following error:

PS C:\michelm\JitBench\src\MusicStore\bin\Release\netcoreapp2.1\publish> dotnet .\MusicStore.dll
Server started in 1062ms

Starting request to http://localhost:5000

Unhandled Exception: System.AggregateException: One or more errors occurred. (An error occurred while sending the request.) ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: The server returned an invalid or unrecognized response
   at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
   at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at MusicStore.Program.Main(String[] args) in C:\michelm\JitBench\src\MusicStore\Program.cs:line 62

Known Issue: Unable to resolve path for 'coreclr'

Everything is currently failing like:

D:\k\JitBench\.dotnet\sdk\2.1.0-preview1-007071\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.CrossGen.targets(48,5): error
 : Unable to find resolved path for 'coreclr'. [D:\k\JitBench\CreateStore.proj]
dotnet store failed.

Following up with the SDK team to see if this is a regression

Discussion: How to test a private build of the shared runtime

We need to recipe for testing private builds of the runtime/CoreCLR/JIT. I'm looking for input on the best ways to do this.

Background

MusicStore is a shared framework app, meaning that it will load the CoreCLR and CoreFx libraries from C:\Program Files\dotnet\shared\Microsoft.NETCore.App\<version>.

Note that the C:\Program Files\dotnet\ prefix is actually not hardcoded, it is based on the location of dotnet.exe, and in the default case you have on your path C:\Program Files\dotnet\dotnet.exe.

The version is chosen via the MusicStore.runtimeconfig.json file:

{
  "runtimeOptions": {
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "1.0.1"
    }
  }
}

The version number emplaced in MusicStore.runtimeconfig.json is chosen at build time based on the reference to Microsoft.NETCore.App in the project.json. You can edit the MusicStore.runtimeconfig.json file after publishing to select a different runtime version, but it will still be loaded from C:\Program Files\dotnet\shared\Microsoft.NETCore.App\<version>.

dotnet also accepts an --fx-version argument to specify a framework version like dotnet --fx-version MusicStore.dll. This will also be loaded from C:\Program Files\dotnet\shared\Microsoft.NETCore.App\<version>.

Proposal

My proposal of how to best leverage what's possible today is to create a 'private' build of the shared framework and then refer to that via the --fx-version argument. This allows you to quickly pivot between builds and do comparisons.

Steps (I haven't tried this, need a guinea pig)

copy C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.1 -> C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.2-private

make changes in C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.2-private

run dotnet --fx-version 1.0.2-private MusicStore.dll

*Note: this does not replace the version used by crossgen.exe. The crossgen step will use binaries in ...publish\.crossgen currently. We could improve this if necessary.

The crossgen step also supports a custom path for crossgen: Invoke-Crossgen.ps1 -crossgen_path <path-to-crossgen>

Announcment: Updating to 3.0 and simplifying scripts

Based on discussion over email we don't have the same complex needs for testing we once had.

The master branch of this repo will be updated to be a simple 3.0-style ASP.NET Core app. I'm going to remove complex scripts that deal with crossgen, or creation of the runtime store so no one has indicated that they use these.

JitBench Failing on latest dotnet

Error: assembly specified in the dependencies manifest was not found probably due to missing runtime store associated with artifact.xml 
-- package: 'System.Diagnostics.DiagnosticSource', version: '4.4.0-preview1-25228-02', path: 'runtimes/win/lib/net46/System.Diagnostics.DiagnosticSource.dll'

The artifact.xml does list DiagnosticSource

   <Package Id="System.Diagnostics.DiagnosticSource"  Version ="4.4.0-preview1-25228-02"/>

But the package isn't in there anywhere.

A new database warning

We have a new EF warning

warn: Microsoft.EntityFrameworkCore.Query[100102]
      Query: '(from Genre g in DbSet<Genre> select [g].Name).Take(__p_0)' uses a row limiting operation (Skip/Take) wit
out OrderBy which may lead to unpredictable results.

Cannot find framework...

Some travis builds are failing like

It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.1.0-preview1-25320-01' was not found.
  - Check application dependencies and target a framework version installed at:
      /
  - Alternatively, install the framework version '2.1.0-preview1-25320-01'.

This seems to be succeeding on osx and failing on linux. The version number that's getting installed on osx is 2.1.0-dev-di-25408-06 and on linux is 2.1.0-dev-di-25408-06.

It's possible this could have been a race condition with NuGet

A new database issue on appveyor

I've seen this issue running on appveyor, I haven't yet seen it on a local windows install.

System.Data.SqlClient.SqlException (0x80131904): Cannot open database "MusicStore" requested by the login. The login failed.
Login failed for user 'APPVYR-WIN\appveyor'.
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.<OpenAsync>d__34.MoveNext()
ClientConnectionId:2e6c7daf-2faa-42b2-8cb1-489a353f9e01
Error Number:4060,State:1,Class:11
Server started in 5534ms
``

Tracking this since it doesn't cause the app to fail, it just seems to affect the startup time. 

I repeat, I have **only** seen this on appveyor.

JitBench: Failing with missing assembly 'Microsoft.Win32.Registry',

In the 'dev' branch after following all the steps to build and run:

E:\fxkit\JitBench\src\MusicStore\bin\Release\netcoreapp2.0\publish>dotnet MusicStore.dll
Error: assembly specified in the dependencies manifest was not found probably due to missing runtime store associated with artifact.xml -- package: 'Microsoft.Win32.Registry', version: '4.4.0-preview1-25229-02', path: 'runtimes/win/lib/netcoreapp2.0/Microsoft.Win32.Registry.dll'

EF Warnings in MusicStore/JitBench

Reported by @JosephTremoulet here: #5 (comment)

Note that the new EntityFramework version spits out a couple warnings when running this code. I've disabled this one per the instructions printed with the warning:

warn: Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory[2]
Query: '(from Genre g in DbSet select g.Name).Take(__p_0)' uses a row limiting operation (Skip/Take)
without OrderBy which may lead to unpredictable results. To configure this warning use the DbContextOptionsBuilder.ConfigureWarnings
API (event id 'CoreEventId.CompilingQueryModel'). ConfigureWarnings can be used when overriding the
DbContext.OnConfiguring method or using AddDbContext on the application service provider.

But I haven't been able to suppress this one (which appears 3x, once for each of 3 different columns):

warn: Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelValidator[1]
No type was specified for the decimal column 'UnitPrice' on entity type 'OrderDetail'. This will cause values to be
silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type
that can accomadate all the values using 'ForSqlServerHasColumnType()'. To configure this warning use the DbContextOpt
ionsBuilder.ConfigureWarnings API (event id 'SqlServerEventId.DefaultDecimalTypeWarning'). ConfigureWarnings can be used
when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.

I can't find an overload of Ignore that takes a SqlServerEventId, not sure if that's an oversight or NYI or what (note I can find an overload for InMemoryEventId and an overload for RelationalEventId)...

Discussion: Using custom crossgen for JitBench

I'm looking for a way to force the dotnet store in AspNet-GenerateStore.ps1 to pickup a custom crossgen (say, available at D:\coreclr\bin\Product\Windows_NT.x64.Release) to generate native images, rather than use the version pulled in to JitBench\.temp\Optimize\netcoreapp. Any suggestions for this? @rynowak @litian2025

JitBench dev branch not using master branch builds of CoreCLR

When I follow the instructions in the dev branch README, I see this:

Setting JITBENCH_FRAMEWORK_VERSION to 2.1.0-dev-di-25621-02

which presumably corresponds to coreclr's dev/defaultintf branch rather than its master branch.

The scripts here seem to be behaving properly, but passing -Channel master to Dotnet-Install.ps1 is now returning dev-di builds. I don't know if we should be specifying some other -Channel (or even where to get a list of available channels and what they're for) or if -Channel master should not be returning dev-di builds or what, but unless we're using code that depends on the default interface features I'd like to be able to continue running against builds from coreclr's master branch.

JitBench should log to console where the binaries are loaded from

We should pick a candidate like Microsoft.AspNetCore.Hosting and check whether the assembly was loaded from the bin directory or not.

This should log to the console:
ASP.NET loaded from bin
OR
ASP.NET loaded from store

This way we can easily verify in logs and scripts that the crossgen'ed binaries were used.

Add View Compilation

Compiling the views on publish is part of our user scenario for 2.0.0 and we expect it to be the default for all but local development.

This is useful for the ASP.NET team to be able to track the impact of this feature on startup, and also potentially useful for the CLR team since it requires a different set of dependencies.

Dev branch build is broken

I see that the build is currently flagged as being broken, but there is no issue or content in PR that explains what the current build break looks like, so I am adding this issue.

I am building a standalone version using "-r win10-x64"
I get two compilation errors:

D:\fxkit\JitBench\src\MusicStore>dotnet publish -r win10-x64 -o pubdir
Microsoft (R) Build Engine version 15.3.246.41955 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Models\MusicStoreContext.cs(7,36): error CS0246: The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) [D:\fxkit\JitBench\src\MusicStore\MusicStore.csproj]
Models\MusicStoreContext.cs(9,18): error CS0311: The type 'MusicStore.Models.ApplicationUser' cannot be used as type parameter 'TUser' in the generic type or method 'IdentityDbContext<TUser>'. There is no implicit reference conversion from 'MusicStore.Models.ApplicationUser' to 'Microsoft.AspNetCore.Identity.IdentityUser'. [D:\fxkit\JitBench\src\MusicStore\MusicStore.csproj]

Add CI for JitBench

We should have some kind of CI running here to make sure that the dev branch doesn't break due to ASP.NET changes.

Enable naive latency measurements

Measure latency on single requests: consider using same measurements for steady state.
Investigate less invasive way of collecting data points.
Steady state could simply output data on the console every 1000 or so requests, making it non-invasive.
Latency will need to collect all data points, making it a bit trickier.
Moving avg/variance?
Or simply accumulate all values in a large enough pre-allocated array and post process?

We are looking for whatever takes the least resource overall.

All branches currently broken

I'm seeing excessive CPU usage and build failures on the CI due to the dotnet store step running for an indefinite amount of time.

Currently investigating, but all runs appear to be blocked.

Dev branch README instructions currently don't seem to get latest CoreCLR bits

I'm seeing some behavior I can't explain, don't know which part if any is wrong or if I'm just misunderstanding something.

I thought the dev branch should always be running against "the latest" CoreCLR bits, and that doesn't seem to be the case today, but maybe there is no "the" latest?

Anyway, if I follow the steps in the readme today, after running the two dotnet-install.ps1 commands, dotnet --info gives me this:

.NET Command Line Tools (2.1.0-preview1-007214)

Product Information:
 Version:            2.1.0-preview1-007214
 Commit SHA-1 hash:  2956c548b9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   D:\Source\JitBench\.dotnet\sdk\2.1.0-preview1-007214\

Microsoft .NET Core Shared Framework Host

  Version  : 2.1.0-preview2-25616-02
  Build    : 8aa34a95bad481e1b5e4c8286e5cb2d7cb6ed943

As I understand it, the 2.1.0-preview2-25616-02 there means this corresponds to https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.NETCore.App/2.1.0-preview2-25616-02

Question 1: Why is that getting 2.1.0-preview2-25616-02 when 2.1.0-preview2-25711-01 is available?

At any rate, the info page for that nuget package/version (NetCoreApp 2.1.0-preview2-25616-02) repeats the 8aa34a95bad481e1b5e4c8286e5cb2d7cb6ed943 hash that matches the "Build" line of the dotnet --info output; presumably this corresponds to commit dotnet/core-setup@8aa34a9. Browsing the core-setup files at that commit, dependencies.props points to CoreCLR runtime package version 2.1.0-preview2-25610-02.

This in turn presumably refers to https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.NETCore.Runtime.CoreCLR/2.1.0-preview2-25610-02, which references dc2ffcdff2fb19e4b252cec3bc6672400a375c1e , which presumably is commit dotnet/coreclr@dc2ffcd, a commit from August 10.

Following the same chain from the latest preview2 version of Microsoft.NETCore.App (https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.NETCore.App/2.1.0-preview2-25711-01), it seems to point to dotnet/core-setup@4cd37c5, where dependencies.props points to CoreCLR runtime package version 2.1.0-preview2-25707-02, which references dotnet/coreclr@49676af, a commit from September 6.

So, even assuming that we want preview2 bits, I don't understand why we're getting the August 10 bits instead of the September 6 bits.

But even September 6 was a while ago. I notice that Microsoft.NETCore.App package version 2.1.0-preview1-25719-04 has a newer date, and indeed following the trail through dotnet/core-setup@b5c917c via dependency.props to Microsoft.NETCore.Runtime.CoreCLR package version 2.1.0-preview1-25718-02, it references commit dotnet/coreclr@cd6b92a, which is a commit from September 16.

What's more, core-setup's current master branch's dependencies.props references a "preview1" version, not a "preview2" version, and there hasn't been a new "preview2" package since September 11, so I don't know if "preview2" got dropped or is in some branch/"channel" other than "master" or what...

Should something in the readme steps or the package generation/publishing be different such that we could be running against the September 16 CoreCLR bits instead?

Define Branching Plan for aspnet/JitBench

A recent PR generated a lot of discussion about what the scenarios and requirements are for startup testing. I want to put forth a plan here and make sure that we've covered everyone's concerns.

Music Store App Requirements

I want to first point out a few requirements just from the standpoint of the app that help drive this discussion in a more practical version.

First, the Music Store app has a strong degree of coupling to a release of ASP.NET. We break things more frequently than the BCL, and ASP.NET 2.0 (current development) has already numerous breaking changes that impact the Music Store app. So, because the source code of the app is fixed in a given branch, it means that each branch needs to target first and foremost a specific ASP.NET release (or current development).

Secondly, the app itself has very little coupling to the release of the .NET shared framework besides what ASP.NET requires. We (ASP.NET) are generally going to be sticking with the netstandard1.6 target for most of our libraries. Where we do get into trouble here with coupling to .NET is the SDK. Any changes which come down the pipe that break the project file require new SDKs. Fortunately clrjit.dll lives in the shared framework. I believe dotnet cache also uses the clrjit.dll from the shared framework - but we might want to confirm that.

TLDR - Music Store is is coupled to a release of ASP.NET but is very flexible with respect to the version of the shared-framework/JIT.

Requirements from the Runtime Team

Here's a summary of the requirements I've been hearing from various runtime team members. If you don't see your feedback captured here, let me know!

  • We want to target a stable version of ASP.NET so we can easier understand the impact of runtime changes. We also want to target latest development of ASP.NET, but this is lower priority.
  • We want to make sure that R2R/crossgen and the app are run with the same version of the JIT. Running a new JIT for runtime JIT but an older JIT for R2R/crossgen only give us half the picture.
  • We want to be able to select the version of dotnet/shared-framework for a given run.
  • We want to be able to run on all platforms/architectures where dotnet runs

The proposal

My proposal is that we have a branch-per-ASP.NET release as well as a special branch for the current development of ASP.NET. The code and project file of MusicStore will be based on the specific ASP.NET release targeted by its resident branch. Each branch will support the minimum version of the dotnet shared framework supported by that ASP.NET release and all newer versions of dotnet - including latest development. This supports the requirement to test changes in the runtime which keeping the ASP.NET libraries and app fixed.

Example
Once 2.0.0-preview1 is released, the release-2.0.0-preview1 branch will support the 2.0.0-preview1 release of ASP.NET and the 2.0.0-preview1 release of the SDK/shared-framework. It will also be possible to use any newer version of the SDK/shared-framework using this branch.

The 2.0.0 release is a major change from the 1.0.0 dotnet/ASP.NET releases. Much of the functionality infrastructure we use (such as dotnet cache) is not available in in the older releases. For that reason I propose that we create/support branches of the 1.0.0 family of releases only as needed by our business requirements. Assume that everything mentioned here applies to the 2.0.0 family of releases and all subsequent releases. When we maintain a branch of the 1.0.0 family it will be somewhat ad-hoc and will not support all of the knobs and dials of the newer bits.

In each branch starting with release-2.0.0-preview1 we'll support performing the crossgen/R2R operation in the test environment. This satisfies the requirement that we use a single runtime version for both runtime JIT and crossgen R2R.

In each branch starting with release-2.0.0-preview1 we'll support performing the full set of options for testing in all architectures and platforms supported by dotnet. This support will not require separate branches, just separate scripts where needed (powershell vs bash)

In each branch starting with release-2.0.0-preview1 we'll support a number of variations on the publishing and running of MusicStore. None of these changes require a significantly different workflow, they just require testing and documenting them. This can include but is not limited to:

  • Multi-tiered jitting
  • View Compilation on publish (ASP.NET production scenario)
  • Running without R2R/crossgen binaries

Unknowns

It's not clear yet what our (ASP.NET) requirements will be for what we want to automate and measure. I would suppose that we would be much more interested in the end-to-end scenarios - what's the difference between 1.0.0 of dotnet/ASP.NET and 2.0.0 of dotnet/ASP.NET - what's the impact of precompiled views? - what's the impact of tiered JIT?. All of these things are just twists on how to publish/run the MusicStore app, and so I don't think they need to affect our overall strategy.

It's not yet clear to me to what degree runtime team members what to hack a local build of the shared framework and iterate locally. The concern here is that dotnet cache goes out and restores a build of the shared framework to use for running crossgen. If we need to be able to do this locally as part of a dev inner loop, then we should request this feature from the SDK team as an additional parameter.

Appendix A: Original Feedback

I think I've addressed all of these points in the strategy and discussion. If you think your concerns are not sufficiently addressed then say so and we'll figure it out.

From @AndyAyersMS

Aspnetcore-dev churns pretty frequently, with only a day or two of packages kept around. The corequisite churns CLI somewhat less frequently, not sure what the policy is there for updates.

So with fetch-latest policy we run the risk of being unable to differentiate perf changes caused by asp changes from those caused by jit/runtime/framework changes.

We also may be unable to root-cause and repro past runs because older packages aren't available.

For the jit team's use it would be more ideal if the aspnet/cli side of things did not update automatically but could remain stable for some predictable interval -- a month would be good. We can have a separate "scout ahead" run that uses latest bits if we want to try and track both.

I also agree with Joseph that running with some or perhaps even most of the code produced with an older jit is going to cause further confusion. We'd need to be able to regenerate all these bits with a newer jit / runtime / framework. Otherwise we might have latent perf surprises when the pregenerated code picks up a newer jit.


From @JosephTremoulet

@AndyAyersMS I think of the 'dev' branch of this repo (which is what this PR is targeting) as the "scout ahead" run -- the simplest place to get a latestAspnet-with-latestCoreclr run to do an A/B comparison for a particular change.

I agree that doesn't make it ideal for analyzing the impact over time of jit changes specifically. Presuming we want both, I don't know if we should just use the master branch (which is tied to released aspnet) for that or have CI runs of the dev branch against fixed aspnet snapshots like you're describing.

Having the flexibility in the dev branch to specify a version (CI could use this) or just grab latest (simplifies joint aspnet/jit development) would probably be ideal. I'd argue the default should be to grab latest.


From @lt72

Andy has a good point. We should definitely have a run configuration with a stable framework and latest JIT. The main reason we created this repo is to test the startup (most important) and steady state perfs of the latest ASP.NET Core w and w/o tiered jitting. Startup is a target for v2, so it should definitely take precedence. Considering that we did not manage to have a stable run for a while, I would suggest to make this work predictably in one configuration and work on other configurations immediately after.

RE: platform priorities: from highest to lowest:

Win x64
Linux x64
Win x86
Linux x86
@rynowak and @davmason : what it would take to create another run configuration that mantains a stable framework as Andy suggested? do we need another branch?

dotnet publish failing for 2.0 x86

When running through the instructions for building MusicStore using architecture x86 and rid win7-x86, and channel release/2.0.0, dotnet publish fails with the following output:

  MusicStore -> C:\michelm\JitBench\src\MusicStore\bin\Release\netcoreapp2.0\MusicStore.dll
  Object reference not set to an instance of an object.
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.Execute()
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompileRunCommand.<Configure>b__17_0()
     at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
     at Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.Internal.PrecompilationApplication.Execute(String[] args)
C:\Users\michelm\.dotnet\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.0-preview1-final\build\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.targets(26,5): error MSB3073: The command "dotnet exec --runtimeconfig "C:\michelm\JitBench\src\MusicStore\bin\Release\netcoreapp2.0\MusicStore.runtimeconfig.json" --depsfile "C:\michelm\JitBench\src\MusicStore\bin\Release\netcoreapp2.0\MusicStore.deps.json" "C:\Users\michelm\.dotnet\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.0-preview1-final\build\netcoreapp2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilation.dll" @"obj\Release\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"" exited with code 1. [C:\michelm\JitBench\src\MusicStore\MusicStore.csproj]

Announcement: Precompilation was on by default

Summary
We were hit by a change in the web SDK's default behavior, and view compilation during publishing got turned on by default for rel/2.0.0-* branches. I don't have an estimate about when this happened.

Impact
This should have a big effect on the 'first request' numbers (~1500ms).

Scenarios
The way to think about this is:
View Compilation on Publish on - simulates startup of a published application
View Compilation on Publish off - simulates startup during local development

Both of these are worth measuring, but from my team's point of view, view compilation off is more interesting when talking about optimizations for startup.

Plans
My plan is to turn this back off. I will add some output to the console spew to make it obvious which one was used.

Use dotnet publish .... /p:MvcRazorCompileOnPublish=true to turn this on.


As usual, if you have concerns or feedback about this plan please raise it soon. Otherwise I will make this change in the next few days.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.