Skip to content

Commit

Permalink
Merge pull request #23 from TechEmpower/master
Browse files Browse the repository at this point in the history
aa
  • Loading branch information
smthing authored Feb 28, 2022
2 parents 5a96394 + c302e1a commit 5c25976
Show file tree
Hide file tree
Showing 340 changed files with 6,377 additions and 9,085 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,18 @@ jobs:
# we'd like to try and do the diffing before github_actions_clean & setup.
# This will run the tests exactly as you would in your own vm:
docker network create tfb > /dev/null 2>&1 && docker run --network=tfb -v /var/run/docker.sock:/var/run/docker.sock --mount type=bind,source=`pwd`,target=/FrameworkBenchmarks techempower/tfb --mode verify --test-dir $RUN_TESTS --results-environment Github-Actions;
dependabot:
needs: verify
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 1 addition & 1 deletion frameworks/C/lwan/lwan-lua.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.10
FROM ubuntu:21.10

RUN apt-get update -yqq && \
apt-get install -yqq \
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C/lwan/lwan.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.10
FROM ubuntu:21.10

RUN apt-get update -yqq && \
apt-get install -yqq \
Expand Down
2 changes: 1 addition & 1 deletion frameworks/C/nginx/nginx.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.10
FROM ubuntu:21.10

ARG DEBIAN_FRONTEND=noninteractive

Expand Down
5 changes: 4 additions & 1 deletion frameworks/CFML/CFML/cfml-adobe.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ortussolutions/commandbox:3.2.1
FROM ortussolutions/commandbox:3.4.4

ENV cfconfig_adminPassword=password
ENV box_server_runwar_args=--cache-servlet-paths=true

COPY ./src/server-adobe.json /app/server.json
COPY ./src/.cfconfig.json /app/.cfconfig.json
Expand All @@ -10,6 +11,8 @@ RUN box install --verbose --force

RUN ${BUILD_DIR}/util/warmup-server.sh

RUN cd /app && box cfpm install postgresql

RUN export FINALIZE_STARTUP=true;$BUILD_DIR/run.sh;unset FINALIZE_STARTUP

HEALTHCHECK NONE
Expand Down
3 changes: 2 additions & 1 deletion frameworks/CFML/CFML/cfml.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ortussolutions/commandbox:3.2.1
FROM ortussolutions/commandbox:3.4.4

ENV cfconfig_adminPassword=password
ENV box_server_runwar_args=--cache-servlet-paths=true

COPY ./src/server-lucee.json /app/server.json
COPY ./src/.cfconfig.json /app/.cfconfig.json
Expand Down
2 changes: 1 addition & 1 deletion frameworks/CFML/CFML/src/server-adobe.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"maxRequests":512
},
"app":{
"cfengine":"adobe@2018"
"cfengine":"adobe@2021"
}
}
2 changes: 1 addition & 1 deletion frameworks/CFML/CFML/src/server-lucee.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"maxRequests" : 512
},
"app" : {
"cfengine" : "[email protected]-rc"
"cfengine" : "[email protected]"
}
}
5 changes: 4 additions & 1 deletion frameworks/CFML/coldbox/coldbox-adobe.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ortussolutions/commandbox:3.2.1
FROM ortussolutions/commandbox:3.4.4

ENV cfconfig_adminPassword=password
ENV box_server_runwar_args=--cache-servlet-paths=true

COPY ./src/server-adobe.json /app/server.json
COPY ./src/.cfconfig.json /app/.cfconfig.json
Expand All @@ -10,6 +11,8 @@ RUN box install --verbose --force

RUN ${BUILD_DIR}/util/warmup-server.sh

RUN cd /app && box cfpm install postgresql,feed

RUN export FINALIZE_STARTUP=true;$BUILD_DIR/run.sh;unset FINALIZE_STARTUP

HEALTHCHECK NONE
Expand Down
1 change: 1 addition & 0 deletions frameworks/CFML/coldbox/coldbox.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ortussolutions/commandbox:3.2.1

ENV cfconfig_adminPassword=password
ENV box_server_runwar_args=--cache-servlet-paths=true

COPY ./src/server-lucee.json /app/server.json
COPY ./src/.cfconfig.json /app/.cfconfig.json
Expand Down
2 changes: 1 addition & 1 deletion frameworks/CFML/coldbox/src/server-adobe.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"maxRequests":512
},
"app":{
"cfengine":"adobe@2018"
"cfengine":"adobe@2021"
}
}
2 changes: 1 addition & 1 deletion frameworks/CFML/coldbox/src/server-lucee.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"maxRequests":512
},
"app":{
"cfengine":"[email protected]-rc"
"cfengine":"[email protected]"
}
}
8 changes: 8 additions & 0 deletions frameworks/CSharp/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*.cs]
indent_style = space
indent_size = 4

[*.json]
indent_size = 2

