Skip to content
Merged

aa #12

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f373faf
OfficeFloor avoid writer stream lock (#6623)
sagenschneider Jun 13, 2021
3946b33
rename handle (#6626)
smthing Jun 13, 2021
75264be
[php-ngx] Updateo to Nginx 1.21 (#6630)
joanhey Jun 14, 2021
e33ae56
Bump django from 3.1.5 to 3.1.12 in /frameworks/Python/django (#6629)
dependabot[bot] Jun 14, 2021
9f7be7f
Disable log subsystem (#6628)
NinoFloris Jun 15, 2021
1185453
Shorter db loop cycle (0.001 millisecond) + plaintext correction (#6658)
LLT21 Jun 16, 2021
1e45c83
Revert "Disable log subsystem (#6628)" (#6661)
NateBrady23 Jun 16, 2021
d02cb6c
Bump undertow-core in /frameworks/Java/undertow-jersey (#6660)
dependabot[bot] Jun 17, 2021
99a9502
Bump undertow-core in /frameworks/Java/light-java (#6659)
dependabot[bot] Jun 17, 2021
4cba05e
aiohttp improvements (#6663)
Dreamsorcerer Jun 21, 2021
ff8615a
Update pom.xml (#6665)
redkale Jun 21, 2021
b85ed88
Fixed broken links (#6672)
lukaseder Jun 22, 2021
180c2e1
Adding Python / async-worker framework (#6602)
diogommartins Jun 22, 2021
b10ea26
OfficeFloor supporting Cache Test (#6670)
sagenschneider Jun 22, 2021
f3b037a
Add TypeScript Deno + MongoDB Raw Test Cases (#6445)
hydrati Jun 22, 2021
06aafa9
[c#/beetlex] update BeetleX.Fasthttpapi 1.9.6, optimize platform cod…
beetlex-io Jun 22, 2021
635fd78
bump (#6676)
Jun 23, 2021
53c547a
Bump jetty-server in /frameworks/Java/jetty (#6677)
dependabot[bot] Jun 23, 2021
543ca7e
Revert to Ubuntu 20.10 (#6678)
joanhey Jun 25, 2021
ac2aa08
Update node version for nodejs (#6680)
JHyeok Jun 26, 2021
980efc7
Replaced Task.Delay by asynchronous callback (#6679)
LLT21 Jun 26, 2021
80ff402
fix: ocaml webmachine & bump to 4.12 (#6681)
rbjorklin Jun 28, 2021
94f74ee
add java isocket-nio to test,thanks (#6674)
longzl Jun 28, 2021
4ee6fb9
upgrade ntex to 0.4 (#6682)
fafhrd91 Jun 28, 2021
9ebb1b3
update magician framework (#6683)
yuyenews Jun 28, 2021
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
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:21.04
FROM ubuntu:20.10

ARG DEBIAN_FRONTEND=noninteractive

Expand Down
61 changes: 32 additions & 29 deletions frameworks/CSharp/appmpower/src/Db/PooledConnections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,67 @@ namespace appMpower.Db
{
public static class PooledConnections
{
private static int _maxLoops = 999;
private static bool _connectionsCreated = false;
private static byte _createdConnections = 0;
private static byte _maxConnections = Math.Min((byte)Environment.ProcessorCount, (byte)21);
private static ConcurrentStack<PooledConnection> _stack = new ConcurrentStack<PooledConnection>();
private static ConcurrentQueue<TaskCompletionSource<PooledConnection>> _waitingQueue = new ConcurrentQueue<TaskCompletionSource<PooledConnection>>();

public static async Task<PooledConnection> GetConnection(string connectionString)
{
int i = 0;
PooledConnection pooledConnection;
PooledConnection pooledConnection = null;

if (_createdConnections < _maxConnections)
if (_connectionsCreated)
{
if (!_stack.TryPop(out pooledConnection))
{
pooledConnection = await GetPooledConnectionAsync();
}

return pooledConnection;

}
else
{
pooledConnection = new PooledConnection();
pooledConnection.OdbcConnection = new OdbcConnection(connectionString);
_createdConnections++;

if (_createdConnections == _maxConnections) _connectionsCreated = true;

pooledConnection.Number = _createdConnections;
pooledConnection.PooledCommands = new ConcurrentDictionary<string, PooledCommand>();
//Console.WriteLine("opened connection number: " + pooledConnection.Number);

return pooledConnection;
}
else
{
while (!_stack.TryPop(out pooledConnection) && i < _maxLoops)
{
if (i < 5) await Task.Delay(1);
else if (i < 10) await Task.Delay(2);
else if (i < 25) await Task.Delay(3);
else if (i < 50) await Task.Delay(4);
else if (i < 100) await Task.Delay(5);
else if (i < 500) await Task.Delay(10);
else await Task.Delay(20);
}

i++;
//Console.WriteLine("waiting: " + i);
}
public static Task<PooledConnection> GetPooledConnectionAsync()
{
var taskCompletionSource = new TaskCompletionSource<PooledConnection>(TaskCreationOptions.RunContinuationsAsynchronously);

if (i < _maxLoops)
{
//Console.WriteLine("opened connection number: " + pooledConnection.Number);
return pooledConnection;
}
else
{
throw new Exception("No connections are available");
}
}
_waitingQueue.Enqueue(taskCompletionSource);
return taskCompletionSource.Task;
}

public static void ReleaseConnection(PooledConnection pooledConnection)
{
TaskCompletionSource<PooledConnection> taskCompletionSource;
PooledConnection stackedConnection = new PooledConnection();

stackedConnection.OdbcConnection = pooledConnection.OdbcConnection;
stackedConnection.Number = pooledConnection.Number;
stackedConnection.PooledCommands = pooledConnection.PooledCommands;

_stack.Push(stackedConnection);
if (_waitingQueue.TryDequeue(out taskCompletionSource))
{
taskCompletionSource.SetResult(stackedConnection);
}
else
{
_stack.Push(stackedConnection);
}
}
}
}
6 changes: 3 additions & 3 deletions frameworks/CSharp/appmpower/src/HttpApplication.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using appMpower.Kestrel;
using PlatformBenchmarks;

namespace appMpower
{
public class HttpApplication : IHttpApplication<IFeatureCollection>
{
private readonly static AsciiString _plainText = "Hello, World!";
public static readonly byte[] _plainText = Encoding.UTF8.GetBytes("Hello, World!");
private readonly static JsonMessageSerializer _jsonMessageSerializer = new JsonMessageSerializer();
private readonly static WorldSerializer _worldSerializer = new WorldSerializer();

Expand All @@ -34,7 +34,7 @@ public async Task ProcessRequestAsync(IFeatureCollection featureCollection)

if (pathStringLength == 10 && pathStringStart == "p")
{
PlainText.Render(httpResponse.Headers, httpResponseBody.Writer, _plainText);
await PlainText.RenderAsync(httpResponse.Headers, httpResponseBody.Writer, _plainText);
return;
}
else if (pathStringLength == 5 && pathStringStart == "j")
Expand Down
12 changes: 7 additions & 5 deletions frameworks/CSharp/appmpower/src/Kestrel/PlainText.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.IO.Pipelines;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
using PlatformBenchmarks;

namespace appMpower.Kestrel
{
Expand All @@ -13,15 +14,16 @@ public static class PlainText
private readonly static KeyValuePair<string, StringValues> _headerContentType =
new KeyValuePair<string, StringValues>("Content-Type", new StringValues("text/plain"));

public static void Render(IHeaderDictionary headerDictionary, PipeWriter pipeWriter, AsciiString utf8String)
public static async Task<FlushResult> RenderAsync(IHeaderDictionary headerDictionary, PipeWriter pipeWriter, ReadOnlyMemory<byte> utf8String)
{
headerDictionary.Add(_headerServer);
headerDictionary.Add(_headerContentType);
headerDictionary.Add(new KeyValuePair<string, StringValues>("Content-Length", utf8String.Length.ToString()));

var bufferWriter = new BufferWriter<WriterAdapter>(new WriterAdapter(pipeWriter), 208);
bufferWriter.Write(utf8String);
bufferWriter.Commit();
var result = await pipeWriter.WriteAsync(utf8String);
await pipeWriter.FlushAsync();

return result;
}
}
}
2 changes: 1 addition & 1 deletion frameworks/CSharp/beetlex/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BeetleX.FastHttpApi" Version="1.5.2.6" />
<PackageReference Include="BeetleX.FastHttpApi" Version="1.9.6" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Npgsql" Version="5.0.0-alpha1" />
<PackageReference Include="SpanJson" Version="3.0.1" />
Expand Down
17 changes: 9 additions & 8 deletions frameworks/CSharp/beetlex/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,34 @@ public class BeetleXHttpServer : IHostedService

private HttpApiServer mApiServer;

private System.Threading.Tasks.TaskCompletionSource<object> mComplete = new TaskCompletionSource<object>();

public async virtual Task StartAsync(CancellationToken cancellationToken)
{


plaintextResult = new StringBytes(_helloWorldPayload);
mApiServer = new HttpApiServer();
mApiServer.Options.Port = 8080;
mApiServer.Options.BufferPoolMaxMemory = 500;
mApiServer.Options.MaxConnections = 100000;
mApiServer.Options.Statistical = false;
mApiServer.Options.UrlIgnoreCase = false;
mApiServer.Options.LogLevel = BeetleX.EventArgs.LogType.Error;
mApiServer.Options.LogToConsole = true;
mApiServer.Options.PrivateBufferPool = true;
mApiServer.Register(typeof(Program).Assembly);
HeaderTypeFactory.SERVAR_HEADER_BYTES = Encoding.ASCII.GetBytes("Server: TFB\r\n");
mApiServer.HttpConnected += (o, e) =>
{
e.Session["DB"] = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance);
};
mApiServer.Started += (o, e) =>
{
mComplete.TrySetResult(new object());
};
mApiServer.Open();
RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Delay Us=500;Write Coalescing Buffer Threshold Bytes=1000";
//RawDb._connectionString = "Server=192.168.2.19;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
var response = await client.GetAsync("http://localhost:8080/json");
mApiServer.BaseServer.Log(LogType.Info, null, $"Get josn {response.StatusCode}");
response = await client.GetAsync("http://localhost:8080/plaintext");
mApiServer.BaseServer.Log(LogType.Info, null, $"Get plaintext {response.StatusCode}");

await mComplete.Task;
}

public virtual Task StopAsync(CancellationToken cancellationToken)
Expand Down
102 changes: 29 additions & 73 deletions frameworks/CSharp/beetlex/PlatformBenchmarks/AsciiString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,96 +8,52 @@ namespace PlatformBenchmarks
{
private readonly byte[] _data;

public byte[] Data => _data;

public int Length => _data.Length;

public AsciiString(string s)
{
_data = Encoding.ASCII.GetBytes(s);
}
public AsciiString(string s) => _data = Encoding.ASCII.GetBytes(s);

public ReadOnlySpan<byte> AsSpan()
{
return _data;
}
private AsciiString(byte[] b) => _data = b;

public static implicit operator ReadOnlySpan<byte>(AsciiString str)
{
return str._data;
}

public static implicit operator byte[](AsciiString str)
{
return str._data;
}

public static implicit operator AsciiString(string str)
{
return new AsciiString(str);
}
public int Length => _data.Length;

public override string ToString()
{
return Encoding.ASCII.GetString(_data);
}
public byte[] Data => _data;

public int CopyTo(byte[] source,int offset)
{
var len = Length;
Buffer.BlockCopy(_data, 0, source, offset, len);
return len;
}
public ReadOnlySpan<byte> AsSpan() => _data;

public static explicit operator string(AsciiString str)
{
return str.ToString();
}
public static implicit operator ReadOnlySpan<byte>(AsciiString str) => str._data;
public static implicit operator byte[](AsciiString str) => str._data;

public bool Equals(AsciiString other)
{
if (_data != other._data)
{
return SequenceEqual(_data, other._data);
}
return true;
}
public static implicit operator AsciiString(string str) => new AsciiString(str);

private bool SequenceEqual(byte[] data1, byte[] data2)
{
return new Span<byte>(data1).SequenceEqual(data2);
}
public override string ToString() => Encoding.ASCII.GetString(_data);
public static explicit operator string(AsciiString str) => str.ToString();

public static bool operator ==(AsciiString a, AsciiString b)
{
return a.Equals(b);
}
public bool Equals(AsciiString other) => ReferenceEquals(_data, other._data) || SequenceEqual(_data, other._data);
private bool SequenceEqual(byte[] data1, byte[] data2) => new Span<byte>(data1).SequenceEqual(data2);

public static bool operator !=(AsciiString a, AsciiString b)
{
return !a.Equals(b);
}
public static bool operator ==(AsciiString a, AsciiString b) => a.Equals(b);
public static bool operator !=(AsciiString a, AsciiString b) => !a.Equals(b);
public override bool Equals(object other) => (other is AsciiString) && Equals((AsciiString)other);

public override bool Equals(object other)
public static AsciiString operator +(AsciiString a, AsciiString b)
{
if (other is AsciiString)
{
return Equals((AsciiString)other);
}
return false;
var result = new byte[a.Length + b.Length];
a._data.CopyTo(result, 0);
b._data.CopyTo(result, a.Length);
return new AsciiString(result);
}

public override int GetHashCode()
{
byte[] data = _data;
int hash3 = 5381;
int hash2 = hash3;
byte[] array = data;
foreach (int b in array)
// Copied from x64 version of string.GetLegacyNonRandomizedHashCode()
// https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/String.Comparison.cs
var data = _data;
int hash1 = 5381;
int hash2 = hash1;
foreach (int b in data)
{
hash3 = (((hash3 << 5) + hash3) ^ b);
hash1 = ((hash1 << 5) + hash1) ^ b;
}
return hash3 + hash2 * 1566083941;
return hash1 + (hash2 * 1566083941);
}

}
}
Loading