Skip to content
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

aspnet-async first implementation #762

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions aspnet-async/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.user
*.suo
*/bin/*
*/obj/*
lib/*
!lib/.nuget
10 changes: 10 additions & 0 deletions aspnet-async/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ASP.NET MVC on Windows in asynchronous mode

This benchmark suite is using the new asynchronous features of .NET 4.5 and MVC, and also a little known JSON serializer [Jil](https://github.com/kevin-montrose/Jil).

## Optimizations

* JSON serialization done with Jil
* Database tests are done asynchronously (including at the ADO.NET level)
* Database update test is done in batch (by concatenating all UPDATE statements in a single query)
* Web site is precompiled and using a single assembly
Empty file added aspnet-async/__init__.py
Empty file.
124 changes: 124 additions & 0 deletions aspnet-async/benchmark_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"framework": "aspnet-async",
"tests": [{
"default": {
"setup_file": "setup_iis",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "None",
"framework": "aspnet-mvc",
"language": "C#",
"orm": "Raw",
"platform": "NET",
"webserver": "IIS",
"os": "Windows",
"database_os": "Linux",
"display_name": "aspnet-async",
"notes": "",
"versus": ""
},
"jil": {
"setup_file": "setup_iis",
"json_url": "/json",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"framework": "aspnet",
"language": "C#",
"orm": "Raw",
"platform": "NET",
"webserver": "IIS",
"os": "Windows",
"database_os": "Linux",
"display_name": "aspnet-async-jil",
"notes": "",
"versus": ""
},
"mysql-raw": {
"setup_file": "setup_iis",
"db_url": "/db?providerName=MySQL",
"query_url": "/queries?providerName=MySQL&queries=",
"fortune_url": "/fortunes?providerName=MySQL",
"update_url": "/updates?providerName=MySQL&queries=",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "MySQL",
"framework": "aspnet-mvc",
"language": "C#",
"orm": "Raw",
"platform": "NET",
"webserver": "IIS",
"os": "Windows",
"database_os": "Linux",
"display_name": "aspnet-async-mysql",
"notes": "",
"versus": ""
},
"postgresql-raw": {
"setup_file": "setup_iis",
"db_url": "/db?providerName=PostgreSQL",
"query_url": "/queries?providerName=PostgreSQL&queries=",
"fortune_url": "/fortunes?providerName=PostgreSQL",
"update_url": "/updates?providerName=PostgreSQL&queries=",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "Postgres",
"framework": "aspnet-mvc",
"language": "C#",
"orm": "Raw",
"platform": "NET",
"webserver": "IIS",
"os": "Windows",
"database_os": "Linux",
"display_name": "aspnet-async-postgres",
"notes": "",
"versus": ""
},
"postgresql-raw-dotConnect": {
"setup_file": "setup_iis",
"db_url": "/db?providerName=PostgreSQL_dotConnect",
"query_url": "/queries?providerName=PostgreSQL_dotConnect&queries=",
"fortune_url": "/fortunes?providerName=PostgreSQL_dotConnect",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "Postgres",
"framework": "aspnet-mvc",
"language": "C#",
"orm": "Raw",
"platform": "NET",
"webserver": "IIS",
"os": "Windows",
"database_os": "Linux",
"display_name": "aspnet-async-postgres",
"notes": "Use dotConnect PostgreSQL provider instead of npgsql. Batch updates are not supported in Express edition.",
"versus": ""
},
"sqlserver-raw": {
"setup_file": "setup_iis",
"db_url": "/db?providerName=SQLServer",
"query_url": "/queries?providerName=SQLServer&queries=",
"fortune_url": "/fortunes?providerName=SQLServer",
"update_url": "/updates?providerName=SQLServer&queries=",
"port": 8080,
"approach": "Realistic",
"classification": "Fullstack",
"database": "SQLServer",
"framework": "aspnet-mvc",
"language": "C#",
"orm": "Raw",
"platform": "NET",
"webserver": "IIS",
"os": "Windows",
"database_os": "Windows",
"display_name": "aspnet-async-sqlserver",
"notes": "",
"versus": ""
}
}]
}
49 changes: 49 additions & 0 deletions aspnet-async/setup_iis.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
param($action)

$ErrorActionPreference = 'Stop'

# From http://zduck.com/2012/powershell-batch-files-exit-codes/
function Exec
{
[CmdletBinding()]
param (
[Parameter(Position=0, Mandatory=1)]
[scriptblock]$Command,
[Parameter(Position=1, Mandatory=0)]
[string]$ErrorMessage = "Execution of command failed.`n$Command"
)
& $Command
if ($LastExitCode -ne 0) {
throw "Exec: $ErrorMessage"
}
}

$wwwroot = "C:\FrameworkBenchmarks\aspnet-async\www"
$source = "C:\FrameworkBenchmarks\aspnet-async\src"
$msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"

# Stop
if (Get-WebSite -Name Benchmarks) { Remove-WebSite -Name Benchmarks }
Get-ChildItem -Path $wwwroot -Recurse -ErrorAction 'SilentlyContinue' | Remove-Item -Force -Recurse -ErrorAction 'SilentlyContinue' | Out-Null
Remove-Item -Force -Recurse $wwwroot -ErrorAction 'SilentlyContinue' | Out-Null

if (Test-Path IIS:\AppPools\BenchmarksAppPool) { Remove-Item IIS:\AppPools\BenchmarksAppPool -Force -Recurse }

if ($action -eq 'start') {
# Create and start application pool
$appPool = New-Item IIS:\AppPools\BenchmarksAppPool
$appPool.managedRuntimeVersion = "4.0"
$appPool.managedPipelineMode = 0 # Integrated
$appPool.queueLength = 9000 # max value = 9000, default = 1000
$appPool | Set-Item
Start-WebAppPool -Name BenchmarksAppPool

# Create a website in IIS
New-Item -Path $wwwroot -Type Directory -ErrorAction 'SilentlyContinue' | Out-Null
New-WebSite -Name Benchmarks -Port 8080 -PhysicalPath $wwwroot -ApplicationPool BenchmarksAppPool

# Build the project
Exec { & $msbuild "$source\AspNetAsyncBenchmark\AspNetAsyncBenchmark.csproj" /t:RestorePackages }
Exec { & $msbuild "$source\AspNetAsyncBenchmark\AspNetAsyncBenchmark.csproj" /p:Configuration=Release /t:Clean }
Exec { & $msbuild "$source\AspNetAsyncBenchmark\AspNetAsyncBenchmark.csproj" /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=prod }
}
22 changes: 22 additions & 0 deletions aspnet-async/setup_iis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import subprocess
import sys
import setup_util
import os

def start(args, logfile, errfile):
if os.name != 'nt':
return 1

try:
setup_util.replace_text("aspnet-async/src/AspNetAsyncBenchmark/Web.config", "localhost", args.database_host)
subprocess.check_call("powershell -Command .\\setup_iis.ps1 start", cwd="aspnet-async", stderr=errfile, stdout=logfile)
return 0
except subprocess.CalledProcessError:
return 1

def stop(logfile, errfile):
if os.name != 'nt':
return 0

subprocess.check_call("powershell -Command .\\setup_iis.ps1 stop", cwd="aspnet-async", stderr=errfile, stdout=logfile)
return 0
29 changes: 29 additions & 0 deletions aspnet-async/source_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
./aspnet-async/src
./aspnet-async/src/AspNetAsyncBenchmark.sln
./aspnet-async/src/AspNetAsyncBenchmark/AspNetAsyncBenchmark.csproj
./aspnet-async/src/AspNetAsyncBenchmark/Global.asax
./aspnet-async/src/AspNetAsyncBenchmark/Global.asax.cs
./aspnet-async/src/AspNetAsyncBenchmark/packages.config
./aspnet-async/src/AspNetAsyncBenchmark/Web.config
./aspnet-async/src/AspNetAsyncBenchmark/Web.Debug.config
./aspnet-async/src/AspNetAsyncBenchmark/Web.Release.config
./aspnet-async/src/AspNetAsyncBenchmark/App_Start
./aspnet-async/src/AspNetAsyncBenchmark/App_Start/FilterConfig.cs
./aspnet-async/src/AspNetAsyncBenchmark/App_Start/RouteConfig.cs
./aspnet-async/src/AspNetAsyncBenchmark/App_Start/WebApiConfig.cs
./aspnet-async/src/AspNetAsyncBenchmark/Controllers
./aspnet-async/src/AspNetAsyncBenchmark/Controllers/DbController.cs
./aspnet-async/src/AspNetAsyncBenchmark/Controllers/JsonController.cs
./aspnet-async/src/AspNetAsyncBenchmark/Controllers/PlainTextController.cs
./aspnet-async/src/AspNetAsyncBenchmark/Models
./aspnet-async/src/AspNetAsyncBenchmark/Models/Fortune.cs
./aspnet-async/src/AspNetAsyncBenchmark/Models/JsonMessage.cs
./aspnet-async/src/AspNetAsyncBenchmark/Models/SqlDb.cs
./aspnet-async/src/AspNetAsyncBenchmark/Models/World.cs
./aspnet-async/src/AspNetAsyncBenchmark/Properties
./aspnet-async/src/AspNetAsyncBenchmark/Properties/AssemblyInfo.cs
./aspnet-async/src/AspNetAsyncBenchmark/Properties/PublishProfiles
./aspnet-async/src/AspNetAsyncBenchmark/Properties/PublishProfiles/prod.pubxml
./aspnet-async/src/AspNetAsyncBenchmark/Views
./aspnet-async/src/AspNetAsyncBenchmark/Views/Web.config
./aspnet-async/src/AspNetAsyncBenchmark/Views/Db/Fortunes.cshtml
6 changes: 6 additions & 0 deletions aspnet-async/src/.nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file added aspnet-async/src/.nuget/NuGet.exe
Binary file not shown.
136 changes: 136 additions & 0 deletions aspnet-async/src/.nuget/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>

<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
Loading