Browse Source

[c#/beetlex] update BeetleX.Fasthttpapi 1.9.6, optimize platform code (#6589)

* update beetlex 1.4.3

update beetlex 1.4.3

* docker add COMPlus_ReadyToRun variable
update beetlex

* update beetlex, enabled thread queue

* beetlex framework add db and queries cases

* add db code

* change result json data

* update query url

* beetlex framework add fortunes cases

* change Content-Type

* add beetlex core cases

* fix queries cases

* update config

* change try readline

* update benchmark config

* Update README.md

* Update README.md

* change versus property

* beetlex-core update .net core to v3.0

* change beetlex-core project file

* beetlex update raw db class

* beetlex update raw db

* beetlex debug plaintext

* change debug docker file

* update beetlex to 1.4.0

* update

* beetlex update core 3.1

* [c#/beetlex] add updates cases

* [c#/beetlex] change Server: TFB, change custom connection pool, add update docker

* fix errors

* change pool init

* change connection pool maxsize

* fix fortunes errors

* clear DBRaw _connectionString value.

* [c#beetlex] change update dbconnection pool size

* [c#/beetlex] udpate spanjson to v3.0.1, Npgsql v5.0.0

* [c#/beetlex] add caching sample

* set connectionstring multiplexing

* remove connection multiplexing setting

* [c#/beetlex]change NpgsqlParameter to  NpgsqlParameter<T>

* [c#/beetlex] update dbraw

* [c#/beetlex] change connection string

* [c#/beetlex]  add fortunes cases to core-updb

* update beetlex 1.5.6

* update 5.0.0-alpha1

* update docker file

* Enabled IOQueues

* Set IOQueues debug mode

* update

* [c#/beetlex] udpate to v1.6.0.1-beta

* update pg drive

* [c#/beetlex] update to beetlex v1.6.3 and support pipelining

* set options

* [c#/beetlex] Optimized actions

* [c#/beetlex] update plaintext

* Bump ServiceStack in /frameworks/CSharp/servicestack/src/SelfHost

Bumps [ServiceStack](https://github.com/ServiceStack/ServiceStack) from 3.9.59 to 5.9.2.
- [Release notes](https://github.com/ServiceStack/ServiceStack/releases)
- [Commits](https://github.com/ServiceStack/ServiceStack/commits/v5.9.2)

Signed-off-by: dependabot[bot] <[email protected]>

* [c#/beetlex] change plaintext buffer size, optimize fortunes.

* [c#/beetlex] update v1.6.5,use System.Text.Json

* change docker files

* update beetlex 1.6.5.2

* [c#/beetlex] update v1.6.5.3-beta

* [c#/beetlex] update 1.6.5.36-beta

* update

* update json

* [c#/beetlex] update

* update beetlex 1.6.5.38 beta

* update

* add  array buffer

* [c#/beetlex] updates

* update

* update

* [c#/beetlex] update to 1.6.5.4.1

* change server tag

* Bump bottle from 0.12.13 to 0.12.19 in /frameworks/Python/bottle

Bumps [bottle](https://github.com/bottlepy/bottle) from 0.12.13 to 0.12.19.
- [Release notes](https://github.com/bottlepy/bottle/releases)
- [Changelog](https://github.com/bottlepy/bottle/blob/master/docs/changelog.rst)
- [Commits](https://github.com/bottlepy/bottle/compare/0.12.13...0.12.19)

Signed-off-by: dependabot[bot] <[email protected]>

* [c#/beetlex] remove debug docker file

* update benchmark_config

* [c#/beetlex] update fasthttpapi 1.9.6, optimize platform code

* update connectionstring

* update

* update

* update

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Henry 4 years ago
parent
commit
06aafa9eab

+ 1 - 1
frameworks/CSharp/beetlex/Benchmarks/Benchmarks.csproj

@@ -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" />

+ 9 - 8
frameworks/CSharp/beetlex/Benchmarks/Program.cs

@@ -84,33 +84,34 @@ namespace Benchmarks
 
         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)

+ 29 - 73
frameworks/CSharp/beetlex/PlatformBenchmarks/AsciiString.cs

@@ -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);
         }
+
     }
 }

+ 23 - 13
frameworks/CSharp/beetlex/PlatformBenchmarks/GMTDate.cs

@@ -1,4 +1,5 @@
-using System;
+using BeetleX.Buffers;
+using System;
 using System.Collections.Generic;
 using System.Text;
 using System.Threading;
@@ -86,19 +87,25 @@ namespace PlatformBenchmarks
 
         private void Init()
         {
-            DATE = GetData(inLine: true);
+            DATE = GetData();
             mUpdateTime = new Timer(delegate
             {
-                DATE = GetData(inLine: true);
+                DATE = GetData();
             }, null, 1000, 1000);
         }
 
-        private ArraySegment<byte> GetData(bool inLine = false)
+        private ArraySegment<byte> GetData()
         {
-            return GetData(DateTime.Now, inLine);
+            return GetData(DateTime.Now);
         }
 
-        private ArraySegment<byte> GetData(DateTime date, bool inLine = false)
+        public void Write(PipeStream stream)
+        {
+            var data = DATE;
+            stream.Write(data.Array, 0, data.Count);
+        }
+
+        private ArraySegment<byte> GetData(DateTime date)
         {
             date = date.ToUniversalTime();
             int offset13 = 0;
@@ -172,13 +179,16 @@ namespace PlatformBenchmarks
             offset13++;
             buffer[offset13] = sub8[2];
             offset13++;
-            if (inLine)
-            {
-                buffer[offset13] = _r;
-                offset13++;
-                buffer[offset13] = _n;
-                offset13++;
-            }
+
+            buffer[offset13] = _r;
+            offset13++;
+            buffer[offset13] = _n;
+            offset13++;
+            buffer[offset13] = _r;
+            offset13++;
+            buffer[offset13] = _n;
+            offset13++;
+
             return new ArraySegment<byte>(GTM_BUFFER, 0, offset13);
         }
     }

+ 6 - 0
frameworks/CSharp/beetlex/PlatformBenchmarks/Caching.cs → frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.Caching.cs

@@ -10,6 +10,8 @@ namespace PlatformBenchmarks
 {
     public partial class HttpHandler
     {
+       
+
         public async Task caching(string queryString, PipeStream stream, HttpToken token, ISession session)
         {
             int count = 1;
@@ -31,6 +33,10 @@ namespace PlatformBenchmarks
             try
             {
                 var data = await token.Db.LoadCachedQueries(count);
+                stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
+                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                GMTDate.Default.Write(stream);
+                token.ContentPostion = stream.CacheLength;
                 await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream);
             }
             catch (Exception e_)

+ 37 - 63
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.cs

@@ -11,11 +11,11 @@ namespace PlatformBenchmarks
 {
     public partial class HttpHandler : ServerHandlerBase
     {
-        private static AsciiString _line = new AsciiString("\r\n");
+        private static readonly AsciiString _line = new AsciiString("\r\n");
 
-        private static AsciiString _2line = new AsciiString("\r\n\r\n");
+        private static readonly AsciiString _2line = new AsciiString("\r\n\r\n");
 
-        private static AsciiString _httpsuccess = new AsciiString("HTTP/1.1 200 OK\r\n");
+        private static readonly AsciiString _httpsuccess = new AsciiString("HTTP/1.1 200 OK\r\n");
 
         private static readonly AsciiString _headerServer = "Server: B\r\n";
 
@@ -29,12 +29,6 @@ namespace PlatformBenchmarks
 
         private static readonly AsciiString _headerContentTypeJson = "Content-Type: application/json\r\n";
 
-        private static readonly AsciiString _textResultHeader = _httpsuccess + _headerServer.ToString() + _headerContentTypeText.ToString();
-
-        private static readonly AsciiString _jsonResultHeader = _httpsuccess + _headerServer.ToString() + _headerContentTypeJson.ToString();
-
-        private static readonly AsciiString _htmlResultHeader = _httpsuccess + _headerServer.ToString() + _headerContentTypeHtml.ToString();
-
         private static readonly AsciiString _path_Json = "/json";
 
         private static readonly AsciiString _path_Db = "/db";
@@ -51,9 +45,41 @@ namespace PlatformBenchmarks
 
         private static readonly AsciiString _cached_worlds = "/cached-worlds";
 
+        private readonly static uint _jsonPayloadSize = (uint)System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(new JsonMessage { message = "Hello, World!" }, SerializerOptions).Length;
+
+
+
+        private readonly static AsciiString _jsonPreamble =
+            _httpsuccess
+            + _headerContentTypeJson
+            + _headerServer
+            + _headerContentLength + _jsonPayloadSize.ToString() + _line;
+
+        private readonly static AsciiString _plaintextPreamble =
+              _httpsuccess
+              + _headerContentTypeText
+              + _headerServer
+              + _headerContentLength + _result_plaintext.Length.ToString() + _line;
+
+
+        private readonly static AsciiString _jsonResultPreamble =
+        _httpsuccess
+        + _headerContentTypeJson
+        + _headerServer
+       + _headerContentLength;
+
+        private readonly static AsciiString _HtmlResultPreamble =
+      _httpsuccess
+      + _headerContentTypeHtml
+      + _headerServer
+     + _headerContentLength;
+
+
+
+
         private static byte _Space = 32;
 
-        public const int _LengthSize = 6;
+        public const int _LengthSize = 8;
 
         private static byte _question = 63;
 
@@ -64,13 +90,7 @@ namespace PlatformBenchmarks
 
         private BeetleX.Dispatchs.DispatchCenter<HttpToken> RequestDispatchs;
 
-        public Task Default(PipeStream stream, HttpToken token, ISession session)
-        {
-            stream.Write("<b> beetlex server</b><hr/>");
-            stream.Write("path not found!");
-            OnCompleted(stream, session, token);
-            return Task.CompletedTask;
-        }
+
 
         public override void Connected(IServer server, ConnectedEventArgs e)
         {
@@ -235,7 +255,6 @@ namespace PlatformBenchmarks
 
         public virtual async Task OnStartRequest(RequestData data, ISession session, HttpToken token, PipeStream stream)
         {
-            OnWriteHeader(stream, token, data.Action);
             ActionType type = data.Action;
             if (type == ActionType.Plaintext)
             {
@@ -272,51 +291,6 @@ namespace PlatformBenchmarks
 
         }
 
-        private void OnWriteHeader(PipeStream stream, HttpToken token, ActionType type)
-        {
-            switch (type)
-            {
-                case ActionType.Caching:
-                case ActionType.Json:
-                case ActionType.Queries:
-                case ActionType.Db:
-                case ActionType.Updates:
-                    stream.Write(_jsonResultHeader.Data, 0, _jsonResultHeader.Length);
-                    break;
-                case ActionType.Plaintext:
-                    stream.Write(_textResultHeader.Data, 0, _textResultHeader.Length);
-                    break;
-                default:
-                    stream.Write(_htmlResultHeader.Data, 0, _htmlResultHeader.Length);
-                    break;
-            }
-
-            ArraySegment<byte> date = GMTDate.Default.DATE;
-            stream.Write(date.Array, date.Offset, date.Count);
-            OnWriteContentLength(stream, token);
-        }
-
-        private void OnWriteContentLength(PipeStream stream, HttpToken token)
-        {
-            var action = token.CurrentRequest.Action;
-            if (action == ActionType.Json)
-            {
-                stream.Write(_jsonPreamble.Data, 0, _jsonPreamble.Length);
-                stream.Write(_2line, 0, 4);
-            }
-            else if (action == ActionType.Plaintext)
-            {
-                stream.Write(_plaintextPreamble.Data, 0, _plaintextPreamble.Length);
-                stream.Write(_2line, 0, 4);
-            }
-            else
-            {
-                stream.Write(_headerContentLength.Data, 0, _headerContentLength.Length);
-                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
-                stream.Write(_2line, 0, 4);
-                token.ContentPostion = stream.CacheLength;
-            }
-        }
 
         private void OnCompleted(PipeStream stream, ISession session, HttpToken token)
         {

+ 5 - 1
frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs → frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.db.cs

@@ -11,12 +11,16 @@ namespace PlatformBenchmarks
     public partial class HttpHandler
     {
 
+
         public async ValueTask db(PipeStream stream, HttpToken token, ISession session)
         {
             try
             {
                 var data = await token.Db.LoadSingleQueryRow();
-
+                stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
+                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                GMTDate.Default.Write(stream);
+                token.ContentPostion = stream.CacheLength;
                 System.Text.Json.JsonSerializer.Serialize<World>(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
             }
             catch (Exception e_)

+ 30 - 0
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.default.cs

@@ -0,0 +1,30 @@
+using BeetleX;
+using BeetleX.Buffers;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PlatformBenchmarks
+{
+    public partial class HttpHandler
+    {
+        private readonly static AsciiString _defaultPreamble =
+               _httpsuccess.ToString()
+               + _headerContentTypeJson.ToString()
+               + _headerServer.ToString();
+
+        public Task Default(PipeStream stream, HttpToken token, ISession session)
+        {
+            stream.Write(_defaultPreamble.Data, 0, _defaultPreamble.Length);
+            token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+            GMTDate.Default.Write(stream);
+            token.ContentPostion = stream.CacheLength;
+            stream.Write("<b> beetlex server</b><hr/>");
+            stream.Write("path not found!");
+            OnCompleted(stream, session, token);
+            return Task.CompletedTask;
+        }
+    }
+}

+ 5 - 3
frameworks/CSharp/beetlex/PlatformBenchmarks/fortunes.cs → frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.fortunes.cs

@@ -19,9 +19,6 @@ namespace PlatformBenchmarks
         private readonly static AsciiString _fortunesRowEnd = "</td></tr>";
         private readonly static AsciiString _fortunesTableEnd = "</table></body></html>";
 
-        [ThreadStatic]
-        private static char[] mHtmlEncodeBuffer;
-
         protected HtmlEncoder HtmlEncoder { get; } = CreateHtmlEncoder();
 
         private static HtmlEncoder CreateHtmlEncoder()
@@ -38,6 +35,11 @@ namespace PlatformBenchmarks
 
                 var data = await token.Db.LoadFortunesRows();
 
+                stream.Write(_HtmlResultPreamble.Data, 0, _HtmlResultPreamble.Length);
+                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                GMTDate.Default.Write(stream);
+                token.ContentPostion = stream.CacheLength;
+
                 var html = token.GetHtmlBufferWriter();
                 html.Reset();
                 html.Write(_fortunesTableStart.Data, 0, _fortunesTableStart.Length);

+ 4 - 5
frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs → frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.json.cs

@@ -11,10 +11,7 @@ namespace PlatformBenchmarks
 {
     public partial class HttpHandler
     {
-        private readonly static uint _jsonPayloadSize = (uint)System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(new JsonMessage { message = "Hello, World!" }, SerializerOptions).Length;
-
-        private readonly static AsciiString _jsonPreamble =
-            _headerContentLength + _jsonPayloadSize.ToString();
+        
 
         private static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions();
 
@@ -32,7 +29,9 @@ namespace PlatformBenchmarks
 
         public ValueTask Json(PipeStream stream, HttpToken token, ISession session)
         {
-            System.Text.Json.JsonSerializer.Serialize<JsonMessage>(GetUtf8JsonWriter(stream, token), new JsonMessage { message = "Hello, World!" }, SerializerOptions);   
+            stream.Write(_jsonPreamble.Data, 0, _jsonPreamble.Length);
+            GMTDate.Default.Write(stream);
+            System.Text.Json.JsonSerializer.Serialize<JsonMessage>(GetUtf8JsonWriter(stream, token), new JsonMessage { message = "Hello, World!" }, SerializerOptions);
             OnCompleted(stream, session, token);
             return ValueTask.CompletedTask;
         }

+ 3 - 3
frameworks/CSharp/beetlex/PlatformBenchmarks/plaintext.cs → frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.plaintext.cs

@@ -9,12 +9,12 @@ namespace PlatformBenchmarks
 {
     public partial class HttpHandler
     {
-        private readonly static AsciiString _plaintextPreamble =
-
-           _headerContentLength + _result_plaintext.Length.ToString();
+      
 
         public ValueTask Plaintext(PipeStream stream, HttpToken token, ISession session)
         {
+            stream.Write(_plaintextPreamble.Data, 0, _plaintextPreamble.Length);
+            GMTDate.Default.Write(stream);
             stream.Write(_result_plaintext.Data, 0, _result_plaintext.Length);
             OnCompleted(stream, session, token);
             return ValueTask.CompletedTask;

+ 4 - 0
frameworks/CSharp/beetlex/PlatformBenchmarks/queries.cs → frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.queries.cs

@@ -31,6 +31,10 @@ namespace PlatformBenchmarks
             try
             {
                 var data = await token.Db.LoadMultipleQueriesRows(count);
+                stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
+                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                GMTDate.Default.Write(stream);
+                token.ContentPostion = stream.CacheLength;
                 System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
             }
             catch (Exception e_)

+ 5 - 0
frameworks/CSharp/beetlex/PlatformBenchmarks/updates.cs → frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.updates.cs

@@ -31,6 +31,11 @@ namespace PlatformBenchmarks
             try
             {
                 var data = await token.Db.LoadMultipleUpdatesRows(count);
+
+                stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
+                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                GMTDate.Default.Write(stream);
+                token.ContentPostion = stream.CacheLength;
                 System.Text.Json.JsonSerializer.Serialize<World[]>(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
             }
             catch (Exception e_)

+ 1 - 1
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpServer.cs

@@ -21,7 +21,7 @@ namespace PlatformBenchmarks
             serverOptions.DefaultListen.Port = 8080;
             serverOptions.Statistical = false;
             serverOptions.BufferPoolMaxMemory = 1000;
-            serverOptions.BufferPoolSize = 1024 * 16;
+            serverOptions.BufferPoolSize = 1024 * 24;
             ApiServer = SocketFactory.CreateTcpServer<HttpHandler>(serverOptions);
             ApiServer.Open();
             if (!Program.UpDB)

+ 3 - 1
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs

@@ -41,10 +41,12 @@ namespace PlatformBenchmarks
         public byte[] GetLengthBuffer(string length)
         {
             Encoding.ASCII.GetBytes(length, 0, length.Length, mLengthBuffer, 0);
-            for (int i = length.Length; i < HttpHandler._LengthSize; i++)
+            for (int i = length.Length; i < mLengthBuffer.Length; i++)
             {
                 mLengthBuffer[i] = 32;
             }
+            mLengthBuffer[6] = (byte)'\r';
+            mLengthBuffer[7] = (byte)'\n';
             return mLengthBuffer;
         }