Browse Source

Merge branch 'PR489' into development

tfb 12 years ago
parent
commit
299d48d755

+ 21 - 0
nancy/benchmark_config

@@ -40,6 +40,27 @@
       "display_name": "nancy",
       "display_name": "nancy",
       "notes": "",
       "notes": "",
       "versus": ""
       "versus": ""
+    },
+    "libevent2": {
+      "setup_file": "setup_libevent",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/db/",
+      "port": 8080,
+	        "approach": "Realistic",
+      "classification": "Micro",
+      "database": "MySQL",
+      "framework": "nancy",
+      "language": "C#",
+      "orm": "Raw",
+      "platform": "Mono",
+      "webserver": "nginx",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "nancy-libevent",
+      "notes": "",
+      "versus": ""
+	  
     }
     }
   }]
   }]
 }
 }

BIN
nancy/lib/Nancy.Hosting.Event2.dll


+ 24 - 0
nancy/nginx.conf.libevent

@@ -0,0 +1,24 @@
+# worker_processes n;
+pid /tmp/nginx.pid;
+error_log /dev/null crit;
+
+events {
+    worker_connections 8192;
+}
+
+http {
+    access_log off;
+
+    #upstream mono {
+    #    server 127.0.0.1:9001;
+    #}
+    include nginx.upstream.conf;
+
+    server {
+        listen 8080;
+
+        location / {
+            proxy_pass http://mono;
+        }
+    }
+}

+ 40 - 0
nancy/setup_libevent.py

@@ -0,0 +1,40 @@
+import subprocess
+import sys
+import setup_util
+import os
+
+root = os.getcwd() + "/nancy"
+app = root + "/src"
+
+def start(args):
+  if os.name == 'nt':
+    return 1
+  
+  setup_util.replace_text(app + "/Web.config", "localhost", args.database_host)
+
+  try:
+    # build
+    subprocess.check_call("rm -rf bin obj", shell=True, cwd=app)
+    subprocess.check_call("xbuild /p:Configuration=Release", shell=True, cwd=app)
+    
+    # nginx
+    workers = 'worker_processes ' + str(args.max_threads) + ';'
+    subprocess.check_call('echo "upstream mono {\n' + ';\n'.join('\tserver 127.0.0.1:' + str(port) for port in range(9001, 9001 + args.max_threads)) + ';\n}" > ' + root + '/nginx.upstream.conf', shell=True);
+    subprocess.check_call('sudo /usr/local/nginx/sbin/nginx -c ' + root + '/nginx.conf.libevent -g "' + workers + '"', shell=True)
+    
+    # fastcgi
+    os.environ['MONO_GC_PARAMS']="nursery-size=16m"
+    for port in range(9001, 9001 + args.max_threads):
+      subprocess.Popen("mono-sgen -O=all LibeventHost/bin/Release/LibeventHost.exe 127.0.0.1 " + str(port) + " " + args.database_host + " &", shell=True, cwd=app)
+    return 0
+  except subprocess.CalledProcessError:
+    return 1
+
+def stop():
+  if os.name == 'nt':
+    return 0
+  
+  subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + root + "/nginx.conf -s stop", shell=True)
+  subprocess.check_call("rm -f " + root + "/nginx.upstream.conf", shell=True)
+  subprocess.check_call("pkill -9 mono-sgen", shell=True)
+  return 0

+ 1 - 1
nancy/src/DbModule.cs