csharp_style_namespace_declarations = file_scoped
19 changes: 19 additions & 0 deletions frameworks/CSharp/appmpower/appmpower-ado-pg.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.100 AS build
RUN apt-get update
RUN apt-get -yqq install clang zlib1g-dev libkrb5-dev libtinfo5

WORKDIR /app
COPY src .
RUN mv ./appMpower.ado ./appMpower.csproj
RUN dotnet publish -c Release -o out -r linux-x64

# Construct the actual image that will run
FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime
RUN apt-get update

WORKDIR /app
COPY --from=build /app/out ./

EXPOSE 8080

ENTRYPOINT ["./appMpower"]
22 changes: 22 additions & 0 deletions frameworks/CSharp/appmpower/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@
"display_name": "appMpower [Middleware, My, Odbc]",
"notes": "",
"versus": "aspcore-mw-ado-my"
},
"ado-pg": {
"db_url": "/db",
"query_url": "/queries?c=",
"update_url": "/updates?c=",
"fortune_url": "/fortunes",
"cached_query_url": "/cached-worlds?c=",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "Postgres",
"framework": "appmpower",
"language": "C#",
"orm": "Raw",
"platform": ".NET",
"flavor": "CoreCLR",
"webserver": "Kestrel",
"os": "Linux",
"database_os": "Linux",
"display_name": "appMpower [Middleware, Pg, Ado]",
"notes": "",
"versus": "aspcore-mw-ado-pg"
}
}
]
Expand Down
18 changes: 17 additions & 1 deletion frameworks/CSharp/appmpower/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,20 @@ os = "Linux"
orm = "Raw"
platform = ".NET"
webserver = "Kestrel"
versus = "aspcore-mw-ado-my"
versus = "aspcore-mw-ado-my"

[ado-pg]
urls.db = "/db"
urls.query = "/queries?c="
urls.update = "/updates?c="
urls.fortune = "/fortunes"
urls.cached_query = "/cached-worlds?c="
approach = "Realistic"
classification = "Micro"
database = "Postgres"
database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = ".NET"
webserver = "Kestrel"
versus = "aspcore-mw-ado-pg"
11 changes: 0 additions & 11 deletions frameworks/CSharp/appmpower/src/ConnectionStrings.cs

This file was deleted.

6 changes: 4 additions & 2 deletions frameworks/CSharp/appmpower/src/Db/DataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ namespace appMpower.Db
public static class DataProvider
{
#if MYSQL
public static bool IsOdbcConnection = true;
public const string ConnectionString = "Driver={MariaDB};Server=tfb-database;Database=hello_world;Uid=benchmarkdbuser;Pwd=benchmarkdbpass;Pooling=false;OPTIONS=67108864;FLAG_FORWARD_CURSOR=1";
#elif ADO
public const string ConnectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=8;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000";
//public const string ConnectionString = "Server=localhost;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=9;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000";
#else
public static bool IsOdbcConnection = true;
public const string ConnectionString = "Driver={PostgreSQL};Server=tfb-database;Database=hello_world;Uid=benchmarkdbuser;Pwd=benchmarkdbpass;UseServerSidePrepare=1;Pooling=false";
//public const string ConnectionString = "Driver={PostgreSQL};Server=localhost;Database=hello_world;Uid=benchmarkdbuser;Pwd=benchmarkdbpass;UseServerSidePrepare=1;Pooling=false";
#endif
}
}
3 changes: 0 additions & 3 deletions frameworks/CSharp/appmpower/src/Db/PooledCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Data;
using System.Data.Common;
using System.Data.Odbc;
using System.Threading.Tasks;

namespace appMpower.Db
Expand Down Expand Up @@ -178,13 +177,11 @@ public IDataReader ExecuteReader()

public async Task<int> ExecuteNonQueryAsync()
{
if (DataProvider.IsOdbcConnection) return await (_dbCommand as OdbcCommand).ExecuteNonQueryAsync();
return await (_dbCommand as DbCommand).ExecuteNonQueryAsync();
}

public async Task<DbDataReader> ExecuteReaderAsync(CommandBehavior behavior)
{
if (DataProvider.IsOdbcConnection) return await (_dbCommand as OdbcCommand).ExecuteReaderAsync(behavior);
return await (_dbCommand as DbCommand).ExecuteReaderAsync(behavior);
}

Expand Down
9 changes: 4 additions & 5 deletions frameworks/CSharp/appmpower/src/Db/PooledConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ internal PooledCommand GetCommand(string commandText, PooledCommand pooledComman
pooledCommand.DbCommand.CommandText = commandText;
pooledCommand.PooledConnection = this;

//For future use with non odbc drivers like Npgsql which do not support Prepare
if (DataProvider.IsOdbcConnection)
{
pooledCommand.DbCommand.Prepare();
}
//For non odbc drivers like Npgsql which do not support Prepare
#if !ADO
pooledCommand.DbCommand.Prepare();
#endif

//Console.WriteLine("prepare pool connection: " + this._number + " for command " + _pooledCommands.Count);
}
Expand Down
22 changes: 6 additions & 16 deletions frameworks/CSharp/appmpower/src/Db/PooledConnections.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Concurrent;
using System.Data.Odbc;
using System.Threading.Tasks;