@@ -14,7 +14,7 @@ namespace NancyBenchmark
 {
 {
     public class DbModule : NancyModule
     public class DbModule : NancyModule
     {
     {
-        private static readonly string MYSQL_CONNECTION_STRING;
+        public static string MYSQL_CONNECTION_STRING;
         
         
         static DbModule()
         static DbModule()
         {
         {

+ 6 - 0
nancy/src/LibeventHost/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
+    </startup>
+</configuration>

+ 72 - 0
nancy/src/LibeventHost/LibeventHost.csproj

@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{64A4525D-688B-4286-9126-78E0D06CFD83}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>LibeventHost</RootNamespace>
+    <AssemblyName>LibeventHost</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Nancy">
+      <HintPath>..\..\lib\Nancy.0.17.1\lib\net40\Nancy.dll</HintPath>
+    </Reference>
+    <Reference Include="Nancy.Hosting.Event2">
+      <HintPath>..\..\lib\Nancy.Hosting.Event2.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\NancyBenchmark.csproj">
+      <Project>{80cf41ab-455b-4eb9-bfcc-3f8c4e1d8354}</Project>
+      <Name>NancyBenchmark</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 32 - 0
nancy/src/LibeventHost/Program.cs

@@ -0,0 +1,32 @@
+using System;
+using Nancy.Hosting.Event2;
+using Nancy;
+using System.Threading;
+
+namespace LibeventHost
+{
+    internal class MainClass
+    {
+        public static void Main(string[] args)
+        {
+            var host = args[0];
+            var port = int.Parse(args[1]);
+            var dbHost = args[2];
+            LibLocator.Init();
+            NancyBenchmark.DbModule.MYSQL_CONNECTION_STRING = "server=localhost;user id=benchmarkdbuser;password=benchmarkdbpass;database=hello_world"
+                .Replace("localhost", dbHost);
+            AddToIndex();
+            var threads = 20*Environment.ProcessorCount;
+            ThreadPool.SetMaxThreads(threads, threads);
+            ThreadPool.SetMinThreads(threads, threads);
+            new NancyEvent2Host(host, port, new DefaultNancyBootstrapper()).Start();
+
+        }
+
+        private static void AddToIndex()
+        {
+            Nancy.Bootstrapper.AppDomainAssemblyTypeScanner
+                 .AddAssembliesToScan(typeof (NancyBenchmark.JsonModule).Assembly);
+        }
+    }
+}

+ 6 - 0
nancy/src/NancyBenchmark.sln

@@ -8,6 +8,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
 		NuGet.config = NuGet.config
 		NuGet.config = NuGet.config
 	EndProjectSection
 	EndProjectSection
 EndProject
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibeventHost", "LibeventHost\LibeventHost.csproj", "{64A4525D-688B-4286-9126-78E0D06CFD83}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU
@@ -18,6 +20,10 @@ Global
 		{80CF41AB-455B-4EB9-BFCC-3F8C4E1D8354}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{80CF41AB-455B-4EB9-BFCC-3F8C4E1D8354}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{80CF41AB-455B-4EB9-BFCC-3F8C4E1D8354}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{80CF41AB-455B-4EB9-BFCC-3F8C4E1D8354}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{80CF41AB-455B-4EB9-BFCC-3F8C4E1D8354}.Release|Any CPU.Build.0 = Release|Any CPU
 		{80CF41AB-455B-4EB9-BFCC-3F8C4E1D8354}.Release|Any CPU.Build.0 = Release|Any CPU
+		{64A4525D-688B-4286-9126-78E0D06CFD83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{64A4525D-688B-4286-9126-78E0D06CFD83}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{64A4525D-688B-4286-9126-78E0D06CFD83}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{64A4525D-688B-4286-9126-78E0D06CFD83}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE

+ 1 - 1
toolset/setup/linux/installer.py

@@ -175,7 +175,7 @@ class Installer:
     # Mono
     # Mono
     #
     #
     self.__run_command("git clone git://github.com/mono/mono", retry=True)
     self.__run_command("git clone git://github.com/mono/mono", retry=True)
-    self.__run_command("git checkout mono-3.2.1", cwd="mono")
+    self.__run_command("git checkout mono-3.2.3", cwd="mono")
     self.__run_command("./autogen.sh --prefix=/usr/local", cwd="mono")
     self.__run_command("./autogen.sh --prefix=/usr/local", cwd="mono")
     self.__run_command("make get-monolite-latest", cwd="mono")
     self.__run_command("make get-monolite-latest", cwd="mono")
     self.__run_command("make EXTERNAL_MCS=${PWD}/mcs/class/lib/monolite/gmcs.exe", cwd="mono")
     self.__run_command("make EXTERNAL_MCS=${PWD}/mcs/class/lib/monolite/gmcs.exe", cwd="mono")