namespace appMpower.Db
Expand All @@ -8,12 +7,7 @@ public static class PooledConnections
{
private static bool _connectionsCreated = false;
private static short _createdConnections = 0;

#if MYSQL
private static short _maxConnections = 500;
#else
private static short _maxConnections = 500;
#endif
private static short _maxConnections = 240;

private static ConcurrentStack<PooledConnection> _stack = new ConcurrentStack<PooledConnection>();
private static ConcurrentQueue<TaskCompletionSource<PooledConnection>> _waitingQueue = new ConcurrentQueue<TaskCompletionSource<PooledConnection>>();
Expand All @@ -39,15 +33,11 @@ public static async Task<PooledConnection> GetConnection(string connectionString
{
pooledConnection = new PooledConnection();

if (DataProvider.IsOdbcConnection)
{
pooledConnection.DbConnection = new OdbcConnection(connectionString);
}
else
{
//For future use with non odbc drivers which can be AOT compiled without reflection
//pooledConnection.DbConnection = new NpgsqlConnection(connectionString);
}
#if ADO
pooledConnection.DbConnection = new Npgsql.NpgsqlConnection(connectionString);
#else
pooledConnection.DbConnection = new System.Data.Odbc.OdbcConnection(connectionString);
#endif

_createdConnections++;

Expand Down
6 changes: 5 additions & 1 deletion frameworks/CSharp/appmpower/src/HttpApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ public async Task ProcessRequestAsync(IFeatureCollection featureCollection)
count = 500;
}

//Json.RenderMany(httpResponse.Headers, httpResponseBody.Writer, await RawDb.LoadMultipleQueriesRows(count), _worldSerializer);
#if ADO
Json.RenderMany(httpResponse.Headers, httpResponseBody.Writer, await RawDb.LoadMultipleQueriesRows(count), _worldSerializer);
#else
Json.RenderMany(httpResponse.Headers, httpResponseBody.Writer, await RawDb.ReadMultipleRows(count), _worldSerializer);
#endif

return;
}
else if (pathStringLength == 9 && pathStringStart == "f")
Expand Down
4 changes: 2 additions & 2 deletions frameworks/CSharp/appmpower/src/Kestrel/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void RenderOne<T>(IHeaderDictionary headerDictionary, PipeWriter p

jsonSerializer.Serialize(utf8JsonWriter, t);
utf8JsonWriter.Flush();
headerDictionary.Add(new KeyValuePair<string, StringValues>("Content-Length", ((uint)utf8JsonWriter.BytesCommitted).ToString()));
headerDictionary.Add(new KeyValuePair<string, StringValues>("Content-Length", utf8JsonWriter.BytesCommitted.ToString()));
}

public static void RenderMany<T>(IHeaderDictionary headerDictionary, PipeWriter pipeWriter, T[] tArray, IJsonSerializer<T> jsonSerializer)
Expand All @@ -52,7 +52,7 @@ public static void RenderMany<T>(IHeaderDictionary headerDictionary, PipeWriter

utf8JsonWriter.WriteEndArray();
utf8JsonWriter.Flush();
headerDictionary.Add(new KeyValuePair<string, StringValues>("Content-Length", ((uint)utf8JsonWriter.BytesCommitted).ToString()));
headerDictionary.Add(new KeyValuePair<string, StringValues>("Content-Length", utf8JsonWriter.BytesCommitted.ToString()));
}
}
}
22 changes: 22 additions & 0 deletions frameworks/CSharp/appmpower/src/Microsoft/BatchUpdateString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ public static string Query(int batchSize)
{
sb.Append("UPDATE world SET randomNumber=? WHERE id=?;");
}
#elif ADO
/*
sb.Append("UPDATE world SET randomNumber = temp.randomNumber FROM (VALUES ");
Enumerable.Range(0, lastIndex).ToList().ForEach(i => sb.Append($"(@i{i}, @r{i}), "));
sb.Append($"(@i{lastIndex}, @r{lastIndex}) ORDER BY 1) AS temp(id, randomNumber) WHERE temp.id = world.id");
*/

sb.Append("UPDATE world SET randomNumber=CASE id ");

for (int i = 0; i < batchSize; i++)
{
sb.Append("WHEN @i" + i + " THEN @r" + i + " ");
}

sb.Append("ELSE randomnumber END WHERE id IN(");

for (int i = 0; i < lastIndex; i++)
{
sb.Append("@j" + i + ",");
}

sb.Append("@j" + lastIndex + ")");
#else
sb.Append("UPDATE world SET randomNumber=CASE id ");

Expand Down
Loading

0 comments on commit 5c25976

Please sign in to comment.