Browse Source

Merge branch 'master' of https://github.com/TechEmpower/FrameworkBenchmarks

jaguililla 1 year ago
parent
commit
30be80547f
100 changed files with 2141 additions and 1362 deletions
  1. 15 14
      Dockerfile
  2. 7 7
      frameworks/C++/drogon/drogon-core.dockerfile
  3. 7 7
      frameworks/C++/drogon/drogon.dockerfile
  4. 2 2
      frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrlRaw.cc
  5. 4 3
      frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrlRaw.h
  6. 1 1
      frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrlRaw.cc
  7. 40 0
      frameworks/C++/paozhu/README.md
  8. 31 0
      frameworks/C++/paozhu/benchmark_config.json
  9. 8 5
      frameworks/C++/paozhu/config.toml
  10. 54 0
      frameworks/C++/paozhu/paozhu.dockerfile
  11. 508 0
      frameworks/C++/paozhu/paozhu_benchmark/CMakeLists.txt
  12. 51 0
      frameworks/C++/paozhu/paozhu_benchmark/common/autocontrolmethod.hpp
  13. 32 0
      frameworks/C++/paozhu/paozhu_benchmark/common/json_reflect_headers.h
  14. 16 0
      frameworks/C++/paozhu/paozhu_benchmark/common/reghttpmethod.hpp
  15. 20 0
      frameworks/C++/paozhu/paozhu_benchmark/common/reghttpmethod_pre.hpp
  16. 20 0
      frameworks/C++/paozhu/paozhu_benchmark/conf/orm.conf
  17. 42 0
      frameworks/C++/paozhu/paozhu_benchmark/conf/server.conf
  18. 19 0
      frameworks/C++/paozhu/paozhu_benchmark/controller/include/techempower.h
  19. 241 0
      frameworks/C++/paozhu/paozhu_benchmark/controller/src/techempower.cpp
  20. 15 0
      frameworks/C++/paozhu/paozhu_benchmark/libs/types/techempower_json.h
  21. 291 0
      frameworks/C++/paozhu/paozhu_benchmark/libs/types/techempower_json_jsonreflect.cpp
  22. 0 19
      frameworks/C++/silicon/CMakeLists.txt
  23. 0 8
      frameworks/C++/silicon/README.md
  24. 0 28
      frameworks/C++/silicon/benchmark_config.json
  25. 0 47
      frameworks/C++/silicon/build/symbols.hh
  26. 0 102
      frameworks/C++/silicon/build/techempower.hh
  27. 0 41
      frameworks/C++/silicon/build/techempower_lwan.cc
  28. 0 48
      frameworks/C++/silicon/build/techempower_microhttpd.cc
  29. 0 19
      frameworks/C++/silicon/config.toml
  30. 0 39
      frameworks/C++/silicon/silicon.dockerfile
  31. 2 2
      frameworks/C++/userver/userver-bare.dockerfile
  32. 2 2
      frameworks/C++/userver/userver.dockerfile
  33. 2 2
      frameworks/C++/userver/userver_configs/static_config.yaml
  34. 0 29
      frameworks/C/duda/README.md
  35. 0 24
      frameworks/C/duda/benchmark_config.json
  36. 0 13
      frameworks/C/duda/duda.dockerfile
  37. 0 7
      frameworks/C/duda/webservice/Makefile.in
  38. 0 81
      frameworks/C/duda/webservice/main.c
  39. 1 0
      frameworks/C/h2o/benchmark_config.json
  40. 3 3
      frameworks/C/h2o/h2o.dockerfile
  41. 120 79
      frameworks/C/h2o/src/database.c
  42. 1 1
      frameworks/C/h2o/src/database.h
  43. 4 3
      frameworks/C/h2o/src/handlers/world.c
  44. 1 4
      frameworks/CSharp/appmpower/src/Data/DbConnection.cs
  45. 1 1
      frameworks/CSharp/appmpower/src/Data/DbConnections.cs
  46. 2 1
      frameworks/CSharp/appmpower/src/HttpApplication.cs
  47. 11 0
      frameworks/CSharp/appmpower/src/Kestrel/PlainText.cs
  48. 1 0
      frameworks/CSharp/appmpower/src/Program.cs
  49. 1 1
      frameworks/CSharp/appmpower/src/appMpower.csproj
  50. 1 0
      frameworks/CSharp/aspnetcore-mono/Benchmarks/Benchmarks.csproj
  51. 1 1
      frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/PlatformBenchmarks.csproj
  52. 1 1
      frameworks/CSharp/aspnetcore/src/Minimal/Minimal.csproj
  53. 1 1
      frameworks/CSharp/aspnetcore/src/Mvc/Mvc.csproj
  54. 1 1
      frameworks/CSharp/aspnetcore/src/Platform/Platform.csproj
  55. 3 3
      frameworks/CSharp/beetlex/Benchmarks.sln
  56. 2 3
      frameworks/CSharp/beetlex/Benchmarks/Benchmarks.csproj
  57. 5 4
      frameworks/CSharp/beetlex/Benchmarks/Program.cs
  58. 2 3
      frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs
  59. 3 2
      frameworks/CSharp/beetlex/PlatformBenchmarks/GMTDate.cs
  60. 30 11
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.Caching.cs
  61. 201 151
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.cs
  62. 23 11
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.db.cs
  63. 14 10
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.default.cs
  64. 27 58
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.fortunes.cs
  65. 14 20
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.json.cs
  66. 3 5
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.plaintext.cs
  67. 32 13
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.queries.cs
  68. 14 11
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.updates.cs
  69. 23 17
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpServer.cs
  70. 57 57
      frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs
  71. 19 0
      frameworks/CSharp/beetlex/PlatformBenchmarks/NetApplication.cs
  72. 6 6
      frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj
  73. 6 0
      frameworks/CSharp/beetlex/PlatformBenchmarks/Program.cs
  74. 3 14
      frameworks/CSharp/beetlex/PlatformBenchmarks/RequestData.cs
  75. 0 12
      frameworks/CSharp/beetlex/beetlex-core-updb.dockerfile
  76. 2 2
      frameworks/CSharp/beetlex/beetlex-core.dockerfile
  77. 2 2
      frameworks/CSharp/beetlex/beetlex.dockerfile
  78. 0 19
      frameworks/CSharp/beetlex/benchmark_config.json
  79. 0 12
      frameworks/CSharp/beetlex/config.toml
  80. 6 6
      frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj
  81. 1 1
      frameworks/CSharp/sisk/sisk/sisk.csproj
  82. 1 1
      frameworks/Crystal/crystal/crystal-radix.dockerfile
  83. 1 1
      frameworks/Crystal/crystal/crystal.dockerfile
  84. 1 1
      frameworks/Crystal/crystal/shard.yml
  85. 1 1
      frameworks/Crystal/grip/grip.cr
  86. 1 1
      frameworks/Crystal/grip/grip.dockerfile
  87. 2 2
      frameworks/Crystal/grip/shard.yml
  88. 0 7
      frameworks/Crystal/h2o.cr/README.md
  89. 0 26
      frameworks/Crystal/h2o.cr/benchmark_config.json
  90. 0 15
      frameworks/Crystal/h2o.cr/config.toml
  91. 0 24
      frameworks/Crystal/h2o.cr/h2o.cr.dockerfile
  92. 0 114
      frameworks/Crystal/h2o.cr/h2o_evloop_hello.cr
  93. 0 7
      frameworks/Crystal/h2o.cr/run.sh
  94. 0 15
      frameworks/Crystal/h2o.cr/shard.yml
  95. 1 1
      frameworks/Crystal/kemal/kemal-concurrent-queries.dockerfile
  96. 1 1
      frameworks/Crystal/kemal/kemal.dockerfile
  97. 21 21
      frameworks/Crystal/kemal/shard.lock
  98. 3 3
      frameworks/Crystal/kemal/shard.yml
  99. 1 1
      frameworks/Crystal/lucky/lucky.dockerfile
  100. 28 20
      frameworks/Crystal/lucky/shard.lock

+ 15 - 14
Dockerfile

@@ -1,4 +1,4 @@
-FROM ubuntu:22.04
+FROM ubuntu:24.04
 
 ARG DEBIAN_FRONTEND=noninteractive
 # WARNING: DON'T PUT A SPACE AFTER ANY BACKSLASH OR APT WILL BREAK
@@ -18,24 +18,25 @@ RUN apt-get -yqq update && \
       libpq-dev \
       pkg-config \
       python3 \
+      python3-colorama \
       python3-dev \
+      python3-dnspython \
+      python3-packaging \
       python3-pip \
+      python3-psutil \
+      python3-psycopg2 \
+      python3-requests \
       siege \
-      software-properties-common
-
-RUN pip3 install \
-      colorama==0.3.1 \
-      docker==4.0.2 \
-      mysqlclient \
-      psutil \
-      psycopg2-binary \
-      pymongo==3.13.0 \
-      # urllib3 incompatibility:
-      # https://github.com/docker/docker-py/issues/3113#issuecomment-1525500104
-      requests==2.28.1
+      software-properties-common && \
+    # Ubuntu's equivalent packages are too old and/or broken.
+    pip3 install \
+      --break-system-packages \
+      docker==7.0.0 \
+      mysqlclient==2.2.4 \
+      pymongo==4.7.2
 
 # Collect resource usage statistics
-ARG DOOL_VERSION=v1.2.0
+ARG DOOL_VERSION=v1.3.1
 
 WORKDIR /tmp
 RUN curl -LSs "https://github.com/scottchiefbaker/dool/archive/${DOOL_VERSION}.tar.gz" | \

+ 7 - 7
frameworks/C++/drogon/drogon-core.dockerfile

@@ -1,4 +1,4 @@
-FROM ubuntu:20.04
+FROM ubuntu:22.04
 
 COPY ./ ./
 
@@ -11,7 +11,7 @@ RUN  apt-get update -yqq && \
      zlib1g-dev && \
      add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
 	 apt-get update -yqq && \
-	 apt-get install -yqq gcc-10 g++-10
+	 apt-get install -yqq gcc g++
 
 RUN locale-gen en_US.UTF-8
 
@@ -19,10 +19,10 @@ ENV LANG en_US.UTF-8
 ENV LANGUAGE en_US:en
 ENV LC_ALL en_US.UTF-8
 
-ENV CC=gcc-10
-ENV CXX=g++-10
-ENV AR=gcc-ar-10
-ENV RANLIB=gcc-ranlib-10
+ENV CC=gcc
+ENV CXX=g++
+ENV AR=gcc-ar
+ENV RANLIB=gcc-ranlib
 
 ENV IROOT=/install
 ENV DROGON_ROOT=$IROOT/drogon
@@ -41,7 +41,7 @@ RUN git clone https://github.com/an-tao/drogon
 
 WORKDIR $DROGON_ROOT
 
-RUN git checkout ebf87d69d7bb45dfa478ba364ef9374d9be25092
+RUN git checkout 96919df488e0ebaa0ed304bbd76bba33508df3cc 
 RUN git submodule update --init
 RUN mkdir build
 

+ 7 - 7
frameworks/C++/drogon/drogon.dockerfile

@@ -1,4 +1,4 @@
-FROM ubuntu:20.04
+FROM ubuntu:22.04
 
 COPY ./ ./
 
@@ -11,7 +11,7 @@ RUN  apt-get update -yqq && \
      zlib1g-dev && \
      add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
 	 apt-get update -yqq && \
-	 apt-get install -yqq gcc-10 g++-10
+	 apt-get install -yqq gcc g++
 
 RUN locale-gen en_US.UTF-8
 
@@ -19,10 +19,10 @@ ENV LANG en_US.UTF-8
 ENV LANGUAGE en_US:en
 ENV LC_ALL en_US.UTF-8
 
-ENV CC=gcc-10
-ENV CXX=g++-10
-ENV AR=gcc-ar-10
-ENV RANLIB=gcc-ranlib-10
+ENV CC=gcc
+ENV CXX=g++
+ENV AR=gcc-ar
+ENV RANLIB=gcc-ranlib
 
 ENV IROOT=/install
 ENV DROGON_ROOT=$IROOT/drogon
@@ -41,7 +41,7 @@ RUN git clone https://github.com/an-tao/drogon
 
 WORKDIR $DROGON_ROOT
 
-RUN git checkout ebf87d69d7bb45dfa478ba364ef9374d9be25092
+RUN git checkout 96919df488e0ebaa0ed304bbd76bba33508df3cc 
 RUN git submodule update --init
 RUN mkdir build
 

+ 2 - 2
frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrlRaw.cc

@@ -22,8 +22,8 @@ void FortuneCtrlRaw::asyncHandleHttpRequest(
         rows.reserve(r.size() + 1);
         for (auto const &row : r)
         {
-            rows.emplace_back(row[0ul].as<string_view>(),   // id
-                              row[1ul].as<string_view>());  // message
+            rows.emplace_back(row[0ul].as<std::string_view>(),   // id
+                              row[1ul].as<std::string_view>());  // message
         }
         rows.emplace_back("0", "Additional fortune added at request time.");
         std::sort(rows.begin(),

+ 4 - 3
frameworks/C++/drogon/drogon_benchmark/controllers/FortuneCtrlRaw.h

@@ -1,17 +1,18 @@
 #pragma once
 #include <drogon/HttpSimpleController.h>
 #include <drogon/IOThreadStorage.h>
+#include <string_view>
 
 using namespace drogon;
 struct Fortune
 {
-    Fortune(string_view &&id, string_view &&message)
+    Fortune(std::string_view &&id, std::string_view &&message)
         : id_(std::move(id)), message_(std::move(message))
     {
     }
     Fortune() = default;
-    string_view id_;
-    string_view message_;
+    std::string_view id_;
+    std::string_view message_;
 };
 class FortuneCtrlRaw : public drogon::HttpSimpleController<FortuneCtrlRaw>
 {

+ 1 - 1
frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrlRaw.cc

@@ -43,7 +43,7 @@ void UpdatesCtrlRaw::update(
     const DbClientPtr &client)
 {
     auto const &sql = getSQL(results->size());
-    auto sqlBinder = *client << string_view(sql.data(), sql.length());
+    auto sqlBinder = *client << std::string_view(sql.data(), sql.length());
     Json::Value json;
     json.resize(0);
     for (auto const &w : *results)

+ 40 - 0
frameworks/C++/paozhu/README.md

@@ -0,0 +1,40 @@
+# paozhu Benchmarking Test
+
+This is the [Paozhu](https://github.com/hggq/paozhu) 
+
+This Benchmarking Test code from https://github.com/hggq/paozhu/releases/tag/v1.5.8
+
+### Test Type Implementation Source Code
+
+* [Benchmark code](controller/src/techempower.cpp)
+* [ORM config](conf/orm.conf) 
+* [Server config](conf/server.conf) 
+
+## Test URLs
+### JSON
+
+http://localhost:8888/json
+
+### PLAINTEXT
+
+http://localhost:8888/plaintext
+
+
+### Single Database Query
+
+http://localhost:8888/db
+
+### Fortune
+
+http://localhost:8888/fortunes
+
+### Multiple Database Queries
+
+http://localhost:8888/queries?queries=10
+
+### Database Updates
+
+http://localhost:8888/updates?queries=10
+
+### Cache
+http://localhost:8888/cached-queries?count=20

+ 31 - 0
frameworks/C++/paozhu/benchmark_config.json

@@ -0,0 +1,31 @@
+{
+  "framework": "paozhu",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "db_url": "/db",
+        "fortune_url": "/fortunes",
+        "query_url": "/queries?queries=",
+        "update_url": "/updates?queries=",
+        "cached_query_url": "/cached-queries?count=",
+        "port": 8888,
+        "approach": "Realistic",
+        "classification": "Fullstack",
+        "database": "MySQL",
+        "framework": "paozhu",
+        "language": "C++",
+        "flavor": "None",
+        "orm": "Micro",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "paozhu",
+        "notes": "",
+        "versus": "None"
+      }
+    }
+  ]
+}

+ 8 - 5
frameworks/Scala/fintrospect/config.toml → frameworks/C++/paozhu/config.toml

@@ -1,5 +1,7 @@
 [framework]
-name = "fintrospect"
+name = "paozhu"
+authors = ["Huang ziquan <[email protected]>"]
+github = "https://github.com/hggq/paozhu"
 
 [main]
 urls.plaintext = "/plaintext"
@@ -8,12 +10,13 @@ urls.db = "/db"
 urls.query = "/queries?queries="
 urls.update = "/updates?queries="
 urls.fortune = "/fortunes"
+urls.cached_query = "/cached-queries?count="
 approach = "Realistic"
-classification = "Micro"
+classification = "Fullstack"
 database = "MySQL"
 database_os = "Linux"
 os = "Linux"
-orm = "Raw"
-platform = "Netty"
+orm = "Micro"
+platform = "None"
 webserver = "None"
-versus = "finagle"
+versus = "None"

+ 54 - 0
frameworks/C++/paozhu/paozhu.dockerfile

@@ -0,0 +1,54 @@
+FROM ubuntu:22.04
+RUN apt-get update -yqq && apt-get install -yqq apt-utils software-properties-common wget unzip cmake git
+RUN apt-get install -yqq gcc g++ openssl libssl-dev zlib1g-dev build-essential locales
+
+RUN apt-get -y install brotli libbrotli-dev 
+RUN apt-get -y install libreadline-dev 
+RUN apt-get -y install mysql-client
+RUN apt-get -y install libmysqlclient-dev
+
+RUN locale-gen en_US.UTF-8
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+ENV LC_ALL en_US.UTF-8
+
+COPY ./ ./
+WORKDIR /
+
+# RUN wget https://github.com/hggq/paozhu/releases/download/v1.5.8/benchmark.zip
+RUN git clone https://github.com/hggq/paozhu
+# RUN unzip benchmark.zip
+RUN rm -Rf ./paozhu/controller
+RUN rm -Rf ./paozhu/libs
+RUN mkdir ./paozhu/libs
+RUN mkdir ./paozhu/libs/types
+
+RUN mkdir ./paozhu/controller
+RUN mkdir ./paozhu/controller/include
+RUN mkdir ./paozhu/controller/src
+
+COPY ./paozhu_benchmark/controller/include/techempower.h ./paozhu/controller/include/
+COPY ./paozhu_benchmark/controller/src/techempower.cpp ./paozhu/controller/src/
+
+COPY ./paozhu_benchmark/libs/types/techempower_json.h ./paozhu/libs/types/
+COPY ./paozhu_benchmark/libs/types/techempower_json_jsonreflect.cpp ./paozhu/libs/types/
+
+COPY ./paozhu_benchmark/common/autocontrolmethod.hpp ./paozhu/common/
+COPY ./paozhu_benchmark/common/reghttpmethod_pre.hpp ./paozhu/common/
+COPY ./paozhu_benchmark/common/reghttpmethod.hpp ./paozhu/common/
+COPY ./paozhu_benchmark/common/json_reflect_headers.h ./paozhu/common/
+
+COPY ./paozhu_benchmark/conf/server.conf ./paozhu/conf/server.conf
+COPY ./paozhu_benchmark/conf/orm.conf ./paozhu/conf/orm.conf
+COPY ./paozhu_benchmark/CMakeLists.txt ./paozhu/CMakeLists.txt
+
+WORKDIR /paozhu
+RUN unzip asio.zip
+
+RUN cmake . -B build -DCMAKE_BUILD_TYPE=Release 
+RUN cmake --build build
+
+
+EXPOSE 8888
+
+CMD ./bin/paozhu 

+ 508 - 0
frameworks/C++/paozhu/paozhu_benchmark/CMakeLists.txt

@@ -0,0 +1,508 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 3.20)
+
+cmake_policy(SET CMP0048 NEW)
+
+set(ENABLE_VCPKG OFF CACHE BOOL "choose ON to enable")
+set(ENABLE_BOOST OFF CACHE BOOL "choose ON to enable")
+set(ENABLE_GD OFF CACHE BOOL "choose ON to enable")
+set(ENABLE_WIN_VCPKG OFF CACHE BOOL "choose ON to enable")
+
+if (ENABLE_GD STREQUAL "ON")
+    list(FIND VCPKG_MANIFEST_FEATURES "gd" index)
+    if (index EQUAL -1)
+        message(STATUS "Auto append features: gd")
+        list(APPEND VCPKG_MANIFEST_FEATURES "gd")
+    endif ()
+endif ()
+
+if (ENABLE_BOOST STREQUAL "ON")
+    list(FIND VCPKG_MANIFEST_FEATURES "boost" index)
+    if (index EQUAL -1)
+        message(STATUS "Auto append features: boost")
+        list(APPEND VCPKG_MANIFEST_FEATURES "boost")
+    endif ()
+endif ()
+
+PROJECT(Paozhu_web_framework)
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+set(mode "CMAKE_BUILD_TYPE")
+
+set(BOOST_OPEN "  ")
+set(GD_OPEN " ")
+
+if(ENABLE_BOOST STREQUAL "ON")
+  message("ENABLE_BOOST")
+  set(BOOST_OPEN " -DENABLE_BOOST ")
+endif()
+
+if(ENABLE_GD STREQUAL "ON")
+    message("ENABLE_GD")
+    set(GD_OPEN " -DENABLE_GD ")
+endif()
+
+set(sys_so_path "/usr/lib64")
+
+if (IS_DIRECTORY "/usr/lib/x86_64-linux-gnu")
+  set(sys_so_path "/usr/lib/x86_64-linux-gnu")
+endif()
+
+if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0601")
+endif()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /EHsc")
+endif ()
+
+if(${mode} AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
+
+    if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DASIO_STANDALONE -DDEBUG ${BOOST_OPEN} ${GD_OPEN}")
+        if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address")
+        elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pthread -g")
+        endif ()
+    else()
+        set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pthread -g -fsanitize=address -DASIO_STANDALONE -DDEBUG ${BOOST_OPEN} ${GD_OPEN} -I/usr/local/include -I/usr/local/mysql/include   -I/usr/include -I/usr/include/mysql " )
+    endif ()
+    message("Debug mode:${CMAKE_CXX_FLAGS_DEBUG}")
+
+elseif(${mode} AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
+
+    if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DASIO_STANDALONE ${BOOST_OPEN} ${GD_OPEN} -O3")
+        if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pthread")
+        endif ()
+    else ()
+        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wextra -O3")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread  -DASIO_STANDALONE ${BOOST_OPEN} ${GD_OPEN}  -I/usr/local/include -I/usr/local/mysql/include -I/usr/include -I/usr/include/mysql  " )
+        file(MAKE_DIRECTORY /usr/local/etc/paozhu)
+        file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/conf/ DESTINATION /usr/local/etc/paozhu/)
+    endif ()
+    message("Release mode:${CMAKE_CXX_FLAGS_RELEASE}")
+
+else()
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra")
+    message("Debug mode:${CMAKE_CXX_FLAGS_DEBUG}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pthread  -g -fsanitize=address  -DASIO_STANDALONE -DDEBUG ${BOOST_OPEN} ${GD_OPEN} -I/usr/local/include -I/usr/local/mysql/include   -I/usr/include  -I/usr/include/mysql  " )
+
+    if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
+    endif ()
+endif()
+
+
+
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/temp)
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/log)
+set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
+set(USE_STANDALONE_ASIO ON)
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
+message(STATUS "SOURCE dir ${CMAKE_CURRENT_SOURCE_DIR}")
+
+
+set(CMAKE_BUILD_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build)
+set(CMAKE_CACHEFILE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
+set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/controller)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpcli)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/viewsrc/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/websockets/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_empty)
+  file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_empty)
+endif ()
+#EXECUTE_PROCESS(COMMAND rm ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_empty)
+set(PAOZHU_PRE paozhu_pre)
+add_executable(${PAOZHU_PRE} ${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpcli/autopickmethod.cpp ${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpserver/src/md5.cpp)
+add_executable(paozhu_empty ${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpcli/autoemptymethod.cpp)
+
+
+
+file(GLOB_RECURSE orm_list ${CMAKE_CURRENT_SOURCE_DIR}/orm/*.cpp)
+file(GLOB_RECURSE source_list ${CMAKE_CURRENT_SOURCE_DIR}/models/*.cpp)
+file(GLOB_RECURSE FRAMEWORK_CPP_PATH ${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpserver/*.cpp)
+file(GLOB_RECURSE common_list ${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp)
+file(GLOB_RECURSE controller_list ${CMAKE_CURRENT_SOURCE_DIR}/controller/src/*.cpp)
+file(GLOB_RECURSE viewsrc_list ${CMAKE_CURRENT_SOURCE_DIR}/viewsrc/view/*.cpp)
+file(GLOB_RECURSE reflect_list ${CMAKE_CURRENT_SOURCE_DIR}/libs/*.cpp)
+file(GLOB_RECURSE src_list ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
+
+foreach(cppfile IN LISTS controller_list)
+  string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/controller/src/" "" cppfilename ${cppfile})
+  string(REGEX REPLACE ".cpp" "" cppbasename ${cppfilename})
+#  message(${cppbasename})
+  if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/controller/include/${cppbasename}.h")
+  else()
+      file(TOUCH "${CMAKE_CURRENT_SOURCE_DIR}/controller/include/${cppbasename}.h")
+  endif()
+endforeach()
+
+function(include_sub_directories_recursively root_dir)
+    if (IS_DIRECTORY ${root_dir})               # 当前路径是一个目录吗,是的话就加入到包含目录
+        #        if (${root_dir} MATCHES "include")
+        message("include dir: " ${root_dir})
+        include_directories(${root_dir})
+        #        endif()
+    endif()
+
+    file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*) # 获得当前目录下的所有文件,让如ALL_SUB列表中
+
+    foreach(sub ${ALL_SUB})
+        if (IS_DIRECTORY ${root_dir}/${sub})
+            include_sub_directories_recursively(${root_dir}/${sub}) # 对子目录递归调用,包含
+        endif()
+    endforeach()
+endfunction()
+
+include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpserver)
+include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR}/orm)
+include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR}/models)
+include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR}/controller/include)
+include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR}/libs)
+include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+add_executable(paozhu_cli ${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpcli/http_cli.cpp)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
+
+
+if(${mode} AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
+  add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/test/testbenchmark.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
+else()
+  add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
+endif()
+
+if (ENABLE_WIN_VCPKG STREQUAL "ON")
+else ()
+add_custom_command(
+    TARGET paozhu_empty paozhu
+    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_pre
+    PRE_BUILD
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
+    COMMAND echo "-- controls method --"
+    COMMAND ${PAOZHU_PRE} ${CMAKE_CURRENT_SOURCE_DIR}/
+    COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_empty
+    )
+endif()
+
+if (ENABLE_VCPKG)
+    add_compile_definitions(ENABLE_VCPKG)
+    find_package(asio CONFIG REQUIRED)
+    target_link_libraries(paozhu asio::asio)
+
+    if (ENABLE_BOOST)
+        add_compile_definitions(ENABLE_BOOST)
+        set(Boost_NO_WARN_NEW_VERSIONS ON)
+        find_package(Boost REQUIRED COMPONENTS filesystem coroutine)
+        target_link_libraries(paozhu Boost::boost Boost::filesystem Boost::coroutine)
+    endif ()
+
+    find_package(OpenSSL REQUIRED)
+    target_link_libraries(paozhu OpenSSL::Crypto OpenSSL::SSL)
+
+    find_package(ZLIB REQUIRED)
+    target_link_libraries(paozhu ZLIB::ZLIB)
+
+    # find_package(libmysql REQUIRED)
+    find_package(unofficial-libmariadb CONFIG REQUIRED)
+    find_path(MYSQL_ROOT_DIR mysql)
+    # target_link_libraries(paozhu ${MYSQL_LIBRARIES})
+    # target_link_libraries(paozhu_cli ${MYSQL_LIBRARIES})
+    target_link_libraries(paozhu unofficial::libmariadb)
+    target_link_libraries(paozhu_cli unofficial::libmariadb)
+    target_include_directories(paozhu PUBLIC ${MYSQL_ROOT_DIR}/mysql)
+    target_include_directories(paozhu_cli PUBLIC ${MYSQL_ROOT_DIR}/mysql)
+
+    if (ENABLE_GD STREQUAL "ON")
+        find_package(PkgConfig)
+        pkg_check_modules(LIBGD REQUIRED IMPORTED_TARGET gdlib)
+        target_link_libraries(paozhu PkgConfig::LIBGD)
+
+        find_path(QRENCODE_INCLUDE_DIR NAMES qrencode.h)
+        find_library(QRENCODE_LIBRARY_RELEASE qrencode)
+        # find_library(QRENCODE_LIBRARY_DEBUG qrencoded)
+        # set(QRENCODE_LIBRARIES optimized ${QRENCODE_LIBRARY_RELEASE} debug ${QRENCODE_LIBRARY_DEBUG})
+        target_include_directories(paozhu PRIVATE ${QRENCODE_INCLUDE_DIR})
+        target_link_libraries(paozhu ${QRENCODE_LIBRARY_RELEASE})
+        # MESSAGE(STATUS ${QRENCODE_LIBRARY_RELEASE})
+
+        # warning: Fixed an issue where ports/libqrencode would not automatically
+        #          copy dll files to the bin directory
+        if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+            set(PATH_TO_QRENCODE_DLL "")
+            if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+                set(PATH_TO_QRENCODE_DLL "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/qrencode.dll")
+            elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+                set(PATH_TO_QRENCODE_DLL "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libqrencode.dll")
+            endif ()
+            message(STATUS "Selected libqrencode.dll: ${PATH_TO_QRENCODE_DLL}")
+
+            add_custom_command(
+                    TARGET paozhu POST_BUILD
+                    COMMAND ${CMAKE_COMMAND} -E copy_if_different
+                    ${PATH_TO_QRENCODE_DLL} ${CMAKE_CURRENT_SOURCE_DIR}/bin/
+            )
+        endif ()
+
+        find_package(PNG REQUIRED)
+        target_link_libraries(paozhu PNG::PNG)
+
+        find_package(Freetype REQUIRED)
+        target_link_libraries(paozhu Freetype::Freetype)
+    endif ()
+
+    find_package(unofficial-brotli CONFIG REQUIRED)
+    target_link_libraries(paozhu unofficial::brotli::brotlidec unofficial::brotli::brotlienc)
+else ()
+
+if(USE_STANDALONE_ASIO)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+set(ASIO_PATH "/usr/local/opt/asio/include" "/usr/local/include")
+else()
+set(ASIO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/asio "/usr/include")
+endif()
+
+    target_compile_definitions(paozhu INTERFACE ASIO_STANDALONE)
+    find_path(ASIO_PATH asio.hpp)
+    message(state " Standalone Asio found: " ${ASIO_PATH})
+    if(NOT ASIO_PATH)
+        message(FATAL_ERROR "Standalone Asio not found")
+    else()
+        target_include_directories(paozhu INTERFACE ${ASIO_PATH})
+    endif()
+
+    include_directories(${ASIO_PATH})
+
+endif()
+
+
+if(ENABLE_BOOST STREQUAL "ON")
+message("---ENABLE_BOOST-----")
+find_package(Boost REQUIRED
+             COMPONENTS system filesystem)
+if(Boost_FOUND)
+    add_compile_definitions(ENABLE_BOOST)
+    include_directories("${Boost_INCLUDE_DIRS}/boost")
+
+    MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
+    MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARY_DIRS}")
+    MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}")
+    link_directories(${Boost_LIBRARY_DIRS})
+    target_link_libraries (paozhu ${Boost_LIBRARIES})
+endif()
+
+endif()
+
+
+find_package(OpenSSL REQUIRED)
+
+if(OPENSSL_FOUND)
+
+  message(STATUS "OPENSSL_VERSION = ${OPENSSL_VERSION}")
+  message(STATUS "OPENSSL_SSL_LIBRARY = ${OPENSSL_SSL_LIBRARY}")
+  message(STATUS "OPENSSL_CRYPTO_LIBRARY = ${OPENSSL_CRYPTO_LIBRARY}")
+  message(STATUS "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}")
+  INCLUDE_DIRECTORIES("${OPENSSL_INCLUDE_DIR}")
+  target_link_libraries (paozhu ${OPENSSL_SSL_LIBRARY})
+  target_link_libraries (paozhu ${OPENSSL_CRYPTO_LIBRARY})
+endif()
+
+
+find_package(ZLIB REQUIRED)
+if(ZLIB_FOUND)
+  message(STATUS "Zlib Found! ${ZLIB_LIBRARIES}")
+  include_directories(${ZLIB_INCLUDE_DIR})
+  set(zlib_library ${ZLIB_LIBRARIES})
+  target_link_libraries(paozhu z)
+endif()
+
+find_path(MYSQL_ROOT_DIR mysql)
+MESSAGE( STATUS "MYSQL_ROOT_DIR = ${MYSQL_ROOT_DIR} ")
+find_package_handle_standard_args(mysql REQUIRED_VARS MYSQL_ROOT_DIR)
+
+FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
+  /usr/local/include/mysql
+  /usr/include/mysql
+  /usr/local/mysql/include
+)
+SET(MYSQL_NAMES mysqlclient)
+FIND_LIBRARY(MYSQL_LIBRARY
+  NAMES ${MYSQL_NAMES}
+  PATHS /usr/lib /usr/local/lib /usr/local/mysql/lib
+  PATH_SUFFIXES mysql
+)
+
+IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+  SET(MYSQL_FOUND TRUE)
+  SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
+ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+  SET(MYSQL_FOUND FALSE)
+  SET( MYSQL_LIBRARIES )
+ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
+
+IF (MYSQL_FOUND)
+  IF (NOT MYSQL_FIND_QUIETLY)
+    MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
+  ENDIF (NOT MYSQL_FIND_QUIETLY)
+ELSE (MYSQL_FOUND)
+  IF (MYSQL_FIND_REQUIRED)
+    MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
+    MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
+  ENDIF (MYSQL_FIND_REQUIRED)
+ENDIF (MYSQL_FOUND)
+
+target_include_directories(paozhu PUBLIC ${MYSQL_INCLUDE_DIR})
+target_link_libraries(paozhu ${MYSQL_LIBRARY})
+
+target_include_directories(paozhu_cli PUBLIC ${MYSQL_INCLUDE_DIR})
+target_link_libraries(paozhu_cli ${MYSQL_LIBRARY})
+
+
+
+if(ENABLE_GD STREQUAL "ON")
+message("---ENABLE_GD-----")
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+  set(GD_ROOT_DIR "/usr/local/opt/gd/lib")
+else()
+  set(GD_ROOT_DIR "${sys_so_path}")
+endif()
+
+set(find_gdname gd)
+
+find_library(GD_LIB_DIR
+  NAMES ${find_gdname}
+  PATHS "${GD_ROOT_DIR}"
+  NO_DEFAULT_PATH
+)
+
+if(NOT GD_LIB_DIR)
+message(FATAL_ERROR
+"GD Graphics Library NOT FOUND! please install . "
+)
+endif()
+
+message(STATUS "GD Graphics Library  at: ${GD_LIB_DIR}")
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+set(QR_ROOT_DIR "/usr/local/opt/qrencode/lib")
+else()
+set(QR_ROOT_DIR "${sys_so_path}")
+endif()
+
+set(find_qrname qrencode)
+
+find_library(QR_LIB_DIR
+  NAMES ${find_qrname}
+  PATHS "${QR_ROOT_DIR}"
+  NO_DEFAULT_PATH
+)
+
+if(NOT QR_LIB_DIR)
+message(FATAL_ERROR
+"qrencode Library  NOT FOUND! please install . "
+)
+endif()
+
+message(STATUS "qrencode at: ${QR_LIB_DIR}")
+
+INCLUDE_DIRECTORIES("${GD_ROOT_DIR}/include")
+INCLUDE_DIRECTORIES("${QR_ROOT_DIR}/include")
+link_directories("${QR_ROOT_DIR}/lib")
+link_directories("${GD_ROOT_DIR}/lib")
+target_link_libraries(paozhu ${GD_LIB_DIR})
+target_link_libraries(paozhu ${QR_LIB_DIR})
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+set(PNG_ROOT_DIR "/usr/local/opt/libpng/lib")
+else()
+set(PNG_ROOT_DIR "${sys_so_path}")
+endif()
+
+find_library(PNG_LIB_DIR
+  NAMES png
+  PATHS "${PNG_ROOT_DIR}"
+  NO_DEFAULT_PATH
+)
+target_link_libraries(paozhu ${PNG_LIB_DIR})
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+  set(FREETYPE_ROOT_DIR "/usr/local/opt/freetype/lib")
+else()
+  set(FREETYPE_ROOT_DIR "${sys_so_path}")
+endif()
+
+find_library(FREETYPE_LIB_DIR
+  NAMES freetype
+  PATHS "${FREETYPE_ROOT_DIR}"
+  NO_DEFAULT_PATH
+)
+target_link_libraries(paozhu ${FREETYPE_LIB_DIR})
+#end ENABLE_GD
+endif()
+
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+  set(BROTLI_ROOT_DIR "/usr/local/opt/brotli/lib")
+else()
+  set(BROTLI_ROOT_DIR "${sys_so_path}")
+endif()
+
+
+
+#find_package(Brotli COMPONENTS encoder decoder common REQUIRED)
+
+message(STATUS "Brotli at: ${BROTLI_ROOT_DIR}")
+
+set(find_brname brotlienc)
+set(find_brdename brotlidec)
+find_library(BR_LIB_DIR
+  NAMES ${find_brname}
+  PATHS "${BROTLI_ROOT_DIR}"
+  NO_DEFAULT_PATH
+)
+find_library(BRDEC_LIB_DIR
+  NAMES ${find_brdename}
+  PATHS "${BROTLI_ROOT_DIR}"
+  NO_DEFAULT_PATH
+)
+INCLUDE_DIRECTORIES("${BROTLI_ROOT_DIR}/include")
+link_directories("${BROTLI_ROOT_DIR}/lib")
+
+if(NOT BR_LIB_DIR)
+message(FATAL_ERROR
+"Brotli Library  NOT FOUND! please install . "
+)
+endif()
+
+message(STATUS "Brotli at: ${BR_LIB_DIR}")
+target_link_libraries(paozhu ${BR_LIB_DIR})
+
+
+if(NOT BRDEC_LIB_DIR)
+message(FATAL_ERROR
+"Brotli Library  NOT FOUND! please install . "
+)
+endif()
+
+message(STATUS "Brotli at: ${BRDEC_LIB_DIR}")
+target_link_libraries(paozhu ${BRDEC_LIB_DIR})
+
+
+message("Compile framework mode")
+
+target_link_libraries(paozhu  m  dl)
+
+endif ()
+
+if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+   target_link_libraries(paozhu ws2_32)
+   target_link_libraries(paozhu_cli ws2_32)
+endif ()

+ 51 - 0
frameworks/C++/paozhu/paozhu_benchmark/common/autocontrolmethod.hpp

@@ -0,0 +1,51 @@
+
+#ifndef __HTTP_AUTO_REG_CONTROL_HTTPMETHOD_HPP
+#define __HTTP_AUTO_REG_CONTROL_HTTPMETHOD_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include "httppeer.h" 
+
+#include "techempower.h"
+
+
+namespace http
+{
+  void _initauto_control_httpmethodregto(std::map<std::string, regmethold_t> &methodcallback)
+  {
+    struct regmethold_t temp;
+
+		temp.pre = nullptr;
+		temp.regfun = techempowerplaintext;
+		methodcallback.emplace("plaintext",temp);
+		temp.pre = nullptr;
+		temp.regfun = techempowerjson;
+		methodcallback.emplace("json",temp);
+		temp.pre = nullptr;
+		temp.regfun = techempowerdb;
+		methodcallback.emplace("db",temp);
+		temp.pre = nullptr;
+		temp.regfun = techempowerqueries;
+		methodcallback.emplace("queries",temp);
+		temp.pre = nullptr;
+		temp.regfun = techempowerfortunes;
+		methodcallback.emplace("fortunes",temp);
+		temp.pre = nullptr;
+		temp.regfun = techempowerupdates;
+		methodcallback.emplace("updates",temp);
+		temp.pre = nullptr;
+		temp.regfun = techempowercached_queries;
+		methodcallback.emplace("cached-queries",temp);
+		temp.pre = nullptr;
+		temp.regfun = techempowercached_db;
+		methodcallback.emplace("cached-db",temp);
+
+
+    }
+}
+
+#endif
+
+    

+ 32 - 0
frameworks/C++/paozhu/paozhu_benchmark/common/json_reflect_headers.h

@@ -0,0 +1,32 @@
+#pragma once
+#include <sstream>
+#include <string>
+#include <vector>
+#include <map>
+
+#include "types/techempower_json.h"
+#include "unicode.h"
+
+template <typename JSON_REF_OBJ_TEMP>
+std::string json_encode([[maybe_unused]] const JSON_REF_OBJ_TEMP &json_reflectobj) { return ""; }
+
+template <typename JSON_REF_OBJ_TEMP>
+std::string json_encode([[maybe_unused]] const std::vector<JSON_REF_OBJ_TEMP> &json_reflectobj) { return ""; }
+
+template <typename JSON_REF_OBJ_TEMP>
+unsigned int json_decode([[maybe_unused]] JSON_REF_OBJ_TEMP &json_reflectobj, [[maybe_unused]] const std::string &_json_data, [[maybe_unused]] unsigned int _offset) { return 0; }
+
+template <typename JSON_REF_OBJ_TEMP>
+unsigned int json_decode([[maybe_unused]] std::vector<JSON_REF_OBJ_TEMP> &json_reflectobj, [[maybe_unused]] const std::string &_json_data, [[maybe_unused]] unsigned int _offset) { return 0; }
+
+namespace http
+{
+
+std::string json_encode(const techempower_outjson_t &json_reflectobj);
+
+std::string json_encode(const std::vector<techempower_outjson_t> &json_reflectobj);
+
+unsigned int json_decode(techempower_outjson_t &json_reflectobj, const std::string &_json_data, unsigned int _offset = 0);
+
+unsigned int json_decode(std::vector<techempower_outjson_t> &json_reflectobj, const std::string &_json_data, unsigned int _offset = 0);
+}// namespace http

+ 16 - 0
frameworks/C++/paozhu/paozhu_benchmark/common/reghttpmethod.hpp

@@ -0,0 +1,16 @@
+#ifndef __HTTP_REGHTTPMETHOD_HPP
+#define __HTTP_REGHTTPMETHOD_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma once
+#endif// defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include "httppeer.h"
+namespace http
+{
+void _inithttpmethodregto(std::map<std::string, regmethold_t> &methodcallback)
+{
+}
+
+}// namespace http
+#endif

+ 20 - 0
frameworks/C++/paozhu/paozhu_benchmark/common/reghttpmethod_pre.hpp

@@ -0,0 +1,20 @@
+#ifndef __HTTP_REGHTTPMETHOD_PRE_HPP
+#define __HTTP_REGHTTPMETHOD_PRE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+#pragma once
+#endif// defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include "httppeer.h"
+namespace http
+{
+void _inithttpmethodregto_pre(std::map<std::string, regmethold_t> &methodcallback)
+{
+    struct regmethold_t temp;
+    //temp.pre = adminlogin;
+    //temp.regfun = adminmar;
+    //methodcallback.emplace("adminmar", temp);
+}
+
+}// namespace http
+#endif

+ 20 - 0
frameworks/C++/paozhu/paozhu_benchmark/conf/orm.conf

@@ -0,0 +1,20 @@
+[default]
+type=main
+host=tfb-database
+port=3306
+dbname=hello_world
+user=benchmarkdbuser
+password=benchmarkdbpass
+pretable=
+maxpool=5
+dbtype=mysql
+
+type=second
+host=tfb-database
+port=3306
+dbname=hello_world
+user=benchmarkdbuser
+password=benchmarkdbpass
+pretable=
+maxpool=20
+dbtype=mysql

+ 42 - 0
frameworks/C++/paozhu/paozhu_benchmark/conf/server.conf

@@ -0,0 +1,42 @@
+[default]
+threadmax=1024
+threadmin=5
+httpport=8888
+httpsport=4430
+cothreadnum=8 ;Coroutines run on thread num
+
+http2_enable=0
+debug_enable=1
+deamon_enable=0
+mainhost=localhost
+certificate_chain_file=localhost.pem
+private_key_file=localhost.key
+tmp_dh_file=dh4096.pem
+reboot_password=e10adc3949ba59abbe56e057f20f883e ;md5(md5("123456")+"rand_char"+md5("123456"))
+session_type=1 ;session save type 0.file 1.memory 2.redis 3.memcache 4.reserve
+static_file_compress_cache=1 ;1 enable, Cache static file compress(gzip,br) content to cache directory 
+modelspath=/root/benchmark/models
+serverpath=/root/benchmark
+viewpath=/root/benchmark/view
+viewsopath=/root/benchmark/module/view
+
+controlpath=/root/benchmark/controller
+controlsopath=/root/benchmark/module/controller
+
+temppath=/root/benchmark/temp
+logpath=/root/benchmark/log
+wwwpath=/root/benchmark/www/default
+pluginspath=/root/benchmark/plugins
+libspath=/root/benchmark/libs
+directorylist=0
+index=index.html
+;usehtmlcache=1
+;usehtmlcachetime=3600
+rewrite_404=0   ;1 file 2 action url path
+rewrite_404_action=index.html
+method_pre=
+method_after=
+show_visitinfo=0
+upload_max_size=16777216
+
+

+ 19 - 0
frameworks/C++/paozhu/paozhu_benchmark/controller/include/techempower.h

@@ -0,0 +1,19 @@
+
+#pragma once
+#include <chrono>
+#include <thread>
+#include "httppeer.h"
+
+namespace http
+{
+
+            
+	std::string techempowerplaintext(std::shared_ptr<httppeer> peer);
+	std::string techempowerjson(std::shared_ptr<httppeer> peer);
+	std::string techempowerdb(std::shared_ptr<httppeer> peer);
+	std::string techempowerqueries(std::shared_ptr<httppeer> peer);
+	std::string techempowerfortunes(std::shared_ptr<httppeer> peer);
+	std::string techempowerupdates(std::shared_ptr<httppeer> peer);
+	std::string techempowercached_queries(std::shared_ptr<httppeer> peer);
+	std::string techempowercached_db(std::shared_ptr<httppeer> peer);
+}

+ 241 - 0
frameworks/C++/paozhu/paozhu_benchmark/controller/src/techempower.cpp

@@ -0,0 +1,241 @@
+#include "orm.h"
+#include <chrono>
+#include <thread>
+#include <algorithm>
+#include <random>
+#include <chrono>
+#include "httppeer.h"
+#include "techempower.h"
+#include "datetime.h"
+#include "func.h"
+#include "pzcache.h"
+#include "json_reflect_headers.h"
+#include "techempower_json.h"
+namespace http
+{
+    //@urlpath(null,plaintext)
+    std::string techempowerplaintext(std::shared_ptr<httppeer> peer)
+    {
+        peer->type("text/plain; charset=UTF-8");
+        peer->set_header("Date", get_gmttime());
+        peer->output = "Hello, World!";
+        return "";
+    }
+
+    //@urlpath(null,json)
+    std::string techempowerjson(std::shared_ptr<httppeer> peer)
+    {
+        peer->type("application/json; charset=UTF-8");
+        peer->set_header("Date", get_gmttime());
+        struct techempower_outjson_t a;
+        a.message = "Hello, World!";
+        peer->output = json_encode(a);
+        return "";
+    }
+
+    //@urlpath(null,db)
+    std::string techempowerdb(std::shared_ptr<httppeer> peer)
+    {
+        peer->type("application/json; charset=UTF-8");
+        peer->set_header("Date", get_gmttime());
+        auto myworld = orm::World();
+        unsigned int rd_num = rand_range(1, 10000);
+        myworld.get_one(rd_num);
+
+        peer->output = myworld.data_tojson();
+        return "";
+    }
+
+    //@urlpath(null,queries)
+    std::string techempowerqueries(std::shared_ptr<httppeer> peer)
+    {
+        peer->type("application/json; charset=UTF-8");
+        peer->set_header("Date", get_gmttime());
+
+        unsigned int get_num = peer->get["queries"].to_int();
+        if (get_num == 0)
+        {
+            get_num = 1;
+        }
+        else if (get_num > 500)
+        {
+            get_num = 500;
+        }
+        auto myworld = orm::World();
+        myworld.record.reserve(get_num);
+        for (unsigned int i = 0; i < get_num; i++)
+        {
+            myworld.wheresql.clear();
+            unsigned int rd_num = rand_range(1, 10000);
+            myworld.where("id", rd_num).fetch_append();
+        }
+
+        peer->output = myworld.to_json();
+        return "";
+    }
+
+    //@urlpath(null,fortunes)
+    std::string techempowerfortunes(std::shared_ptr<httppeer> peer)
+    {
+        peer->type("text/html; charset=UTF-8");
+        peer->set_header("Date", get_gmttime());
+
+        auto myfortune = orm::Fortune();
+        myfortune.fetch();
+        myfortune.data.id = 0;
+        myfortune.data.message = "Additional fortune added at request time.";
+        myfortune.record.push_back(myfortune.data);
+
+        std::sort(myfortune.record.begin(), myfortune.record.end(), [](const auto &lhs, const auto &rhs)
+                  { return lhs.message < rhs.message; });
+        peer->val["list"].set_array();
+        OBJ_ARRAY item;
+        for (unsigned int i = 0; i < myfortune.record.size(); i++)
+        {
+            item["id"] = myfortune.record[i].id;
+            item["message"] = html_encode(myfortune.record[i].message);
+            peer->val["list"].push(item);
+        }
+
+        peer->view("techempower/fortunes");
+        return "";
+    }
+
+    //@urlpath(null,updates)
+    std::string techempowerupdates(std::shared_ptr<httppeer> peer)
+    {
+        peer->type("application/json; charset=UTF-8");
+        peer->set_header("Date", get_gmttime());
+        unsigned int get_num = peer->get["queries"].to_int();
+
+        if (get_num == 0)
+        {
+            get_num = 1;
+        }
+        else if (get_num > 500)
+        {
+            get_num = 500;
+        }
+        auto myworld = orm::World();
+        myworld.record.clear();
+        myworld.record.reserve(get_num);
+        for (unsigned int i = 0; i < get_num; i++)
+        {
+            myworld.wheresql.clear();
+            myworld.where("id", rand_range(1, 10000)).fetch_append();
+            if (myworld.effect() > 0)
+            {
+                unsigned int j = myworld.record.size() - 1;
+                myworld.data.randomnumber = rand_range(1, 10000);
+                myworld.record[j].randomnumber = myworld.data.randomnumber;
+                myworld.update("randomnumber");
+            }
+        }
+        peer->output = myworld.to_json();
+        return "";
+    }
+
+    //@urlpath(null,cached-queries)
+    std::string techempowercached_queries(std::shared_ptr<httppeer> peer)
+    {
+        peer->type("application/json; charset=UTF-8");
+        peer->set_header("Date", get_gmttime());
+
+        unsigned int get_num = peer->get["count"].to_int();
+        if (get_num == 0)
+        {
+            get_num = 1;
+        }
+        else if (get_num > 500)
+        {
+            get_num = 500;
+        }
+        auto myworld = orm::World();
+        std::string mycacheid = "alldatacache";
+
+        pzcache<std::vector<orm::worldbase::meta>> &temp_cache = pzcache<std::vector<orm::worldbase::meta>>::conn();
+
+        std::vector<orm::worldbase::meta> allcachedata_array;
+        allcachedata_array.reserve(10000);
+        // create rand data to cache
+        if (temp_cache.check(mycacheid) > -1)
+        {
+            allcachedata_array = temp_cache.get(mycacheid);
+        }
+        else
+        {
+            allcachedata_array.resize(10000);
+            for (unsigned int i = 0; i < 10000; i++)
+            {
+                allcachedata_array[i].id = i + 1;
+                allcachedata_array[i].randomnumber = rand_range(1, 10000);
+            }
+            temp_cache.save(mycacheid, allcachedata_array, 120);
+        }
+        // get rand data from cache
+        mycacheid = "my" + std::to_string(get_num);
+        myworld.record.reserve(get_num);
+        if (temp_cache.check(mycacheid) > -1)
+        {
+            myworld.record = temp_cache.get(mycacheid);
+        }
+        else
+        {
+            if (allcachedata_array.size() == 10000)
+            {
+                for (unsigned int i = 0; i < get_num; i++)
+                {
+                    unsigned int temp_rid = rand_range(0, 9999);
+                    myworld.record.push_back(allcachedata_array[temp_rid]);
+                }
+            }
+            temp_cache.save(mycacheid, myworld.record, 120);
+        }
+
+        peer->output = myworld.to_json();
+        return "";
+    }
+
+    //@urlpath(null,cached-db)
+    std::string techempowercached_db(std::shared_ptr<httppeer> peer)
+    {
+        peer->type("application/json; charset=UTF-8");
+        peer->set_header("Date", get_gmttime());
+        // this test from database to cache
+        unsigned int get_num = peer->get["count"].to_int();
+        if (get_num == 0)
+        {
+            get_num = 1;
+        }
+        else if (get_num > 500)
+        {
+            get_num = 500;
+        }
+        auto myworld = orm::World();
+        std::string mycacheid = "my" + std::to_string(get_num);
+
+        pzcache<std::vector<orm::worldbase::meta>> &temp_cache = pzcache<std::vector<orm::worldbase::meta>>::conn();
+
+        myworld.record.reserve(get_num);
+        if (temp_cache.check(mycacheid) > -1)
+        {
+            myworld.record = temp_cache.get(mycacheid);
+        }
+        else
+        {
+            std::vector<unsigned int> cacheid;
+            for (unsigned int i = 0; i < get_num; i++)
+            {
+                cacheid.push_back(rand_range(1, 10000));
+            }
+
+            std::string sqlstr = array_to_sql(cacheid);
+            myworld.whereIn("id", sqlstr).fetch();
+            temp_cache.save(mycacheid, myworld.record, 120);
+        }
+
+        peer->output = myworld.to_json();
+        return "";
+    }
+
+} // namespace http

+ 15 - 0
frameworks/C++/paozhu/paozhu_benchmark/libs/types/techempower_json.h

@@ -0,0 +1,15 @@
+#ifndef LIBS_TYPES_TECHEMPOWER_TYPE_H
+#define LIBS_TYPES_TECHEMPOWER_TYPE_H
+#include <string>
+#include <sstream>
+
+namespace http
+{
+//@reflect json to_json from_json
+struct techempower_outjson_t
+{
+    std::string message;
+};
+
+}// namespace http
+#endif

+ 291 - 0
frameworks/C++/paozhu/paozhu_benchmark/libs/types/techempower_json_jsonreflect.cpp

@@ -0,0 +1,291 @@
+#include <sstream>
+#include <string>
+#include <vector>
+#include <map>
+#include "types/techempower_json.h"
+#include "json_reflect_headers.h"
+#include "unicode.h"
+#include "func.h"
+//This file is automatically created, do not edit it
+
+namespace http
+{
+
+
+std::string json_encode(const techempower_outjson_t &json_reflectobj)
+	{
+ 
+    std::stringstream _stream;
+    _stream << "{"; 
+    _stream << "\"message\":\"" << http::utf8_to_jsonstring(json_reflectobj.message)<< "\"";
+                
+    _stream << "}";
+
+    return _stream.str();
+            
+	}
+
+
+std::string json_encode(const std::vector<techempower_outjson_t> &json_reflectobj)
+        {
+        std::stringstream _stream;
+        _stream << "["; 
+    
+            for(unsigned int i=0;i<json_reflectobj.size();i++) 
+            {
+                if(i>0)
+                {
+                    _stream <<",";
+                }
+                _stream <<json_encode(json_reflectobj[i]);
+            }
+    
+        _stream << "]";
+
+        return _stream.str();
+        }
+              
+     unsigned int json_decode(techempower_outjson_t &json_reflectobj,const std::string &_json_data,unsigned int _offset)
+     {           
+             bool _isarray=false;
+        for(;_offset<_json_data.size();_offset++)
+        {
+            if(_json_data[_offset]=='{')
+            {
+                break;
+            }
+            if(_json_data[_offset]=='[')
+            {
+                _isarray=true;
+                break;
+            }
+        }
+
+        if(_isarray)
+        {
+            for(;_offset<_json_data.size();_offset++)
+            {
+                if(_json_data[_offset]=='{')
+                {
+                    _isarray=false;
+                    break;
+                }   
+            }
+        }
+
+        if(_isarray==false)
+        {
+            if(_json_data[_offset]=='{')
+            {
+                _offset++;
+            }
+            std::string _json_key_name,_json_value_name;
+            for(;_offset<_json_data.size();_offset++)
+            {
+
+                //去除空格
+                _offset=http::json_string_trim(_json_data,_offset);
+                //如果是右侧括号表示这个对象已经结束
+                if(_json_data[_offset]==0x7D)
+                {
+                    return _offset;
+                }
+                //直到引号
+                if(_json_data[_offset]==0x22)
+                {
+                    unsigned int temp_offset=_offset;
+                    _json_value_name.clear();
+                    _json_key_name=http::jsonstring_to_utf8(&_json_data[_offset],_json_data.size()-_offset,temp_offset);
+
+                    _offset=temp_offset;
+                    if(_offset < _json_data.size() &&_json_data[_offset]==0x22)
+                    {
+                        _offset+=1;
+                    }
+                    //键名 后就是键值类型 循环去除空格
+                    _offset=http::json_string_trim(_json_data,_offset);
+                    if(_offset < _json_data.size() &&_json_data[_offset]!=':')
+                    {
+                        return _offset; 
+                    }
+                    _offset++;
+                    _offset=http::json_string_trim(_json_data,_offset);
+                    
+                    if(_offset < _json_data.size() &&_json_data[_offset]=='{')
+                    {   //还是一个对象,表示有嵌套对象
+                        //1 内置 struct map<std::string,*>
+                        //递归代码
+                    
+                            _offset++;
+                            for ( ; _offset < _json_data.size(); _offset++)
+                            {
+                                if (_json_data[_offset] == '}')
+                                {
+                                    //offset++;
+                                    break;
+                                }
+                                if (_json_data[_offset] == '"')
+                                {
+                                    _offset++;
+                                    for ( ; _offset < _json_data.size(); _offset++)
+                                    {
+                                        if (_json_data[_offset] == '"'&&_json_data[_offset-1]!=0x5C)
+                                        {
+                                            break;
+                                        }
+                                    }
+                                }
+                            }
+                                                
+
+                        if(_offset < _json_data.size() && (_json_data[_offset]==']'||_json_data[_offset]=='}'))
+                        {
+                            _offset-=1;
+                        }
+                        //直接下一个,不用处理键值
+                        continue;   
+                    }
+                    else if(_json_data[_offset]=='[')
+                    {   //表示有数组 
+                        //////////////////////////////////////////////////////////////////////
+                        //begin level1 []
+                        //vector<std::string> vector<std::pair<std::string,*>>   vector<vector<int|long|float|double>>
+                        //如果是非内置类型 直接使用json_decode<>
+
+                        //递归代码     
+
+                    
+                            _offset++;
+                            for ( ; _offset < _json_data.size(); _offset++)
+                            {
+                                if (_json_data[_offset] == ']')
+                                {
+                                    //offset++;
+                                    break;
+                                }
+                                if (_json_data[_offset] == '"')
+                                {
+                                    _offset++;
+                                    for ( ; _offset < _json_data.size(); _offset++)
+                                    {
+                                        if (_json_data[_offset] == '"'&&_json_data[_offset-1]!=0x5C)
+                                        {
+                                            break;
+                                        }
+                                    }
+                                }
+                            }
+                        
+                        //直接下一个,不用处理键值
+                        if(_offset < _json_data.size() && (_json_data[_offset]==']'||_json_data[_offset]=='}'))
+                        {
+                            _offset-=1;
+                        }
+                        continue;    
+                        //end level1[]
+                        ////////////////////////////////////////////////////////////////////
+                    }
+                    else if(_json_data[_offset]==0x22)
+                    {
+                        //如果键值也是字符串
+                        temp_offset=_offset;
+                        _json_value_name=http::jsonstring_to_utf8(&_json_data[_offset],_json_data.size()-_offset,temp_offset);
+                        _offset=temp_offset;
+                        if(_json_data[_offset]==0x22)
+                        {
+                            if((_offset+1)<_json_data.size())
+                            {
+                                if(_json_data[_offset+1]!=']'&&_json_data[_offset+1]!='}')
+                                {
+                                    _offset+=1;
+                                }
+                            }
+                        }
+                    }
+                    else
+                    {
+                        //表示是数字 bool NULL
+                        for(;_offset<_json_data.size();_offset++)
+                        {
+                            //结束条件
+                            if(_json_data[_offset]==','||_json_data[_offset]==']'||_json_data[_offset]=='}'||_json_data[_offset]==0x20||_json_data[_offset]==0x0A||_json_data[_offset]==0x0D||_json_data[_offset]=='\t')
+                            {
+                                break;
+                            }
+                            _json_value_name.push_back(_json_data[_offset]);
+                        }
+                        //让前面循环退出或返回
+                        if(_offset < _json_data.size() && _json_data[_offset]=='}')
+                        {
+                            _offset-=1;
+                        }
+                    }
+                    ////////////////////////////////////////////////////////
+                    // level1
+                    //处理对象赋值
+                    if (http::str_casecmp(_json_key_name, "message"))
+                            {
+
+                                json_reflectobj.message=_json_value_name;     
+                            }
+                            
+                    ////////////////////////////////////////////////////////
+                    //继续循环下一个键值
+                    continue;
+                }
+            }
+        }
+        return _offset;
+    }
+  
+unsigned int json_decode(std::vector<techempower_outjson_t> &json_reflectobj,const std::string &_json_data,unsigned int _offset)
+      {          
+             bool _isarray=false;
+        for(;_offset<_json_data.size();_offset++)
+        {
+            if(_json_data[_offset]=='{')
+            {
+                break;
+            }
+            if(_json_data[_offset]=='[')
+            {
+                _isarray=true;
+                break;
+            }
+        }
+
+        if(_isarray)
+        {
+            if(_json_data[_offset]=='[')
+            {
+                _offset+=1;
+            }
+            for(;_offset<_json_data.size();_offset++)
+            {
+                _offset=http::json_string_trim(_json_data,_offset);
+                //直接返回,这样可以防插入空的对象
+                if(_json_data[_offset]==0x5D)
+                {
+                    return _offset;
+                }else if(_json_data[_offset]=='{')
+                {
+                    techempower_outjson_t temp;
+                    _offset=json_decode(temp,_json_data,_offset);
+                    json_reflectobj.push_back(temp);
+                }
+
+            }
+            
+        }
+        else
+        {
+            techempower_outjson_t temp;
+            _offset=json_decode(temp,_json_data,_offset);
+            json_reflectobj.push_back(temp);
+            
+        }
+
+        return _offset; 
+    }
+         
+}

+ 0 - 19
frameworks/C++/silicon/CMakeLists.txt

@@ -1,19 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-project(silicon)
-
-include_directories(/include $ENV{MICROHTTPD_HOME}/include)
-
-link_directories(/lib $ENV{MICROHTTPD_HOME}/lib)
-
-add_definitions(-std=c++14 -ftemplate-depth=1024 -DNDEBUG -O3)
-
-add_executable(silicon_tpc_mysql techempower_microhttpd.cc)
-target_link_libraries(silicon_tpc_mysql microhttpd mysqlclient)
-
-add_executable(silicon_epoll_mysql techempower_microhttpd.cc)
-set_target_properties(silicon_epoll_mysql PROPERTIES COMPILE_FLAGS "-DTFB_USE_EPOLL")
-target_link_libraries(silicon_epoll_mysql microhttpd mysqlclient)
-
-add_executable(silicon_lwan_mysql techempower_lwan.cc)
-target_link_libraries(silicon_lwan_mysql mysqlclient lwan ubsan curl z pthread dl luajit-5.1)

+ 0 - 8
frameworks/C++/silicon/README.md

@@ -1,8 +0,0 @@
-# C++/silicon Benchmarking test
-
-Silicon is a C++ web framework located at https://github.com/matt-42/silicon
-
-### Note
-
-The `silicon-epoll-mysql` and `silicon-lwan-mysql` tests are currently not working. They have been removed from the `benchmark_config.json` file but the implementations still exist. You can see the old `benchmark_config.json` [here](https://github.com/TechEmpower/FrameworkBenchmarks/blob/5d44d57cbb5cbc209a2d6aeb23010b466c055200/frameworks/C%2B%2B/silicon/benchmark_config.json).
-

+ 0 - 28
frameworks/C++/silicon/benchmark_config.json

@@ -1,28 +0,0 @@
-{
-  "framework": "silicon",
-  "tests": [{
-    "default": {
-      "json_url"       : "/json",
-      "db_url"         : "/db",
-      "query_url"      : "/queries?queries=",
-      "fortune_url"    : "/fortunes",
-      "update_url"     : "/updates?queries=",
-      "plaintext_url"  : "/plaintext",
-      "port": 8080,
-      "approach": "Realistic",
-      "classification": "Micro",
-      "database": "MySQL",
-      "framework": "silicon",
-      "language": "C++",
-      "flavor": "None",
-      "orm": "Full",
-      "platform": "None",
-      "webserver": "microhttpd",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "silicon-tpc-mysql",
-      "notes": "",
-      "versus": "silicon"
-    }
-  }]
-}

+ 0 - 47
frameworks/C++/silicon/build/symbols.hh

@@ -1,47 +0,0 @@
-// Generated by iod_generate_symbols.
-#include <iod/symbol.hh>
-#ifndef IOD_SYMBOL_db
-#define IOD_SYMBOL_db
-    iod_define_symbol(db)
-#endif
-
-#ifndef IOD_SYMBOL_fortunes
-#define IOD_SYMBOL_fortunes
-    iod_define_symbol(fortunes)
-#endif
-
-#ifndef IOD_SYMBOL_id
-#define IOD_SYMBOL_id
-    iod_define_symbol(id)
-#endif
-
-#ifndef IOD_SYMBOL_json
-#define IOD_SYMBOL_json
-    iod_define_symbol(json)
-#endif
-
-#ifndef IOD_SYMBOL_message
-#define IOD_SYMBOL_message
-    iod_define_symbol(message)
-#endif
-
-#ifndef IOD_SYMBOL_plaintext
-#define IOD_SYMBOL_plaintext
-    iod_define_symbol(plaintext)
-#endif
-
-#ifndef IOD_SYMBOL_queries
-#define IOD_SYMBOL_queries
-    iod_define_symbol(queries)
-#endif
-
-#ifndef IOD_SYMBOL_randomNumber
-#define IOD_SYMBOL_randomNumber
-    iod_define_symbol(randomNumber)
-#endif
-
-#ifndef IOD_SYMBOL_updates
-#define IOD_SYMBOL_updates
-    iod_define_symbol(updates)
-#endif
-

+ 0 - 102
frameworks/C++/silicon/build/techempower.hh

@@ -1,102 +0,0 @@
-#include <unistd.h>
-#include <iostream>
-#include <silicon/api.hh>
-#include <silicon/middleware_factories.hh>
-#include <silicon/middlewares/mysql_connection.hh>
-#include <silicon/middlewares/mysql_orm.hh>
-#include "symbols.hh"
-
-using namespace s;
-using namespace sl;
-
-typedef decltype(D(_id(_auto_increment, _primary_key) = int(),
-                   _randomNumber = int())) random_number;
-
-typedef decltype(D(_id(_auto_increment, _primary_key) = int(),
-                   _message = std::string())) fortune;
-
-typedef mysql_orm_factory<random_number> rn_orm_factory;
-typedef mysql_orm<random_number> rn_orm;
-
-typedef mysql_orm_factory<fortune> fortune_orm_factory;
-typedef mysql_orm<fortune> fortune_orm;
-
-
-std::string escape_html_entities(std::string& data)
-{
-    std::string buffer;
-    buffer.reserve(data.size());
-    for(size_t pos = 0; pos != data.size(); ++pos) {
-        switch(data[pos]) {
-            case '&':  buffer.append("&amp;");       break;
-            case '\"': buffer.append("&quot;");      break;
-            case '\'': buffer.append("&apos;");      break;
-            case '<':  buffer.append("&lt;");        break;
-            case '>':  buffer.append("&gt;");        break;
-            default:   buffer.append(&data[pos], 1); break;
-        }
-    }
-    return std::move(buffer);
-}
-
-auto techempower_api = http_api(
-
-  GET / _plaintext = [] () { return response(_content_type = string_ref("text/plain"),
-                                       _body = string_ref("Hello, World!")); },
-
-  GET / _json = [] () { return response(_content_type = string_ref("application/json"),
-                                  _body = D(_message = "Hello, World!")); },
-                        
-  GET / _db = [] (rn_orm& orm) {
-    random_number r;
-    orm.find_by_id(1245, r);
-    return response(_content_type = "application/json",
-                    _body = r);
-  },
-
-  GET / _queries * get_parameters(_queries = optional(std::string("1"))) = [] (auto param, rn_orm& orm) {
-    int N = atoi(param.queries.c_str());
-    N = std::max(1, std::min(N, 500));
-
-    std::vector<random_number> qs(N);
-    for (int i = 0; i < N; i++)
-      orm.find_by_id(1 + rand() % 9999, qs[i]);
-    return response(_content_type = "application/json",
-                    _body = std::move(qs));
-  },
-
-  GET / _updates * get_parameters(_queries = optional(std::string("1"))) = [] (auto param, rn_orm& orm) {
-    int N = atoi(param.queries.c_str());
-    N = std::max(1, std::min(N, 500));
-
-    std::vector<random_number> qs(N);
-    for (int i = 0; i < N; i++)
-    {
-      orm.find_by_id(1 + rand() % 9999, qs[i]);
-      qs[i].randomNumber = 1 + rand() % 9999;
-      orm.update(qs[i]);
-    }
-    return response(_content_type = "application/json",
-                    _body = std::move(qs));
-  },
-  
-  GET / _fortunes = [] (fortune_orm& orm) {
-    std::vector<fortune> table;
-    orm.forall([&] (fortune& f) { table.push_back(f); });
-    table.push_back(fortune(0, "Additional fortune added at request time."));
-
-    std::sort(table.begin(), table.end(),
-              [] (const fortune& a, const fortune& b) { return a.message < b.message; });
-
-    std::stringstream ss;
-
-    ss << "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>";
-    for(auto& f : table)
-      ss << "<tr><td>" << f.id << "</td><td>" << escape_html_entities(f.message) << "</td></tr>";
-    ss << "</table></body></html>";
-
-    return response(_content_type = "text/html; charset=utf-8",
-                    _body = ss.str());
-  }
-  
-  );

+ 0 - 41
frameworks/C++/silicon/build/techempower_lwan.cc

@@ -1,41 +0,0 @@
-#include <silicon/backends/lwan.hh>
-
-#include "techempower.hh"
-
-using namespace s;
-using namespace sl;
-
-int main(int argc, char* argv[])
-{
-  if (argc != 3)
-  {
-    std::cerr << "Usage: " << argv[0] << " mysql_host port" << std::endl;
-    return 1;
-  }
-
-  auto techempower_middlewares = middleware_factories(
-    mysql_connection_factory(argv[1], "benchmarkdbuser", "benchmarkdbpass", "hello_world"),
-    fortune_orm_factory("Fortune"),
-    rn_orm_factory("World")
-    );
-  
-  try
-  {
-
-    // Write the pid.
-    std::ofstream pidfile(argv[3]);
-    pidfile << getpid() << std::endl;
-    pidfile.close();
-
-    // Start the server.
-    sl::lwan_json_serve(techempower_api, techempower_middlewares, atoi(argv[2]));
-  }
-  catch (std::exception& e)
-  {
-    std::cerr << e.what() << std::endl;
-  }
-  catch (sl::error::error& e)
-  {
-    std::cerr << e.what() << std::endl;
-  }
-}

+ 0 - 48
frameworks/C++/silicon/build/techempower_microhttpd.cc

@@ -1,48 +0,0 @@
-#include <silicon/backends/mhd.hh>
-
-#include "techempower.hh"
-
-using namespace s;
-using namespace sl;
-
-int main(int argc, char* argv[])
-{
-
-  if (argc != 4)
-  {
-    std::cerr << "Usage: " << argv[0] << " mysql_host port nthreads" << std::endl;
-    return 1;
-  }
-
-  auto techempower_middlewares = middleware_factories(
-    mysql_connection_factory(argv[1], "benchmarkdbuser", "benchmarkdbpass", "hello_world"),
-    fortune_orm_factory("Fortune"),
-    rn_orm_factory("World")
-    );
-  
-  try
-  {
-    // Write the pid.
-    std::ofstream pidfile(argv[3]);
-    pidfile << getpid() << std::endl;
-    pidfile.close();
-
-    // Start the server.
-    sl::mhd_json_serve(techempower_api, techempower_middlewares, atoi(argv[2]), _blocking
-#ifdef TFB_USE_EPOLL
-                       , _linux_epoll, _nthreads = atoi(argv[3])
-#else
-                       , _one_thread_per_connection
-#endif
-      );
-    
-  }
-  catch (std::exception& e)
-  {
-    std::cerr << e.what() << std::endl;
-  }
-  catch (sl::error::error& e)
-  {
-    std::cerr << e.what() << std::endl;
-  }
-}

+ 0 - 19
frameworks/C++/silicon/config.toml

@@ -1,19 +0,0 @@
-[framework]
-name = "silicon"
-
-[main]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Micro"
-database = "MySQL"
-database_os = "Linux"
-os = "Linux"
-orm = "Full"
-platform = "None"
-webserver = "microhttpd"
-versus = "silicon"

+ 0 - 39
frameworks/C++/silicon/silicon.dockerfile

@@ -1,39 +0,0 @@
-FROM buildpack-deps:xenial
-
-RUN apt-get update -yqq && apt-get install -yqq software-properties-common cmake apt-transport-https
-
-RUN add-apt-repository -s "deb http://apt.llvm.org/`lsb_release -cs`/ llvm-toolchain-`lsb_release -cs`-3.9 main"
-RUN wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add -
-RUN apt-get update -yqq
-RUN apt-get install -yqq clang-3.9 lldb-3.9
-
-ENV MICROHTTPD_VERSION=0.9.39
-ENV MICROHTTPD=/libmicrohttpd
-ENV MICROHTTPD_HOME=$MICROHTTPD-$VERSION
-
-RUN wget http://mirror.ibcp.fr/pub/gnu/libmicrohttpd/libmicrohttpd-$MICROHTTPD_VERSION.tar.gz
-RUN tar xf libmicrohttpd-$MICROHTTPD_VERSION.tar.gz
-RUN cd libmicrohttpd-$MICROHTTPD_VERSION && \
-    ./configure --prefix=$MICROHTTPD_HOME && \
-    make install
-
-ENV PATH=${MICROHTTPD_HOME}/bin:${PATH}
-
-RUN apt-get install -yqq libboost-dev cmake
-
-ENV SILICON=/silicon
-
-COPY ./ ./
-
-RUN git clone https://github.com/matt-42/silicon.git && \
-    cd silicon && \
-    git checkout ecaf04887c9dbbf0f457afab1f487268f6aeffab && \
-    CC=clang-3.9 CXX=clang++-3.9 ./install.sh /
-
-RUN cd build && \
-    cmake .. -DCMAKE_CXX_COMPILER=clang++-3.9 && \
-    make silicon_tpc_mysql
-
-EXPOSE 8080
-
-CMD /build/silicon_tpc_mysql tfb-database 8080 $(nproc)

+ 2 - 2
frameworks/C++/userver/userver-bare.dockerfile

@@ -1,4 +1,4 @@
-FROM ghcr.io/userver-framework/ubuntu-userver-build-base:v2 AS builder
+FROM ghcr.io/userver-framework/ubuntu-22.04-userver-pg AS builder
 
 RUN apt update && \
     apt install -y lsb-release wget software-properties-common gnupg && \
@@ -6,7 +6,7 @@ RUN apt update && \
 
 WORKDIR /src
 RUN git clone https://github.com/userver-framework/userver.git && \
-    cd userver && git checkout c2ca5454f0b0e93dd0a2e082904dedda5cda3052
+    cd userver && git checkout ec1a3b07793f8d4cd0968cd61d8e6079d667a1e7
 
 COPY userver_benchmark/ ./
 RUN mkdir build && cd build && \

+ 2 - 2
frameworks/C++/userver/userver.dockerfile

@@ -1,4 +1,4 @@
-FROM ghcr.io/userver-framework/ubuntu-userver-build-base:v2 AS builder
+FROM ghcr.io/userver-framework/ubuntu-22.04-userver-pg AS builder
 
 RUN apt update && \
     apt install -y lsb-release wget software-properties-common gnupg && \
@@ -6,7 +6,7 @@ RUN apt update && \
 
 WORKDIR /src
 RUN git clone https://github.com/userver-framework/userver.git && \
-    cd userver && git checkout c2ca5454f0b0e93dd0a2e082904dedda5cda3052
+    cd userver && git checkout ec1a3b07793f8d4cd0968cd61d8e6079d667a1e7
 
 COPY userver_benchmark/ ./
 RUN mkdir build && cd build && \

+ 2 - 2
frameworks/C++/userver/userver_configs/static_config.yaml

@@ -1,7 +1,7 @@
 # yaml
 components_manager:
     event_thread_pool:
-        threads: 5
+        threads: 9
         dedicated_timer_threads: 1
     coro_pool:
         initial_size: 10000              # Preallocate 10000 coroutines at startup.
@@ -12,7 +12,7 @@ components_manager:
 
         main-task-processor:            # Make a task processor for CPU-bound couroutine tasks.
             thread_name: main-worker    # OS will show the threads of this task processor with 'main-worker' prefix.
-            worker_threads: 23
+            worker_threads: 46
             guess-cpu-limit: true
 
         fs-task-processor:              # Make a separate task processor for filesystem bound tasks.

+ 0 - 29
frameworks/C/duda/README.md

@@ -1,29 +0,0 @@
-# Duda I/O Benchmarking Test
-
-This is the web service used to benchmark Duda I/O web services framework.
-
-http://duda.io
-
-## Requirements
-
-Just the GNU C Compiler and a Linux system running Kernel version >= 2.6.32
-
-## Tests available
-
-### 1. JSON
-
-URL: /json
-
-### 6. Plain text
-
-URL: /plaintext
-
-## About pending tests
-
-Most of tests that are related to database query are pending and will be available for the next Round.
-
-## Contact
-
-Eduardo Silva <[email protected]>
-
-

+ 0 - 24
frameworks/C/duda/benchmark_config.json

@@ -1,24 +0,0 @@
-{
-  "framework": "duda",
-  "tests": [{
-    "default": {
-      "json_url": "/json",
-      "plaintext_url": "/plaintext",
-      "port": 2001,
-      "approach": "Realistic",
-      "classification": "Platform",
-      "database": "None",
-      "framework": "None",
-      "language": "C",
-      "flavor": "None",
-      "orm": "Raw",
-      "platform": "duda",
-      "webserver": "Monkey",
-      "os": "Linux",
-      "database_os": "Linux",
-      "display_name": "Duda I/O",
-      "notes": "",
-      "versus": "duda"
-    }
-  }]
-}

+ 0 - 13
frameworks/C/duda/duda.dockerfile

@@ -1,13 +0,0 @@
-FROM python:2.7
-
-COPY ./ ./
-# Get v0.31 (no official releases that work 2015-06-25)
-
-RUN git clone https://github.com/monkey/dudac.git
-RUN cd dudac && git checkout 7c3d5b03b09fb4cb5f5e338fff72df2e25e95ef0 && \
-    ./dudac -r && \
-    ./dudac -s
-
-EXPOSE 2001
-
-CMD ["./dudac/dudac", "-w", "webservice", "-p", "2001"]

+ 0 - 7
frameworks/C/duda/webservice/Makefile.in

@@ -1,7 +0,0 @@
-NAME    = ws
-CC      = gcc
-CFLAGS  = -g -Wall -O2
-LDFLAGS =
-DEFS    =
-INCDIR  =
-OBJECTS = main.o

+ 0 - 81
frameworks/C/duda/webservice/main.c

@@ -1,81 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*
- * Duda I/O Benchmark Tests
- * ========================
- * This web service is made for the performance contest made by
- * TechEmpower, mode details here:
- *
- *     http://www.techempower.com/benchmarks
- *
- * At the moment only Tests 1 & 6 are implemented.
- */
-
-#include "webservice.h"
-#include "packages/json/json.h"
-
-/* Test Macros (Tn) */
-#define JSON_CONTENT_TYPE    "Content-Type: application/json"
-#define PLAIN_CONTENT_TYPE   "Content-Type: text/plain"
-#define T6_BODY              "Hello, World!"
-
-DUDA_REGISTER("Duda I/O Benchmark Test", "WS Bench");
-
-/*
- * Test type 1: JSON serialization
- * ===============================
- * This test use the JSON API object to compose the JSON response
- */
-void cb_json(duda_request_t *dr)
-{
-    char *body;
-    int body_len;
-    json_t *j_root;
-
-    /* Instance the JSON object and compose the content */
-    j_root = json->create_object();
-    json->add_to_object(j_root,
-                        "message",
-                        json->create_string("Hello, World!"));
-
-    /* Format output to string */
-    body = json->print_unformatted_gc(dr, j_root);
-    body_len = strlen(body);
-
-    /* Delete the JSON tree */
-    json->delete(j_root);
-
-    /* Compose the response */
-    response->http_status(dr, 200);
-    response->http_header_n(dr, JSON_CONTENT_TYPE, sizeof(JSON_CONTENT_TYPE) - 1);
-    response->print(dr, body, body_len);
-    response->end(dr, NULL);
-}
-
-
-/*
- * Test type 6: Plaintext
- * ======================
- */
-void cb_plaintext(duda_request_t *dr)
-{
-    response->http_status(dr, 200);
-    response->http_header_n(dr, PLAIN_CONTENT_TYPE, sizeof(PLAIN_CONTENT_TYPE) - 1);
-    response->print(dr, T6_BODY, sizeof(T6_BODY) - 1);
-    response->end(dr, NULL);
-}
-
-int duda_main()
-{
-    /* load packages */
-    duda_load_package(json, "json");
-
-    /* let this web service own the virtual host */
-    conf->service_root();
-
-    /* set callbacks */
-    map->static_add("/json", "cb_json");            /* Test #1 */
-    map->static_add("/plaintext", "cb_plaintext");  /* Test #6 */
-
-    return 0;
-}

+ 1 - 0
frameworks/C/h2o/benchmark_config.json

@@ -1,5 +1,6 @@
 {
   "framework": "h2o",
+  "maintainers": ["volyrique"],
   "tests": [{
     "default": {
       "json_url": "/json",

+ 3 - 3
frameworks/C/h2o/h2o.dockerfile

@@ -1,4 +1,4 @@
-ARG UBUNTU_VERSION=22.04
+ARG UBUNTU_VERSION=24.04
 
 ARG H2O_APP_PREFIX=/opt/h2o_app
 
@@ -25,6 +25,7 @@ RUN apt-get -yqq update && \
       libwslay-dev \
       libyajl-dev \
       libz-dev \
+      llvm-dev \
       make \
       ninja-build \
       pkg-config \
@@ -46,8 +47,7 @@ RUN curl -LSs "https://github.com/h2o/h2o/archive/${H2O_VERSION}.tar.gz" | \
       -G Ninja \
       -S . && \
     cmake --build build -j && \
-    cmake --install build && \
-    cp -a deps/picotls/include/picotls* deps/quicly/include/quicly* /usr/local/include
+    cmake --install build
 
 ARG MUSTACHE_C_REVISION=7fe52392879d0188c172d94bb4fde7c513d6b929
 

+ 120 - 79
frameworks/C/h2o/src/database.c

@@ -75,7 +75,7 @@ static void on_database_write_ready(h2o_socket_t *sock, const char *err);
 static void on_process_queries(void *arg);
 static void poll_database_connection(h2o_socket_t *sock, const char *err);
 static void prepare_statements(db_conn_t *conn);
-static void process_queries(db_conn_t *conn, bool removed);
+static void process_queries(db_conn_pool_t *pool);
 static void remove_connection(db_conn_t *conn);
 static void start_database_connect(db_conn_pool_t *pool, db_conn_t *conn);
 
@@ -237,7 +237,10 @@ static void on_database_connect_read_ready(h2o_socket_t *sock, const char *err)
 					h2o_timer_unlink(&conn->timer);
 					h2o_socket_read_stop(conn->sock);
 					h2o_socket_read_start(conn->sock, on_database_read_ready);
-					process_queries(conn, true);
+					*conn->pool->conn.tail = &conn->l;
+					conn->pool->conn.tail = &conn->l.next;
+					conn->l.next = NULL;
+					process_queries(conn->pool);
 					return;
 				default:
 					LIBRARY_ERROR("PQresultStatus", PQresultErrorMessage(result));
@@ -370,7 +373,13 @@ static void on_database_read_ready(h2o_socket_t *sock, const char *err)
 	for (PGnotify *notify = PQnotifies(conn->conn); notify; notify = PQnotifies(conn->conn))
 		PQfreemem(notify);
 
-	process_queries(conn, removed);
+	if (removed && conn->query_num) {
+		*conn->pool->conn.tail = &conn->l;
+		conn->pool->conn.tail = &conn->l.next;
+		conn->l.next = NULL;
+	}
+
+	process_queries(conn->pool);
 }
 
 static void on_database_timeout(h2o_timer_t *timer)
@@ -405,20 +414,83 @@ static void on_database_write_ready(h2o_socket_t *sock, const char *err)
 
 static void on_process_queries(void *arg)
 {
+	list_t *iter = NULL;
 	db_conn_pool_t * const pool = arg;
+	size_t query_num = 0;
 
-	while (pool->queries.head && pool->conn) {
-		db_conn_t * const conn = H2O_STRUCT_FROM_MEMBER(db_conn_t, l, pool->conn);
+	while (pool->queries.head && pool->conn.head) {
+		db_conn_t * const conn = H2O_STRUCT_FROM_MEMBER(db_conn_t, l, pool->conn.head);
+		db_query_param_t * const param = H2O_STRUCT_FROM_MEMBER(db_query_param_t,
+		                                                        l,
+		                                                        conn->pool->queries.head);
 
-		pool->conn = conn->l.next;
 		assert(conn->query_num);
-		process_queries(conn, true);
+		assert(pool->query_num < pool->config->max_query_num);
+		pool->conn.head = conn->l.next;
+		pool->queries.head = param->l.next;
+
+		if (!pool->conn.head) {
+			assert(pool->conn.tail == &conn->l.next);
+			pool->conn.tail = &pool->conn.head;
+		}
+
+		if (++pool->query_num == pool->config->max_query_num) {
+			assert(!pool->queries.head);
+			assert(pool->queries.tail == &param->l.next);
+			pool->queries.tail = &pool->queries.head;
+		}
+
+		if (do_execute_query(conn, param)) {
+			param->on_error(param, DB_ERROR);
+			on_database_error(conn, DB_ERROR);
+		}
+		else {
+			query_num++;
+
+			if (conn->query_num) {
+				*pool->conn.tail = &conn->l;
+				pool->conn.tail = &conn->l.next;
+				conn->l.next = NULL;
+			}
+			else {
+				conn->l.next = iter;
+				iter = &conn->l;
+			}
+		}
 	}
 
-	if (pool->queries.head && pool->conn_num)
-		start_database_connect(pool, NULL);
+	if (iter)
+		do {
+			db_conn_t * const conn = H2O_STRUCT_FROM_MEMBER(db_conn_t, l, iter);
+
+			iter = conn->l.next;
+
+			if (flush_connection(on_database_write_ready, conn))
+				on_database_error(conn, DB_ERROR);
+		} while (iter);
 
+	pool->conn.tail = &pool->conn.head;
 	pool->process_queries = false;
+	query_num += pool->config->max_query_num - pool->query_num;
+
+	for (iter = pool->conn.head; iter;) {
+		db_conn_t * const conn = H2O_STRUCT_FROM_MEMBER(db_conn_t, l, iter);
+
+		iter = conn->l.next;
+
+		if (flush_connection(on_database_write_ready, conn)) {
+			*pool->conn.tail = iter;
+			on_database_error(conn, DB_ERROR);
+		}
+		else
+			pool->conn.tail = &conn->l.next;
+	}
+
+	const size_t conn_num = pool->config->max_db_conn_num - pool->conn_num;
+
+	if (query_num > conn_num)
+		for (query_num -= conn_num; pool->conn_num && query_num; query_num--)
+			start_database_connect(pool, NULL);
 }
 
 static void poll_database_connection(h2o_socket_t *sock, const char *err)
@@ -536,54 +608,44 @@ static void prepare_statements(db_conn_t *conn)
 	}
 	else {
 		h2o_socket_read_start(conn->sock, on_database_read_ready);
-		process_queries(conn, true);
+		*conn->pool->conn.tail = &conn->l;
+		conn->pool->conn.tail = &conn->l.next;
+		conn->l.next = NULL;
+		process_queries(conn->pool);
 	}
 }
 
-static void process_queries(db_conn_t *conn, bool removed)
+static void process_queries(db_conn_pool_t *pool)
 {
-	const bool flush = conn->query_num && conn->pool->queries.head;
-
-	while (conn->query_num && conn->pool->queries.head) {
-		db_query_param_t * const param = H2O_STRUCT_FROM_MEMBER(db_query_param_t,
-		                                                        l,
-		                                                        conn->pool->queries.head);
-
-		if (++conn->pool->query_num == conn->pool->config->max_query_num) {
-			assert(conn->pool->queries.tail == &param->l.next);
-			conn->pool->queries.tail = &conn->pool->queries.head;
-		}
-
-		conn->pool->queries.head = param->l.next;
-
-		if (do_execute_query(conn, param)) {
-			param->on_error(param, DB_ERROR);
-			on_database_error(conn, DB_ERROR);
-			return;
-		}
-	}
-
-	if (flush && flush_connection(on_database_write_ready, conn))
-		on_database_error(conn, DB_ERROR);
-	else if (conn->query_num && removed) {
-		conn->l.next = conn->pool->conn;
-		conn->pool->conn = &conn->l;
+	if (!pool->process_queries && pool->queries.head) {
+		task_message_t * const msg = h2o_mem_alloc(sizeof(*msg));
+
+		assert(pool->query_num < pool->config->max_query_num);
+		memset(msg, 0, sizeof(*msg));
+		msg->arg = pool;
+		msg->super.type = TASK;
+		msg->task = on_process_queries;
+		pool->process_queries = true;
+		send_local_message(&msg->super, pool->local_messages);
 	}
-	else if (!conn->query_num && !removed)
-		// This call should not be problematic, assuming a relatively low number of connections.
-		remove_connection(conn);
 }
 
 static void remove_connection(db_conn_t *conn)
 {
-	list_t *iter = conn->pool->conn;
-	list_t **prev = &conn->pool->conn;
+	list_t *iter = conn->pool->conn.head;
+	list_t **prev = &conn->pool->conn.head;
 
 	for (; iter && iter != &conn->l; iter = iter->next)
 		prev = &iter->next;
 
-	if (iter)
+	if (iter) {
 		*prev = iter->next;
+
+		if (!conn->pool->conn.head) {
+			assert(conn->pool->conn.tail == &iter->next);
+			conn->pool->conn.tail = &conn->pool->conn.head;
+		}
+	}
 }
 
 static void start_database_connect(db_conn_pool_t *pool, db_conn_t *conn)
@@ -661,37 +723,15 @@ int execute_database_query(db_conn_pool_t *pool, db_query_param_t *param)
 	int ret = 1;
 
 	if (pool->query_num) {
-		if (pool->conn) {
-			// Delay sending the database queries to the server, so that if there is a rapid
-			// succession of calls to this function, all resultant queries would be inserted
-			// into a command pipeline with a smaller number of system calls.
-			if (!pool->process_queries) {
-				task_message_t * const msg = h2o_mem_alloc(sizeof(*msg));
-
-				memset(msg, 0, sizeof(*msg));
-				msg->arg = pool;
-				msg->super.type = TASK;
-				msg->task = on_process_queries;
-				send_local_message(&msg->super, pool->local_messages);
-				pool->process_queries = true;
-			}
-
-			ret = 0;
-		}
-		else {
-			if (pool->conn_num)
-				start_database_connect(pool, NULL);
-
-			if (pool->conn_num < pool->config->max_db_conn_num && pool->query_num)
-				ret = 0;
-		}
-
-		if (!ret) {
-			param->l.next = NULL;
-			*pool->queries.tail = &param->l;
-			pool->queries.tail = &param->l.next;
-			pool->query_num--;
-		}
+		// Delay sending the database queries to the server, so that if there is a rapid
+		// succession of calls to this function, all resultant queries would be inserted
+		// into a command pipeline with a smaller number of system calls.
+		param->l.next = NULL;
+		*pool->queries.tail = &param->l;
+		pool->queries.tail = &param->l.next;
+		pool->query_num--;
+		process_queries(pool);
+		ret = 0;
 	}
 
 	return ret;
@@ -704,9 +744,9 @@ void free_database_connection_pool(db_conn_pool_t *pool)
 
 	size_t num = 0;
 
-	if (pool->conn)
+	if (pool->conn.head)
 		do {
-			db_conn_t * const conn = H2O_STRUCT_FROM_MEMBER(db_conn_t, l, pool->conn);
+			db_conn_t * const conn = H2O_STRUCT_FROM_MEMBER(db_conn_t, l, pool->conn.head);
 
 			assert(!conn->queries.head);
 			assert(conn->query_num == pool->config->max_pipeline_query_num);
@@ -715,10 +755,10 @@ void free_database_connection_pool(db_conn_pool_t *pool)
 			h2o_socket_read_stop(conn->sock);
 			h2o_socket_close(conn->sock);
 			PQfinish(conn->conn);
-			pool->conn = pool->conn->next;
-			free(conn);
+			pool->conn.head = conn->l.next;
 			num++;
-		} while (pool->conn);
+			free(conn);
+		} while (pool->conn.head);
 
 	assert(num + pool->conn_num == pool->config->max_db_conn_num);
 }
@@ -732,6 +772,7 @@ void initialize_database_connection_pool(const char *conninfo,
 {
 	memset(pool, 0, sizeof(*pool));
 	pool->config = config;
+	pool->conn.tail = &pool->conn.head;
 	pool->conninfo = conninfo ? conninfo : "";
 	pool->local_messages = local_messages;
 	pool->loop = loop;

+ 1 - 1
frameworks/C/h2o/src/database.h

@@ -60,7 +60,7 @@ typedef struct db_query_param_t {
 
 typedef struct {
 	const struct config_t *config;
-	list_t *conn;
+	queue_t conn;
 	const char *conninfo;
 	h2o_linklist_t *local_messages;
 	h2o_loop_t *loop;

+ 4 - 3
frameworks/C/h2o/src/handlers/world.c

@@ -416,7 +416,7 @@ static void fetch_from_cache(uint64_t now,
 		h2o_cache_ref_t * const r = h2o_cache_fetch(data->world_cache, now, key, 0);
 
 		if (r) {
-			const uint32_t * const table = (const uint32_t *) r->value.base;
+			const uint16_t * const table = (const uint16_t *) r->value.base;
 
 			for (size_t i = 0; i < query_ctx->num_query; i++) {
 				const uint32_t id = query_ctx->res[i].id;
@@ -440,7 +440,7 @@ static void fetch_from_cache(uint64_t now,
 			memset(ctx, 0, sizeof(*ctx));
 			ctx->data = data;
 			ctx->loop = query_ctx->ctx->event_loop.h2o_ctx.loop;
-			ctx->table.len = (MAX_ID + 1) * sizeof(uint32_t);
+			ctx->table.len = (MAX_ID + 1) * sizeof(uint16_t);
 			ctx->table.base = h2o_mem_alloc(ctx->table.len);
 			memset(ctx->table.base, 0, ctx->table.len);
 			ctx->param.command = POPULATE_CACHE_QUERY;
@@ -605,10 +605,11 @@ static result_return_t on_populate_cache_result(db_query_param_t *param, PGresul
 		                                                                param,
 		                                                                param);
 		query_result_t r = {.id = 0};
-		uint32_t * const table = (uint32_t *) query_ctx->table.base;
+		uint16_t * const table = (uint16_t *) query_ctx->table.base;
 
 		for (size_t i = 0; i < num_rows; i++) {
 			process_result(result, i, &r);
+			assert(r.random_number <= UINT16_MAX);
 			table[r.id] = r.random_number;
 		}
 

+ 1 - 4
frameworks/CSharp/appmpower/src/Data/DbConnection.cs

@@ -142,10 +142,7 @@ namespace appMpower.Data
 
       public async Task OpenAsync()
       {
-#if ADO && SQLSERVER
-         _internalConnection = new();
-         _internalConnection.DbConnection = new System.Data.SqlClient.SqlConnection(_connectionString);
-#elif ADO && POSTGRESQL
+#if ADO && POSTGRESQL
          _internalConnection = new(); 
          _internalConnection.DbConnection = new Npgsql.NpgsqlConnection(_connectionString);
 #else

+ 1 - 1
frameworks/CSharp/appmpower/src/Data/DbConnections.cs

@@ -7,7 +7,7 @@ namespace appMpower.Data
    {
       private static bool _connectionsCreated = false;
       private static short _createdConnections = 0;
-      private static short _maxConnections = 250;
+      private static short _maxConnections = 500;
 
       private static ConcurrentStack<InternalConnection> _stack = new();
       private static ConcurrentQueue<TaskCompletionSource<InternalConnection>> _waitingQueue = new();

+ 2 - 1
frameworks/CSharp/appmpower/src/HttpApplication.cs

@@ -35,7 +35,8 @@ namespace appMpower
 
             if (pathStringLength == 10 && pathStringStart == "p")
             {
-               await PlainText.RenderAsync(httpResponse.Headers, httpResponseBody.Writer, _plainText);
+               //await PlainText.RenderAsync(httpResponse.Headers, httpResponseBody.Writer, _plainText);
+               PlainText.Render(httpResponse.Headers, httpResponseBody, _plainText);
                return;
             }
             else if (pathStringLength == 5 && pathStringStart == "j")

+ 11 - 0
frameworks/CSharp/appmpower/src/Kestrel/PlainText.cs

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.IO.Pipelines;
 using Microsoft.AspNetCore.Http;
 using Microsoft.Extensions.Primitives;
+using Microsoft.AspNetCore.Http.Features;
 
 namespace appMpower.Kestrel
 {
@@ -23,5 +24,15 @@ namespace appMpower.Kestrel
          await pipeWriter.WriteAsync(utf8String);
          pipeWriter.Complete();
       }
+
+      public static void Render(IHeaderDictionary headerDictionary, IHttpResponseBodyFeature httpResponseBodyFeature, byte[] utf8String)
+      {
+         headerDictionary.Add(_headerServer);
+         headerDictionary.Add(_headerContentType);
+         int length = utf8String.Length;
+         headerDictionary.Add(new KeyValuePair<string, StringValues>("Content-Length", length.ToString()));
+
+         httpResponseBodyFeature.Stream.Write(utf8String, 0, length);
+      }
    }
 }

+ 1 - 0
frameworks/CSharp/appmpower/src/Program.cs

@@ -19,6 +19,7 @@ namespace appMpower
          var kestrelServerOptions = new KestrelServerOptions();
 
          kestrelServerOptions.Listen(IPAddress.Any, 8080);
+         kestrelServerOptions.AllowSynchronousIO = true; 
          kestrelServerOptions.AddServerHeader = false;
 
          using var kestrelServer = new KestrelServer(Options.Create(kestrelServerOptions), socketTransportFactory, NullLoggerFactory.Instance);

+ 1 - 1
frameworks/CSharp/appmpower/src/appMpower.csproj

@@ -43,7 +43,7 @@
 
   <ItemGroup>
     <PackageReference Include="System.Data.Odbc" Version="8.0.0" />
-    <PackageReference Include="Npgsql" Version="8.0.0-*" />
+    <PackageReference Include="Npgsql" Version="8.0.2-*" />
   </ItemGroup>
 
   <PropertyGroup>

+ 1 - 0
frameworks/CSharp/aspnetcore-mono/Benchmarks/Benchmarks.csproj

@@ -25,6 +25,7 @@
 
     <PackageReference Include="Dapper" Version="2.0.90" />
     <PackageReference Include="MySqlConnector" Version="1.0.1" />
+    <PackageReference Include="Npgsql" Version="8.0.3" />
     <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0-rc1" />
     <PackageReference Include="System.IO.Pipelines" Version="5.0.0-rc.1.20451.14" />
   </ItemGroup>

+ 1 - 1
frameworks/CSharp/aspnetcore-mono/PlatformBenchmarks/PlatformBenchmarks.csproj

@@ -23,7 +23,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="Npgsql" Version="5.0.0-alpha1" />
+    <PackageReference Include="Npgsql" Version="8.0.3" />
     <PackageReference Include="System.IO.Pipelines" Version="5.0.0-rc.1.20451.14" />
   </ItemGroup>
 

+ 1 - 1
frameworks/CSharp/aspnetcore/src/Minimal/Minimal.csproj

@@ -9,7 +9,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Npgsql" Version="8.0.1" />
+    <PackageReference Include="Npgsql" Version="8.0.3" />
     <PackageReference Include="Dapper" Version="2.1.21" />
     <PackageReference Include="RazorSlices" Version="0.7.0" />
   </ItemGroup>

+ 1 - 1
frameworks/CSharp/aspnetcore/src/Mvc/Mvc.csproj

@@ -9,7 +9,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Npgsql" Version="8.0.0-rc.2" />
+    <PackageReference Include="Npgsql" Version="8.0.3" />
     <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-rc.2" />
   </ItemGroup>
 

+ 1 - 1
frameworks/CSharp/aspnetcore/src/Platform/Platform.csproj

@@ -19,7 +19,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="Npgsql" Version="8.0.1" />
+    <PackageReference Include="Npgsql" Version="8.0.3" />
     <PackageReference Include="MySqlConnector" Version="2.3.1" />
     <PackageReference Include="Dapper" Version="2.1.21" />
     <PackageReference Include="RazorSlices" Version="0.7.0" Condition="$(PublishAot) != 'true'" />

+ 3 - 3
frameworks/CSharp/beetlex/Benchmarks.sln

@@ -1,11 +1,11 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.28010.2036
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34728.123
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{12CA0190-5EA2-460F-ABC4-FAD454148EBF}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlatformBenchmarks", "PlatformBenchmarks\PlatformBenchmarks.csproj", "{8ACF83AD-E861-4642-BEF3-A6211F99389D}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformBenchmarks", "PlatformBenchmarks\PlatformBenchmarks.csproj", "{8ACF83AD-E861-4642-BEF3-A6211F99389D}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution

+ 2 - 3
frameworks/CSharp/beetlex/Benchmarks/Benchmarks.csproj

@@ -2,13 +2,12 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net8.0</TargetFramework>
     <ServerGarbageCollection>true</ServerGarbageCollection>
   </PropertyGroup>
   <ItemGroup>
     <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" />
+    <PackageReference Include="Npgsql" Version="8.0.3" />
   </ItemGroup>
 </Project>

+ 5 - 4
frameworks/CSharp/beetlex/Benchmarks/Program.cs

@@ -6,9 +6,9 @@ using System;
 using System.Threading;
 using System.Text;
 using BeetleX.Buffers;
-using SpanJson;
 using System.Collections.Generic;
 using BeetleX.EventArgs;
+using System.Text.Json;
 
 namespace Benchmarks
 {
@@ -109,8 +109,8 @@ namespace Benchmarks
                 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";
+            RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=64;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000";
+            //RawDb._connectionString = "Server=localhost;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
             await mComplete.Task;
         }
 
@@ -140,7 +140,8 @@ namespace Benchmarks
 
         public override void Write(PipeStream stream, HttpResponse response)
         {
-            JsonSerializer.NonGeneric.Utf8.SerializeAsync(Data, stream);
+
+            JsonSerializer.Serialize(stream, Data); ;
         }
 
 

+ 2 - 3
frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs

@@ -7,11 +7,11 @@ using System.Linq;
 using System.Runtime.Versioning;
 using System.Text;
 using System.Threading.Tasks;
-using System.Runtime.InteropServices.ComTypes;
-using BeetleX.EventArgs;
+
 using Microsoft.Extensions.Caching.Memory;
 using Npgsql;
 
+
 namespace PlatformBenchmarks
 {
     public class RawDb
@@ -342,7 +342,6 @@ namespace PlatformBenchmarks
                     }
                 }
                 mInited = true;
-                HttpServer.ApiServer.Log(LogType.Info, null, $"Init update commands cached");
                 return;
             }
         }

+ 3 - 2
frameworks/CSharp/beetlex/PlatformBenchmarks/GMTDate.cs

@@ -1,4 +1,5 @@
-using BeetleX.Buffers;
+
+using BeetleX.Light.Memory;
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -99,7 +100,7 @@ namespace PlatformBenchmarks
             return GetData(DateTime.Now);
         }
 
-        public void Write(PipeStream stream)
+        public void Write(IStreamWriter stream)
         {
             var data = DATE;
             stream.Write(data.Array, 0, data.Count);

+ 30 - 11
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.Caching.cs

@@ -1,18 +1,18 @@
-using BeetleX;
-using BeetleX.Buffers;
-using SpanJson;
+using BeetleX.Light.Memory;
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Text;
+using System.Text.Json;
 using System.Threading.Tasks;
 
 namespace PlatformBenchmarks
 {
     public partial class HttpHandler
     {
-       
 
-        public async Task caching(string queryString, PipeStream stream, HttpToken token, ISession session)
+
+        public async Task caching(string queryString, IStreamWriter stream)
         {
             int count = 1;
             if (!string.IsNullOrEmpty(queryString))
@@ -30,20 +30,39 @@ namespace PlatformBenchmarks
                 count = 500;
             if (count < 1)
                 count = 1;
+            ContentLengthMemory content = new ContentLengthMemory();
             try
             {
-                var data = await token.Db.LoadCachedQueries(count);
+                var data = await _db.LoadCachedQueries(count);
                 stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
-                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                content.Data = GetContentLengthMemory(stream);
                 GMTDate.Default.Write(stream);
-                token.ContentPostion = stream.CacheLength;
-                await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream);
+                stream.WriteSequenceNetStream.StartWriteLength();
+
+                var jsonWriter = GetJsonWriter(stream);
+                using (var unflush = stream.UnFlush())
+                {
+                    jsonWriter.WriteStartArray();
+                    foreach (var item in data)
+                    {
+                        jsonWriter.WriteStartObject();
+                        jsonWriter.WriteNumber("Id", item.Id);
+                        jsonWriter.WriteNumber("RandomNumber", item.RandomNumber);
+                        jsonWriter.WriteEndObject();
+                    }
+                    jsonWriter.WriteEndArray();
+                    jsonWriter.Flush();
+
+                }
             }
             catch (Exception e_)
             {
-                stream.Write(e_.Message);
+                Context.GetLoger(BeetleX.Light.Logs.LogLevel.Error)?.WriteException(Context, "PlatformBenchmarks", "caching", e_);
+                stream.WriteString(e_.Message);
             }
-            OnCompleted(stream, session, token);
+            var len = stream.WriteSequenceNetStream.EndWriteLength();
+            content.Full(len);
+
         }
     }
 }

+ 201 - 151
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.cs

@@ -1,15 +1,21 @@
-using BeetleX;
-using BeetleX.Buffers;
-using BeetleX.EventArgs;
-using SpanJson;
+using BeetleX.Light;
+using BeetleX.Light.Memory;
 using System;
+using System.Buffers;
 using System.Collections.Generic;
+using System.IO;
+using System.IO.Pipelines;
 using System.Text;
+using System.Text.Json;
 using System.Threading.Tasks;
 
 namespace PlatformBenchmarks
 {
-    public partial class HttpHandler : ServerHandlerBase
+
+
+
+
+    public partial class HttpHandler : SesionBase
     {
         private static readonly AsciiString _line = new AsciiString("\r\n");
 
@@ -45,7 +51,7 @@ 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 uint _jsonPayloadSize = (uint)System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(new JsonMessage { message = "Hello, World!" }).Length;
 
 
 
@@ -65,14 +71,12 @@ namespace PlatformBenchmarks
         private readonly static AsciiString _jsonResultPreamble =
         _httpsuccess
         + _headerContentTypeJson
-        + _headerServer
-       + _headerContentLength;
+        + _headerServer;
 
         private readonly static AsciiString _HtmlResultPreamble =
       _httpsuccess
       + _headerContentTypeHtml
-      + _headerServer
-     + _headerContentLength;
+      + _headerServer;
 
 
 
@@ -83,24 +87,49 @@ namespace PlatformBenchmarks
 
         private static byte _question = 63;
 
-        public HttpHandler()
+        struct ContentLengthMemory
+        {
+            public Memory<byte> Data { get; set; }
+
+            public void Full(int length)
+            {
+                _headerContentLength.Data.CopyTo(Data);
+                var span = Data.Slice(_headerContentLength.Length).Span;
+                var len = span.Write(length.ToString(), Encoding.ASCII);
+                for (int i = len; i < span.Length - 2; i++)
+                {
+                    span[i] = 32;
+                }
+                span[^2] = 13;
+                span[^1] = 10;
+            }
+        }
+
+
+        protected Memory<byte> GetContentLengthMemory(IStreamWriter writer)
         {
-            RequestDispatchs = new BeetleX.Dispatchs.DispatchCenter<HttpToken>(OnRequest, Math.Min(Environment.ProcessorCount, 16));
+            var result = writer.WriteSequenceNetStream.GetWriteMemory(28);
+            writer.WriteSequenceNetStream.WriteAdvance(28);
+            return result;
         }
 
-        private BeetleX.Dispatchs.DispatchCenter<HttpToken> RequestDispatchs;
+        public NetContext Context { get; set; }
+
+        public HttpHandler()
+        {
 
+        }
 
+        private Queue<RequestData> _Requests = new Queue<RequestData>();
 
-        public override void Connected(IServer server, ConnectedEventArgs e)
+        private RawDb _db;
+
+        private RequestData _ReadRequest = null;
+        public override void Connected(NetContext context)
         {
-            base.Connected(server, e);
-            e.Session.Socket.NoDelay = true;
-            var token = new HttpToken();
-            token.ThreadDispatcher = RequestDispatchs.Next();
-            token.Session = e.Session;
-            token.Db = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance);
-            e.Session.Tag = token;
+            base.Connected(context);
+            this.Context = context;
+            _db = new RawDb(new ConcurrentRandom(), Npgsql.NpgsqlFactory.Instance); ;
         }
 
         private int AnalysisUrl(ReadOnlySpan<byte> url)
@@ -114,195 +143,216 @@ namespace PlatformBenchmarks
 
         }
 
-        private void OnRequest(HttpToken token)
+        public override void Receive(NetContext context, object message)
         {
-            if (token.Requests.TryDequeue(out RequestData result))
+            var stream = context.Reader.ReadSequenceNetStream;
+            var reader = stream.GetReadOnlySequence();
+            var len = reader.IndexOf(_line);
+            while (len != null)
             {
-                OnStartRequest(result, token.Session, token, token.Session.Stream.ToPipeStream());
-            }
-        }
-
-        public override void SessionReceive(IServer server, SessionReceiveEventArgs e)
-        {
-            base.SessionReceive(server, e);
-            PipeStream pipeStream = e.Session.Stream.ToPipeStream();
-            HttpToken token = (HttpToken)e.Session.Tag;
-            var result = pipeStream.IndexOfLine();
-            while (result.End != null)
-            {
-                if (result.Length == 2)
+                var lendata = len.Value;
+                stream.ReadAdvance(lendata.Length);
+                if (lendata.Length == 2)
                 {
-                    pipeStream.ReadFree(result.Length);
-                    OnStartRequest(token.CurrentRequest, e.Session, token, pipeStream);
+                    _Requests.Enqueue(_ReadRequest);
+                    _ReadRequest = null;
                 }
                 else
                 {
-                    if (token.CurrentRequest == null)
+                    if (_ReadRequest == null)
+                    {
+                        _ReadRequest = new RequestData();
+                    }
+                    if (_ReadRequest.Action == null)
                     {
-                        var request = new RequestData();
-                        byte[] buffer = null;
-                        buffer = new byte[result.Length];
-                        pipeStream.Read(buffer, 0, result.Length);
-                        request.Data = new ArraySegment<byte>(buffer, 0, result.Length);
-                        AnalysisAction(request);
-                        if (request.Action == ActionType.Plaintext)
-                        {
-                            token.CurrentRequest = request;
-                        }
-                        else
-                        {
-                            token.CurrentRequest = request;
-                            pipeStream.ReadFree((int)pipeStream.Length);
-                            OnStartRequest(request, e.Session, token, pipeStream);
-                            return;
-                        }
+                        AnalysisAction(lendata, out var type, out var querystring);
+                        _ReadRequest.Action = type;
+                        _ReadRequest.QueryString = querystring;
+
                     }
                     else
                     {
-                        pipeStream.ReadFree(result.Length);
+
                     }
                 }
-                if (pipeStream.Length > 0)
-                    result = pipeStream.IndexOfLine();
-                else
-                    break;
+                reader = stream.GetReadOnlySequence();
+                len = reader.IndexOf(_line);
+            }
+            if (_Requests.Count > 0)
+            {
+                OnStartRequest(context.Writer);
             }
         }
 
-        private void AnalysisAction(RequestData requestData)
+        //public override void SessionReceive(IServer server, SessionReceiveEventArgs e)
+        //{
+        //    base.SessionReceive(server, e);
+        //    PipeStream pipeStream = e.Session.Stream.ToPipeStream();
+        //    HttpToken token = (HttpToken)e.Session.Tag;
+        //    var result = pipeStream.IndexOfLine();
+        //    while (result.End != null)
+        //    {
+        //        if (result.Length == 2)
+        //        {
+        //            pipeStream.ReadFree(result.Length);
+        //            OnStartRequest(token.CurrentRequest, e.Session, token, pipeStream);
+        //        }
+        //        else
+        //        {
+        //            if (token.CurrentRequest == null)
+        //            {
+        //                var request = new RequestData();
+        //                byte[] buffer = null;
+        //                buffer = new byte[result.Length];
+        //                pipeStream.Read(buffer, 0, result.Length);
+        //                request.Data = new ArraySegment<byte>(buffer, 0, result.Length);
+        //                AnalysisAction(request);
+        //                if (request.Action == ActionType.Plaintext)
+        //                {
+        //                    token.CurrentRequest = request;
+        //                }
+        //                else
+        //                {
+        //                    token.CurrentRequest = request;
+        //                    pipeStream.ReadFree((int)pipeStream.Length);
+        //                    OnStartRequest(request, e.Session, token, pipeStream);
+        //                    return;
+        //                }
+        //            }
+        //            else
+        //            {
+        //                pipeStream.ReadFree(result.Length);
+        //            }
+        //        }
+        //        if (pipeStream.Length > 0)
+        //            result = pipeStream.IndexOfLine();
+        //        else
+        //            break;
+        //    }
+        //}
+
+        private void AnalysisAction(ReadOnlySequence<byte> line, out ActionType type, out string queryString)
         {
-            var line = _line.AsSpan();
-            int len = requestData.Data.Count;
-            var receiveData = requestData.GetSpan();
-            ReadOnlySpan<byte> http = line;
-            ReadOnlySpan<byte> method = line;
-            ReadOnlySpan<byte> url = line;
-            int offset2 = 0;
-            int count = 0;
-            for (int i = 0; i < len; i++)
-            {
-                if (receiveData[i] == line[0])
-                {
-                    http = receiveData.Slice(offset2, i - offset2);
-                    break;
-                }
-                else
-                {
-                    if (receiveData[i] == _Space)
-                    {
-                        if (count != 0)
-                        {
-                            url = receiveData.Slice(offset2, i - offset2);
-                            offset2 = i + 1;
-                        }
-                        else
-                        {
-                            method = receiveData.Slice(offset2, i - offset2);
-                            offset2 = i + 1;
-                            count++;
-                        }
-                    }
-                }
-            }
-            int queryIndex = AnalysisUrl(url);
-            ReadOnlySpan<byte> baseUrl = default;
-            ReadOnlySpan<byte> queryString = default;
-            if (queryIndex > 0)
+            type = ActionType.Plaintext;
+            queryString = default;
+            var spanIndex = line.PositionOf((byte)32);
+            var postion = line.GetPosition(1, spanIndex.Value);
+            line = line.Slice(postion);
+            spanIndex = line.PositionOf((byte)32);
+            var url = line.Slice(0, spanIndex.Value);
+            int baseurlLen = 0;
+            spanIndex = url.PositionOf((byte)63);
+            if (spanIndex != null)
             {
-                baseUrl = url.Slice(0, queryIndex);
-                queryString = url.Slice(queryIndex + 1, url.Length - queryIndex - 1);
-                requestData.QueryString = Encoding.ASCII.GetString(queryString);
+                baseurlLen = (int)url.Slice(0, spanIndex.Value).Length;
+                queryString = url.Slice(baseurlLen + 1).ReadString(Encoding.ASCII);
             }
             else
             {
-                baseUrl = url;
+                baseurlLen = (int)url.Length;
             }
+
+            Span<byte> baseUrl = stackalloc byte[baseurlLen];
+            url.Slice(0, baseurlLen).CopyTo(baseUrl);
+
             if (baseUrl.Length == _path_Plaintext.Length && baseUrl.StartsWith(_path_Plaintext))
             {
-                requestData.Action = ActionType.Plaintext;
+                type = ActionType.Plaintext;
             }
             else if (baseUrl.Length == _path_Json.Length && baseUrl.StartsWith(_path_Json))
             {
-                requestData.Action = ActionType.Json;
+                type = ActionType.Json;
             }
             else if (baseUrl.Length == _path_Db.Length && baseUrl.StartsWith(_path_Db))
             {
-                requestData.Action = ActionType.Db;
+                type = ActionType.Db;
             }
             else if (baseUrl.Length == _path_Queries.Length && baseUrl.StartsWith(_path_Queries))
             {
-                requestData.Action = ActionType.Queries;
+                type = ActionType.Queries;
             }
 
             else if (baseUrl.Length == _cached_worlds.Length && baseUrl.StartsWith(_cached_worlds))
             {
-                requestData.Action = ActionType.Caching;
+                type = ActionType.Caching;
             }
 
             else if (baseUrl.Length == _path_Updates.Length && baseUrl.StartsWith(_path_Updates))
             {
-                requestData.Action = ActionType.Updates;
+                type = ActionType.Updates;
             }
             else if (baseUrl.Length == _path_Fortunes.Length && baseUrl.StartsWith(_path_Fortunes))
             {
-                requestData.Action = ActionType.Fortunes;
+                type = ActionType.Fortunes;
             }
             else
             {
-                requestData.Action = ActionType.Other;
+                type = ActionType.Other;
             }
         }
 
-        public virtual async Task OnStartRequest(RequestData data, ISession session, HttpToken token, PipeStream stream)
+        public async Task OnStartRequest(IStreamWriter stream)
         {
-            ActionType type = data.Action;
-            if (type == ActionType.Plaintext)
-            {
-                await Plaintext(stream, token, session);
-            }
-            else if (type == ActionType.Json)
-            {
-                await Json(stream, token, session);
-            }
-            else if (type == ActionType.Db)
-            {
-                await db(stream, token, session);
-            }
-            else if (type == ActionType.Queries)
-            {
-                await queries(data.QueryString, stream, token, session);
-            }
-            else if (type == ActionType.Caching)
-            {
-                await caching(data.QueryString, stream, token, session);
-            }
-            else if (type == ActionType.Updates)
-            {
-                await updates(data.QueryString, stream, token, session);
-            }
-            else if (type == ActionType.Fortunes)
+            bool haveData = false;
+            while (_Requests.Count > 0)
             {
-                await fortunes(stream, token, session);
+                haveData = true;
+                var data = _Requests.Dequeue();
+                ActionType type = data.Action.Value;
+                if (type == ActionType.Plaintext)
+                {
+                    Plaintext(stream);
+                }
+                else if (type == ActionType.Json)
+                {
+                    Json(stream);
+                }
+                else if (type == ActionType.Db)
+                {
+                    await db(stream);
+                }
+                else if (type == ActionType.Queries)
+                {
+                    await queries(data.QueryString, stream);
+                }
+                else if (type == ActionType.Caching)
+                {
+                    await caching(data.QueryString, stream);
+                }
+                else if (type == ActionType.Updates)
+                {
+                    await updates(data.QueryString, stream);
+                }
+                else if (type == ActionType.Fortunes)
+                {
+                    await fortunes(stream);
+                }
+                else
+                {
+                    await Default(stream);
+                }
             }
-            else
+            if (haveData)
             {
-                await Default(stream, token, session);
+                stream.Flush();
             }
-
         }
 
 
-        private void OnCompleted(PipeStream stream, ISession session, HttpToken token)
+
+
+        private Utf8JsonWriter GetJsonWriter(IStreamWriter stream)
         {
-            var type = token.CurrentRequest.Action;
-            if (type != ActionType.Plaintext && type != ActionType.Json)
-            {
-                token.FullLength((stream.CacheLength - token.ContentPostion).ToString());
-            }
-            if (token.Requests.IsEmpty && stream.Length == 0)
-                session.Stream.Flush();
-            token.CurrentRequest = null;
+            Utf8JsonWriter utf8JsonWriter = _utf8JsonWriter ??= new Utf8JsonWriter((Stream)stream.WriteSequenceNetStream, new JsonWriterOptions { SkipValidation = true });
+            utf8JsonWriter.Reset((Stream)stream.WriteSequenceNetStream);
+            return utf8JsonWriter;
         }
+        [ThreadStatic]
+        private static Utf8JsonWriter _utf8JsonWriter;
 
+        public static JsonWriterOptions _jsonWriterOptions = new JsonWriterOptions
+        {
+            SkipValidation = true
+        };
     }
 }

+ 23 - 11
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.db.cs

@@ -1,8 +1,7 @@
-using BeetleX;
-using BeetleX.Buffers;
-using SpanJson;
+using BeetleX.Light.Memory;
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Text;
 using System.Threading.Tasks;
 
@@ -12,23 +11,36 @@ namespace PlatformBenchmarks
     {
 
 
-        public async ValueTask db(PipeStream stream, HttpToken token, ISession session)
+        public async Task db(IStreamWriter stream)
         {
+            ContentLengthMemory content = new ContentLengthMemory();
+
             try
             {
-                var data = await token.Db.LoadSingleQueryRow();
+                var data = await _db.LoadSingleQueryRow();
                 stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
-                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                content.Data = GetContentLengthMemory(stream);
                 GMTDate.Default.Write(stream);
-                token.ContentPostion = stream.CacheLength;
-                System.Text.Json.JsonSerializer.Serialize<World>(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
+                stream.WriteSequenceNetStream.StartWriteLength();
+                var jsonWriter = GetJsonWriter(stream);
+                using (var unflush = stream.UnFlush())
+                {
+                    jsonWriter.WriteStartObject();
+                    jsonWriter.WriteNumber("Id", data.Id);
+                    jsonWriter.WriteNumber("RandomNumber", data.RandomNumber);
+                    jsonWriter.WriteEndObject();
+                    System.Text.Json.JsonSerializer.Serialize<World>((Stream)stream.WriteSequenceNetStream, data);
+                }
+
             }
             catch (Exception e_)
             {
-                HttpServer.ApiServer.Log(BeetleX.EventArgs.LogType.Error, null, $"db error {e_.Message}@{e_.StackTrace}");
-                stream.Write(e_.Message);
+                Context.GetLoger(BeetleX.Light.Logs.LogLevel.Error)?.WriteException(Context, "PlatformBenchmarks", "db", e_);
+                stream.WriteString(e_.Message);
             }
-            OnCompleted(stream, session, token);
+            var len = stream.WriteSequenceNetStream.EndWriteLength();
+            content.Full(len);
+
         }
     }
 }

+ 14 - 10
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.default.cs

@@ -1,6 +1,7 @@
-using BeetleX;
-using BeetleX.Buffers;
+
+using BeetleX.Light.Memory;
 using System;
+using System.Buffers;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -15,16 +16,19 @@ namespace PlatformBenchmarks
                + _headerContentTypeJson.ToString()
                + _headerServer.ToString();
 
-        public Task Default(PipeStream stream, HttpToken token, ISession session)
-        {
+        public ValueTask Default(IStreamWriter stream)
+        { 
+            
             stream.Write(_defaultPreamble.Data, 0, _defaultPreamble.Length);
-            token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+            ContentLengthMemory contentLength = new ContentLengthMemory();
+            contentLength.Data = GetContentLengthMemory(stream);
             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;
+            stream.WriteSequenceNetStream.StartWriteLength();
+            stream.WriteString("<b> beetlex server</b><hr/>");
+            stream.WriteString("path not found!");
+            var length = stream.WriteSequenceNetStream.EndWriteLength();
+            contentLength.Full(length);
+            return ValueTask.CompletedTask;
         }
     }
 }

+ 27 - 58
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.fortunes.cs

@@ -1,5 +1,5 @@
-using BeetleX;
-using BeetleX.Buffers;
+
+using BeetleX.Light.Memory;
 using System;
 using System.Collections.Generic;
 using System.Globalization;
@@ -13,87 +13,56 @@ namespace PlatformBenchmarks
     public partial class HttpHandler
     {
 
+        static readonly HtmlEncoder htmlEncoder = CreateHtmlEncoder();
+        static HtmlEncoder CreateHtmlEncoder()
+        {
+            var settings = new TextEncoderSettings(UnicodeRanges.BasicLatin, UnicodeRanges.Katakana, UnicodeRanges.Hiragana);
+            settings.AllowCharacter('\u2014'); // allow EM DASH through
+            return HtmlEncoder.Create(settings);
+        }
+
         private readonly static AsciiString _fortunesTableStart = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>";
         private readonly static AsciiString _fortunesRowStart = "<tr><td>";
         private readonly static AsciiString _fortunesColumn = "</td><td>";
         private readonly static AsciiString _fortunesRowEnd = "</td></tr>";
         private readonly static AsciiString _fortunesTableEnd = "</table></body></html>";
 
-        protected HtmlEncoder HtmlEncoder { get; } = CreateHtmlEncoder();
-
-        private static HtmlEncoder CreateHtmlEncoder()
-        {
-            var settings = new TextEncoderSettings(UnicodeRanges.BasicLatin, UnicodeRanges.Katakana, UnicodeRanges.Hiragana);
-            settings.AllowCharacter('\u2014');  // allow EM DASH through
-            return HtmlEncoder.Create(settings);
-        }
 
-        public async Task fortunes(PipeStream stream, HttpToken token, ISession session)
+        public async Task fortunes(IStreamWriter stream)
         {
+            ContentLengthMemory content = new ContentLengthMemory();
             try
             {
 
-                var data = await token.Db.LoadFortunesRows();
+                var data = await this._db.LoadFortunesRows();
 
                 stream.Write(_HtmlResultPreamble.Data, 0, _HtmlResultPreamble.Length);
-                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                content.Data = GetContentLengthMemory(stream);
                 GMTDate.Default.Write(stream);
-                token.ContentPostion = stream.CacheLength;
 
-                var html = token.GetHtmlBufferWriter();
-                html.Reset();
-                html.Write(_fortunesTableStart.Data, 0, _fortunesTableStart.Length);
+                stream.WriteSequenceNetStream.StartWriteLength();
+                stream.Write(_fortunesTableStart.Data, 0, _fortunesTableStart.Length);
                 foreach (var item in data)
                 {
-                    html.Write(_fortunesRowStart.Data, 0, _fortunesRowStart.Length);
-                    WriteNumeric(html, (uint)item.Id);
-                    html.Write(_fortunesColumn.Data, 0, _fortunesColumn.Length);
-                    html.Write(HtmlEncoder.Encode(item.Message));
-                    html.Write(_fortunesRowEnd.Data, 0, _fortunesRowEnd.Length);
+                    stream.Write(_fortunesRowStart.Data, 0, _fortunesRowStart.Length);
+                    stream.WriteString(item.Id.ToString(CultureInfo.InvariantCulture));
+                    stream.Write(_fortunesColumn.Data, 0, _fortunesColumn.Length);
+                    stream.WriteString(htmlEncoder.Encode(item.Message));
+                    stream.Write(_fortunesRowEnd.Data, 0, _fortunesRowEnd.Length);
                 }
-                html.Write(_fortunesTableEnd.Data, 0, _fortunesTableEnd.Length);
-                stream.Write(html.Data, 0, html.Length);
-
+                stream.Write(_fortunesTableEnd.Data, 0, _fortunesTableEnd.Length);
             }
             catch (Exception e_)
             {
-                HttpServer.ApiServer.Log(BeetleX.EventArgs.LogType.Error, null, $"fortunes error {e_.Message}@{e_.StackTrace}");
-                stream.Write(e_.Message);
-            }
-            OnCompleted(stream, session, token);
-        }
-
-        internal void WriteNumeric(HtmlBufferWriter writer, uint number)
-        {
-            const byte AsciiDigitStart = (byte)'0';
-
-            if (number < 10)
-            {
-                writer.Write((byte)(number + AsciiDigitStart));
-
+                Context.GetLoger(BeetleX.Light.Logs.LogLevel.Error)?.WriteException(Context, "PlatformBenchmarks", "fortunes", e_);
+                stream.WriteString(e_.Message);
             }
-            else if (number < 100)
-            {
-                var tens = (byte)((number * 205u) >> 11); // div10, valid to 1028
-                var span = new byte[2];
-                span[0] = (byte)(tens + AsciiDigitStart);
-                span[1] = (byte)(number - (tens * 10) + AsciiDigitStart);
-                writer.Write(span, 0, 2);
+            var len = stream.WriteSequenceNetStream.EndWriteLength();
+            content.Full(len);
 
-            }
-            else if (number < 1000)
-            {
-                var digit0 = (byte)((number * 41u) >> 12); // div100, valid to 1098
-                var digits01 = (byte)((number * 205u) >> 11); // div10, valid to 1028
-                var span = new byte[3];
-                span[0] = (byte)(digit0 + AsciiDigitStart);
-                span[1] = (byte)(digits01 - (digit0 * 10) + AsciiDigitStart);
-                span[2] = (byte)(number - (digits01 * 10) + AsciiDigitStart);
-                writer.Write(span, 0, 3);
-            }
         }
 
-        internal void WriteNumeric(PipeStream stream, uint number)
+        internal void WriteNumeric(IStreamWriter stream, uint number)
         {
             const byte AsciiDigitStart = (byte)'0';
 

+ 14 - 20
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.json.cs

@@ -1,8 +1,10 @@
 using BeetleX;
-using BeetleX.Buffers;
-using SpanJson;
+
+using BeetleX.Light.Memory;
+
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
@@ -11,29 +13,21 @@ namespace PlatformBenchmarks
 {
     public partial class HttpHandler
     {
-        
 
-        private static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions();
 
-        private static Utf8JsonWriter GetUtf8JsonWriter(PipeStream stream, HttpToken token)
-        {
-            var buffer = stream.CreateBufferWriter();
-            if (token.Utf8JsonWriter == null)
-            {
-                token.Utf8JsonWriter = new Utf8JsonWriter(buffer, new JsonWriterOptions { SkipValidation = true });
-            }
-            var writer = token.Utf8JsonWriter;
-            writer.Reset(buffer);
-            return writer;
-        }
-
-        public ValueTask Json(PipeStream stream, HttpToken token, ISession session)
+        public void Json(IStreamWriter stream)
         {
             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;
+            var jsonWriter = GetJsonWriter(stream);
+            using (var unflush = stream.UnFlush())
+            {
+                jsonWriter.WriteStartObject();
+                jsonWriter.WriteString("message", "Hello, World!");
+                jsonWriter.WriteEndObject();
+                jsonWriter.Flush();
+            }
+            
         }
     }
 }

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

@@ -1,5 +1,5 @@
-using BeetleX;
-using BeetleX.Buffers;
+
+using BeetleX.Light.Memory;
 using System;
 using System.Collections.Generic;
 using System.Text;
@@ -11,13 +11,11 @@ namespace PlatformBenchmarks
     {
       
 
-        public ValueTask Plaintext(PipeStream stream, HttpToken token, ISession session)
+        public void Plaintext(IStreamWriter stream)
         {
             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;
         }
     }
 }

+ 32 - 13
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.queries.cs

@@ -1,24 +1,24 @@
-using BeetleX;
-using BeetleX.Buffers;
-using SpanJson;
+using BeetleX.Light.Memory;
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Text;
+using System.Text.Json;
 using System.Threading.Tasks;
 
 namespace PlatformBenchmarks
 {
     public partial class  HttpHandler
     {
-        public async ValueTask queries(string queryString, PipeStream stream, HttpToken token, ISession session)
+        public async ValueTask queries(string queryString, IStreamWriter stream)
         {
             int count = 1;
-            if(!string.IsNullOrEmpty(queryString))
+            if (!string.IsNullOrEmpty(queryString))
             {
                 var values = queryString.Split('=');
-                if(values.Length>1)
+                if (values.Length > 1)
                 {
-                    if(int.TryParse(values[1],out int size))
+                    if (int.TryParse(values[1], out int size))
                     {
                         count = size;
                     }
@@ -28,20 +28,39 @@ namespace PlatformBenchmarks
                 count = 500;
             if (count < 1)
                 count = 1;
+            ContentLengthMemory content = new ContentLengthMemory();
             try
             {
-                var data = await token.Db.LoadMultipleQueriesRows(count);
+                var data = await _db.LoadMultipleQueriesRows(count);
                 stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
-                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                content.Data = GetContentLengthMemory(stream);
                 GMTDate.Default.Write(stream);
-                token.ContentPostion = stream.CacheLength;
-                System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
+
+                stream.WriteSequenceNetStream.StartWriteLength();
+
+                var jsonWriter = GetJsonWriter(stream);
+                using (var unflush = stream.UnFlush())
+                {
+                    jsonWriter.WriteStartArray();
+                    foreach (var item in data)
+                    {
+                        jsonWriter.WriteStartObject();
+                        jsonWriter.WriteNumber("Id", item.Id);
+                        jsonWriter.WriteNumber("RandomNumber", item.RandomNumber);
+                        jsonWriter.WriteEndObject();
+                    }
+                    jsonWriter.WriteEndArray();
+                    jsonWriter.Flush();
+
+                }
             }
             catch (Exception e_)
             {
-                stream.Write(e_.Message);
+                Context.GetLoger(BeetleX.Light.Logs.LogLevel.Error)?.WriteException(Context, "PlatformBenchmarks", "queries", e_);
+                stream.WriteString(e_.Message);
             }
-            OnCompleted(stream, session, token);
+            var len = stream.WriteSequenceNetStream.EndWriteLength();
+            content.Full(len);
         }
     }
 }

+ 14 - 11
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.updates.cs

@@ -1,16 +1,17 @@
-using BeetleX;
-using BeetleX.Buffers;
-using SpanJson;
+
+using BeetleX.Light.Memory;
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Text;
+using System.Text.Json;
 using System.Threading.Tasks;
 
 namespace PlatformBenchmarks
 {
     public partial class HttpHandler
     {
-        public async ValueTask updates(string queryString, PipeStream stream, HttpToken token, ISession session)
+        public async ValueTask updates(string queryString, IStreamWriter stream)
         {
             int count = 1;
             if (!string.IsNullOrEmpty(queryString))
@@ -28,22 +29,24 @@ namespace PlatformBenchmarks
                 count = 500;
             if (count < 1)
                 count = 1;
+            ContentLengthMemory content = new ContentLengthMemory();
             try
             {
-                var data = await token.Db.LoadMultipleUpdatesRows(count);
+                var data = await _db.LoadMultipleUpdatesRows(count);
 
                 stream.Write(_jsonResultPreamble.Data, 0, _jsonResultPreamble.Length);
-                token.ContentLength = stream.Allocate(HttpHandler._LengthSize);
+                content.Data = GetContentLengthMemory(stream);
                 GMTDate.Default.Write(stream);
-                token.ContentPostion = stream.CacheLength;
-                System.Text.Json.JsonSerializer.Serialize<World[]>(GetUtf8JsonWriter(stream, token), data, SerializerOptions);
+                stream.WriteSequenceNetStream.StartWriteLength();
+                JsonSerializer.Serialize((Stream)stream.WriteSequenceNetStream, data);
             }
             catch (Exception e_)
             {
-                HttpServer.ApiServer.Log(BeetleX.EventArgs.LogType.Error, null, $"updates error {e_.Message}@{e_.StackTrace}");
-                stream.Write(e_.Message);
+                Context.GetLoger(BeetleX.Light.Logs.LogLevel.Error)?.WriteException(Context, "PlatformBenchmarks", "updates", e_);
+                stream.WriteString(e_.Message);
             }
-            OnCompleted(stream, session, token);
+            var len = stream.WriteSequenceNetStream.EndWriteLength();
+            content.Full(len);
         }
     }
 }

+ 23 - 17
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpServer.cs

@@ -1,5 +1,5 @@
-using BeetleX;
-using BeetleX.EventArgs;
+using BeetleX.Light;
+using BeetleX.Light.Logs;
 using Microsoft.Extensions.Hosting;
 using System;
 using System.Collections.Generic;
@@ -11,38 +11,44 @@ namespace PlatformBenchmarks
 {
     public class HttpServer : IHostedService
     {
-        public static IServer ApiServer;
+        private static NetServer<HttpNetApplication, HttpHandler> _apiServer;
 
         public virtual Task StartAsync(CancellationToken cancellationToken)
         {
+            ThreadPool.SetMinThreads(Environment.ProcessorCount * 2, Environment.ProcessorCount * 2);
+            Constants.MemorySegmentMinSize = 1024 * 8;
+            Constants.MemorySegmentMaxSize = 1024 * 8;
+            Constants.InitMemoryBlock();
             ArraySegment<byte> date = GMTDate.Default.DATE;
-            ServerOptions serverOptions = new ServerOptions();
-            serverOptions.LogLevel = LogType.Error;
-            serverOptions.DefaultListen.Port = 8080;
-            serverOptions.Statistical = false;
-            serverOptions.BufferPoolMaxMemory = 1000;
-            serverOptions.BufferPoolSize = 1024 * 24;
-            ApiServer = SocketFactory.CreateTcpServer<HttpHandler>(serverOptions);
-            ApiServer.Open();
+            _apiServer = new NetServer<HttpNetApplication, HttpHandler>();
+            _apiServer.Options.LogLevel = BeetleX.Light.Logs.LogLevel.Error;
+            _apiServer.Options.AddLogOutputHandler<LogOutputToConsole>();
+            _apiServer.Options.SetDefaultListen(o =>
+            {
+                o.Port = 8080;
+            });
+            _apiServer.Start();
+
+
             if (!Program.UpDB)
             {
-               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";
+                RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=64;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000";
+                //RawDb._connectionString = "Server=127.0.0.1;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=256;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
             }
             else
             {
 
-                RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=64;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3;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=64;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
+                 RawDb._connectionString = "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;SSL Mode=Disable;Maximum Pool Size=64;NoResetOnClose=true;Enlist=false;Max Auto Prepare=4;Multiplexing=true;Write Coalescing Buffer Threshold Bytes=1000";
+                //RawDb._connectionString = "Server=127.0.0.1;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=64;NoResetOnClose=true;Enlist=false;Max Auto Prepare=3";
             }
-           // ApiServer.Log(LogType.Info, null, $"Debug mode [{Program.Debug}]");
+            // ApiServer.Log(LogType.Info, null, $"Debug mode [{Program.Debug}]");
             return Task.CompletedTask;
 
         }
 
         public virtual Task StopAsync(CancellationToken cancellationToken)
         {
-            ApiServer.Dispose();
+
             return Task.CompletedTask;
         }
     }

+ 57 - 57
frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs

@@ -1,76 +1,76 @@
-using BeetleX;
-using BeetleX.Buffers;
-using BeetleX.Dispatchs;
-using System;
-using System.Collections.Concurrent;
-using System.Text;
-using System.Text.Json;
+//using BeetleX;
+//using BeetleX.Buffers;
+//using BeetleX.Dispatchs;
+//using System;
+//using System.Collections.Concurrent;
+//using System.Text;
+//using System.Text.Json;
 
-namespace PlatformBenchmarks
-{
-    public class HttpToken
-    {
-        private byte[] mLengthBuffer = new byte[10];
+//namespace PlatformBenchmarks
+//{
+//    public class HttpToken
+//    {
+//        private byte[] mLengthBuffer = new byte[10];
 
-        public RawDb Db { get; set; }
+//        public RawDb Db { get; set; }
 
-        public HttpToken()
-        {
+//        public HttpToken()
+//        {
 
-        }
+//        }
 
-        public SingleThreadDispatcher<HttpToken> ThreadDispatcher { get; set; }
+//        public SingleThreadDispatcher<HttpToken> ThreadDispatcher { get; set; }
 
-        public ConcurrentQueue<RequestData> Requests { get; set; } = new ConcurrentQueue<RequestData>();
+//        public ConcurrentQueue<RequestData> Requests { get; set; } = new ConcurrentQueue<RequestData>();
 
-        public Utf8JsonWriter Utf8JsonWriter { get; set; }
+//        public Utf8JsonWriter Utf8JsonWriter { get; set; }
 
-        public ISession Session { get; set; }
+//        public ISession Session { get; set; }
 
-        public RequestData CurrentRequest { get; set; }
+//        public RequestData CurrentRequest { get; set; }
 
-        private HtmlBufferWriter mHtmlBufferWriter = null;
+//        private HtmlBufferWriter mHtmlBufferWriter = null;
 
-        public HtmlBufferWriter GetHtmlBufferWriter()
-        {
-            if (mHtmlBufferWriter == null)
-                mHtmlBufferWriter = new HtmlBufferWriter(2048);
-            return mHtmlBufferWriter;
-        }
+//        public HtmlBufferWriter GetHtmlBufferWriter()
+//        {
+//            if (mHtmlBufferWriter == null)
+//                mHtmlBufferWriter = new HtmlBufferWriter(2048);
+//            return mHtmlBufferWriter;
+//        }
 
-        public byte[] GetLengthBuffer(string length)
-        {
-            Encoding.ASCII.GetBytes(length, 0, length.Length, mLengthBuffer, 0);
-            for (int i = length.Length; i < mLengthBuffer.Length; i++)
-            {
-                mLengthBuffer[i] = 32;
-            }
-            mLengthBuffer[6] = (byte)'\r';
-            mLengthBuffer[7] = (byte)'\n';
-            return mLengthBuffer;
-        }
+//        public byte[] GetLengthBuffer(string length)
+//        {
+//            Encoding.ASCII.GetBytes(length, 0, length.Length, mLengthBuffer, 0);
+//            for (int i = length.Length; i < mLengthBuffer.Length; i++)
+//            {
+//                mLengthBuffer[i] = 32;
+//            }
+//            mLengthBuffer[6] = (byte)'\r';
+//            mLengthBuffer[7] = (byte)'\n';
+//            return mLengthBuffer;
+//        }
 
-        public int ContentPostion { get; set; }
+//        public int ContentPostion { get; set; }
 
-        public MemoryBlockCollection ContentLength { get; set; }
+//        public MemoryBlockCollection ContentLength { get; set; }
 
-        public void FullLength(string length)
-        {
-            var item = GetLengthBuffer(length);
-            ContentLength.Full(item);
-        }
+//        public void FullLength(string length)
+//        {
+//            var item = GetLengthBuffer(length);
+//            ContentLength.Full(item);
+//        }
 
-        private int mProcessStatus = 0;
+//        private int mProcessStatus = 0;
 
-        public void CompletedProcess()
-        {
-            System.Threading.Interlocked.Exchange(ref mProcessStatus, 0);
-        }
+//        public void CompletedProcess()
+//        {
+//            System.Threading.Interlocked.Exchange(ref mProcessStatus, 0);
+//        }
 
-        public bool EnterProcess()
-        {
-            return System.Threading.Interlocked.CompareExchange(ref mProcessStatus, 1, 0) == 0;
-        }
+//        public bool EnterProcess()
+//        {
+//            return System.Threading.Interlocked.CompareExchange(ref mProcessStatus, 1, 0) == 0;
+//        }
 
-    }
-}
+//    }
+//}

+ 19 - 0
frameworks/CSharp/beetlex/PlatformBenchmarks/NetApplication.cs

@@ -0,0 +1,19 @@
+using BeetleX.Light;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PlatformBenchmarks
+{
+    public class HttpNetApplication : ApplicationBase
+    {
+        public override bool Connecting(Socket socket, ListenHandler handler)
+        {
+            socket.NoDelay = true;
+            return true;
+        }
+    }
+}

+ 6 - 6
frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj

@@ -2,17 +2,17 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net8.0</TargetFramework>
     <ServerGarbageCollection>true</ServerGarbageCollection>
    
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="BeetleX" Version="1.6.5.41" />
-    <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
-    <PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
-    <PackageReference Include="Npgsql" Version="5.0.3" />
-    <PackageReference Include="SpanJson" Version="3.1.0" />
+    <PackageReference Include="BeetleX.Light" Version="0.10.24.607" />
+    <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
+    <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
+    <PackageReference Include="Npgsql" Version="8.0.3" />
+    <PackageReference Include="System.Runtime.Caching" Version="8.0.0" />
   </ItemGroup>
 
 </Project>

+ 6 - 0
frameworks/CSharp/beetlex/PlatformBenchmarks/Program.cs

@@ -1,6 +1,7 @@
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 using System;
+using System.IO;
 
 namespace PlatformBenchmarks
 {
@@ -14,7 +15,12 @@ namespace PlatformBenchmarks
         public static void Main(string[] args)
         {
             //Debug = (args != null && args.Length > 0 && args[0] == "debug");
+            var data = GMTDate.Default.DATE;
             UpDB = (args != null && args.Length > 0 && args[0] == "updb");
+            UpdateCommandsCached.Init();
+            //HttpServer server = new HttpServer();
+            //server.StartAsync(default);
+            //Console.ReadLine();
             new HostBuilder().ConfigureServices(delegate (HostBuilderContext hostContext, IServiceCollection services)
             {
                 services.AddHostedService<HttpServer>();

+ 3 - 14
frameworks/CSharp/beetlex/PlatformBenchmarks/RequestData.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Buffers;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -6,24 +7,12 @@ using System.Threading.Tasks;
 
 namespace PlatformBenchmarks
 {
-    public class RequestData : IDisposable
+    public class RequestData 
     {
-        public ArraySegment<byte> Data { get; set; }
-
-        public ReadOnlySpan<byte> GetSpan()
-        {
-            return new ReadOnlySpan<byte>(Data.Array, Data.Offset, Data.Count);
-        }
-
-        public void Dispose()
-        {
-
-            //System.Buffers.ArrayPool<byte>.Shared.Return(Data.Array);
-        }
 
         public string QueryString { get; set; }
 
-        public ActionType Action { get; set; }
+        public ActionType? Action { get; set; }
 
 
     }

+ 0 - 12
frameworks/CSharp/beetlex/beetlex-core-updb.dockerfile

@@ -1,12 +0,0 @@
-FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
-WORKDIR /app
-COPY PlatformBenchmarks .
-RUN dotnet publish -c Release -o out
-
-FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
-WORKDIR /app
-COPY --from=build /app/out ./
-
-EXPOSE 8080
-
-ENTRYPOINT ["dotnet", "PlatformBenchmarks.dll","updb"]

+ 2 - 2
frameworks/CSharp/beetlex/beetlex-core.dockerfile

@@ -1,9 +1,9 @@
-FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
 WORKDIR /app
 COPY PlatformBenchmarks .
 RUN dotnet publish -c Release -o out
 
-FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
 WORKDIR /app
 COPY --from=build /app/out ./
 

+ 2 - 2
frameworks/CSharp/beetlex/beetlex.dockerfile

@@ -1,9 +1,9 @@
-FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
 WORKDIR /app
 COPY Benchmarks .
 RUN dotnet publish -c Release -o out
 
-FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime
+FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
 WORKDIR /app
 COPY --from=build /app/out ./
 

+ 0 - 19
frameworks/CSharp/beetlex/benchmark_config.json

@@ -48,25 +48,6 @@
         "display_name": "beetlex-core",
         "notes": "",
         "versus": "aspcore"
-      },
-      "core-updb": {
-        "update_url": "/updates?queries=",
-        "fortune_url": "/fortunes",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "Platform",
-        "database": "Postgres",
-        "framework": "beetlex",
-        "language": "C#",
-        "orm": "Raw",
-        "platform": ".NET",
-        "flavor": "CoreCLR",
-        "webserver": "beetlex",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "beetlex-core-updb",
-        "notes": "",
-        "versus": "aspcore"
       }
     }
   ]

+ 0 - 12
frameworks/CSharp/beetlex/config.toml

@@ -36,15 +36,3 @@ platform = ".NET"
 webserver = "beetlex"
 versus = "aspcore"
 
-[core-updb]
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Platform"
-database = "Postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = ".NET"
-webserver = "beetlex"
-versus = "aspcore"

+ 6 - 6
frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj

@@ -28,13 +28,13 @@
     
   <ItemGroup>
 	  
-    <PackageReference Include="GenHTTP.Core" Version="8.0.0" />
-    <PackageReference Include="GenHTTP.Modules.Razor" Version="8.0.0" />
-    <PackageReference Include="GenHTTP.Modules.Webservices" Version="8.0.0" />
+    <PackageReference Include="GenHTTP.Core" Version="8.5.2" />
+    <PackageReference Include="GenHTTP.Modules.Razor" Version="8.5.0" />
+    <PackageReference Include="GenHTTP.Modules.Webservices" Version="8.5.0" />
 	  
-    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
-    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
+    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
 	  
   </ItemGroup>
   
-</Project>
+</Project>

+ 1 - 1
frameworks/CSharp/sisk/sisk/sisk.csproj

@@ -9,7 +9,7 @@
 	</PropertyGroup>
 
 	<ItemGroup>
-	  <PackageReference Include="Sisk.HttpServer" Version="0.16.0-rc-5" />
+	  <PackageReference Include="Sisk.HttpServer" Version="0.16.2" />
 	</ItemGroup>
 
 </Project>

+ 1 - 1
frameworks/Crystal/crystal/crystal-radix.dockerfile

@@ -1,4 +1,4 @@
-FROM crystallang/crystal:1.0.0
+FROM crystallang/crystal:1.12.1
 
 WORKDIR /crystal
 COPY shard.yml shard.yml

+ 1 - 1
frameworks/Crystal/crystal/crystal.dockerfile

@@ -1,4 +1,4 @@
-FROM crystallang/crystal:1.0.0
+FROM crystallang/crystal:1.12.1
 
 WORKDIR /crystal
 COPY shard.yml shard.yml

+ 1 - 1
frameworks/Crystal/crystal/shard.yml

@@ -7,7 +7,7 @@ crystal: "~> 1.0"
 dependencies:
   pg:
     github: will/crystal-pg
-    version: ~> 0.23.2
+    version: ~> 0.28.0
   radix:
     github: luislavena/radix
     version: ~> 0.4.1

+ 1 - 1
frameworks/Crystal/grip/grip.cr

@@ -121,7 +121,7 @@ end
 
 class Application < Grip::Application
   def initialize
-    super(environment: "production", serve_static: false)
+    super(environment: "production")
 
     get "/json", Json
     get "/plaintext", Plaintext

+ 1 - 1
frameworks/Crystal/grip/grip.dockerfile

@@ -1,4 +1,4 @@
-FROM crystallang/crystal:1.0.0
+FROM crystallang/crystal:1.12.1
 
 WORKDIR /grip
 COPY views views

+ 2 - 2
frameworks/Crystal/grip/shard.yml

@@ -4,11 +4,11 @@ version: 0.2.0
 dependencies:
   grip:
     github: grip-framework/grip
-    version: 2.0.0
+    version: 3.0.0
 
   pg:
     github: will/crystal-pg
-    version: 0.26.0
+    version: 0.28.0
 targets:
   grip:
     main: grip.cr

+ 0 - 7
frameworks/Crystal/h2o.cr/README.md

@@ -1,7 +0,0 @@
-# h2o.cr
-
-Crystal bindings to h2o
-
-### notes
-
-h2o.cr currently only support plaintext and json requests

+ 0 - 26
frameworks/Crystal/h2o.cr/benchmark_config.json

@@ -1,26 +0,0 @@
-{
-  "framework": "h2o.cr",
-  "tests": [
-    {
-      "default": {
-        "json_url": "/json",
-        "plaintext_url": "/plaintext",
-        "port": 7890,
-        "approach": "Realistic",
-        "classification": "Micro",
-        "database": "None",
-        "framework": "h2o.cr",
-        "language": "Crystal",
-        "flavor": "None",
-        "orm": "Raw",
-        "platform": "None",
-        "webserver": "h2o",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "crystal-h2o",
-        "notes": "",
-        "versus": "None"
-      }
-    }
-  ]
-}

+ 0 - 15
frameworks/Crystal/h2o.cr/config.toml

@@ -1,15 +0,0 @@
-[framework]
-name = "h2o.cr"
-
-[main]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-approach = "Realistic"
-classification = "Micro"
-database = "None"
-database_os = "Linux"
-os = "Linux"
-orm = "Raw"
-platform = "None"
-webserver = "h2o"
-versus = "None"

+ 0 - 24
frameworks/Crystal/h2o.cr/h2o.cr.dockerfile

@@ -1,24 +0,0 @@
-FROM debian:sid
-
-RUN apt-get update \
-  && apt-get install -yqq libh2o-evloop-dev libwslay-dev libyaml-0-2 libevent-dev libpcre3-dev \
-    gcc wget git libssl-dev libuv1-dev ca-certificates --no-install-recommends
-
-RUN wget -q https://github.com/crystal-lang/crystal/releases/download/0.26.1/crystal-0.26.1-1-linux-x86_64.tar.gz \
-  && tar --strip-components=1 -xzf crystal-0.26.1-1-linux-x86_64.tar.gz -C /usr/ \
-  && rm -f *.tar.gz
-
-WORKDIR /crystal
-
-ENV GC_MARKERS 1
-
-COPY ./ ./
-
-RUN shards install
-RUN gcc -shared -O3 lib/h2o/src/ext/h2o.c -I/usr/include -fPIC -o h2o.o
-ENV CRYSTAL_PATH=lib:/usr/share/crystal/src
-RUN crystal build --prelude=empty --no-debug --release -Dgc_none -Dfiber_none -Dexcept_none -Dhash_none -Dtime_none -Dregex_none -Dextreme h2o_evloop_hello.cr --link-flags="-Wl,-s $PWD/h2o.o -DH2O_USE_LIBUV=0" -o server.out
-
-EXPOSE 7890
-
-CMD sh run.sh

+ 0 - 114
frameworks/Crystal/h2o.cr/h2o_evloop_hello.cr

@@ -1,114 +0,0 @@
-require "reset/prelude"
-require "reset/patches"
-require "reset/json"
-require "h2o/h2o_evloop"
-
-class H2oHello < H2o
-  @config = LibH2o::H2oGlobalconfT.new
-  @ctx = LibH2o::H2oContextT.new
-  @accept_ctx = LibH2o::H2oAcceptCtxT.new
-  @loop : LibH2o::H2oLoopT*
-
-  macro hello
-    Handler.new do |handler, req|
-      generator = uninitialized LibH2o::H2oGeneratorT[2]
-      body = h2o_iovec_init("Hello, World!")
-      req.value.res.status = 200
-      req.value.res.reason = "OK"
-      req.value.res.content_length = body.len
-
-      # require h2o.c extension
-      h2o_add_header(req, H2O_TOKEN_CONTENT_TYPE, "text/plain")
-      h2o_start_response(req, generator)
-      h2o_send(req, pointerof(body), 1, LibH2o::H2oSendState::H2OSendStateFinal)
-      0
-    end
-  end
-
-  macro json
-    Handler.new do |handler, req|
-      generator = uninitialized LibH2o::H2oGeneratorT[2]
-      alloc = uninitialized UInt8[32]
-      buf = StackBuffer.new(alloc.to_unsafe)
-
-      len = {message: "Hello, World!"}.to_json(buf)
-      body = LibH2o::H2oIovecT.new(base: buf, len: len)
-
-      req.value.res.status = 200
-      req.value.res.reason = "OK"
-      req.value.res.content_length = body.len
-
-      h2o_add_header(req, H2O_TOKEN_CONTENT_TYPE, "application/json")
-      h2o_start_response(req, generator)
-      h2o_send(req, pointerof(body), 1, LibH2o::H2oSendState::H2OSendStateFinal)
-      0
-    end
-  end
-
-  def on_accept(listener : LibH2o::H2oSocketT*, err : LibC::Char*) : Void
-    return if err
-    return unless s = h2o_evloop_socket_accept(listener)
-    h2o_accept(pointerof(@accept_ctx), s)
-  end
-
-  def create_listener : Int32
-    addr = uninitialized LibC::SockaddrIn
-
-    pointerof(addr).clear
-    addr.sin_family = LibC::AF_INET
-    addr.sin_addr.s_addr = 0 # 0x100007f # b32(0x7f000001)
-    addr.sin_port = 0xd21e   # b16(7890)
-
-    option = 1
-    if (fd = socket(LibC::AF_INET, LibC::SOCK_STREAM | LibC::O_NONBLOCK | LibC::O_CLOEXEC, 0)) == -1 ||
-       setsockopt(fd, LibC::SOL_SOCKET, LibC::SO_REUSEADDR, pointerof(option), 4) != 0 ||
-       setsockopt(fd, LibC::SOL_SOCKET, LibC::SO_REUSEPORT, pointerof(option), 4) != 0 ||
-       setsockopt(fd, LibC::IPPROTO_TCP, LibC::TCP_QUICKACK, pointerof(option), 4) != 0 ||
-       ((option = H2O_DEFAULT_HANDSHAKE_TIMEOUT_IN_SECS) &&
-       setsockopt(fd, LibC::IPPROTO_TCP, LibC::TCP_DEFER_ACCEPT, pointerof(option), 4) != 0) ||
-       ((option = DEFAULT_TCP_FASTOPEN_QUEUE_LEN) &&
-       setsockopt(fd, LibC::IPPROTO_TCP, LibC::TCP_FASTOPEN, pointerof(option), 4) != 0) ||
-       bind(fd, pointerof(addr).as(LibC::Sockaddr*), sizeof(LibC::SockaddrIn)) != 0 ||
-       listen(fd, LibC::SOMAXCONN) != 0
-      return -1
-    end
-
-    sock = h2o_evloop_socket_create(@ctx.loop, fd, H2O_SOCKET_FLAG_DONT_READ)
-    h2o_socket_read_start(sock, LibH2o::H2oSocketCb.new { |listener, err|
-      {{@type}}.instance.on_accept(listener, err)
-    })
-    0
-  end
-
-  def register_handler(hostconf : LibH2o::H2oHostconfT*, path : String, on_req : Handler) : Void
-    pathconf = h2o_config_register_path(hostconf, path, 0)
-    handler = h2o_create_handler(pathconf, sizeof(LibH2o::H2oHandlerT))
-    handler.value.on_req = on_req
-  end
-
-  def initialize
-    @loop = h2o_evloop_create()
-  end
-
-  def run : Void
-    h2o_config_init(pointerof(@config))
-    @config.server_name = h2o_iovec_init("h2o")
-
-    hostconf = h2o_config_register_host(pointerof(@config), h2o_iovec_init("default"), 65535)
-    register_handler(hostconf, "/plaintext", hello)
-    register_handler(hostconf, "/json", json)
-
-    h2o_context_init(pointerof(@ctx), @loop, pointerof(@config))
-
-    @accept_ctx.ctx = pointerof(@ctx)
-    @accept_ctx.hosts = @config.hosts
-
-    if create_listener != 0
-      return 1
-    end
-
-    while h2o_evloop_run(@ctx.loop, Int32::MAX) == 0; end
-  end
-end
-
-H2oHello.run

+ 0 - 7
frameworks/Crystal/h2o.cr/run.sh

@@ -1,7 +0,0 @@
-#!/bin/sh
-
-for i in $(seq 1 $(nproc --all)); do
-  ./server.out &
-done
-
-wait

+ 0 - 15
frameworks/Crystal/h2o.cr/shard.yml

@@ -1,15 +0,0 @@
-name: crystal-h2o
-version: 0.0.1
-
-license: MIT
-
-crystal: 0.26.1
-
-dependencies:
-  h2o:
-    github: s-you/h2o.cr
-  uv:
-    github: s-you/uv.cr
-  reset:
-    github: s-you/reset.cr
-    branch: h2o

+ 1 - 1
frameworks/Crystal/kemal/kemal-concurrent-queries.dockerfile

@@ -1,4 +1,4 @@
-FROM crystallang/crystal:0.32.1
+FROM crystallang/crystal:1.12.1
 
 WORKDIR /kemal
 COPY views views

+ 1 - 1
frameworks/Crystal/kemal/kemal.dockerfile

@@ -1,4 +1,4 @@
-FROM crystallang/crystal:0.32.1
+FROM crystallang/crystal:1.12.1
 
 WORKDIR /kemal
 COPY views views

+ 21 - 21
frameworks/Crystal/kemal/shard.lock

@@ -1,38 +1,38 @@
-version: 1.0
+version: 2.0
 shards:
+  backtracer:
+    git: https://github.com/sija/backtracer.cr.git
+    version: 1.2.2
+
   commander:
-    github: snluu/commander
-    commit: 9396efd427f06f0f6de5206f6e81d54fcd254abe
+    git: https://github.com/snluu/commander.git
+    version: 0.1.0+git.commit.9396efd427f06f0f6de5206f6e81d54fcd254abe
 
   db:
-    github: crystal-lang/crystal-db
-    version: 0.8.0
+    git: https://github.com/crystal-lang/crystal-db.git
+    version: 0.13.1
 
   exception_page:
-    github: crystal-loot/exception_page
-    version: 0.1.2
+    git: https://github.com/crystal-loot/exception_page.git
+    version: 0.4.1
 
   kemal:
-    github: kemalcr/kemal
-    version: 0.26.1
-
-  kilt:
-    github: jeromegn/kilt
-    version: 0.4.0
+    git: https://github.com/kemalcr/kemal.git
+    version: 1.5.0
 
   pg:
-    github: will/crystal-pg
-    version: 0.20.0
+    git: https://github.com/will/crystal-pg.git
+    version: 0.28.0
 
   pool:
-    github: ysbaddaden/pool
-    version: 0.2.3
+    git: https://github.com/ysbaddaden/pool.git
+    version: 0.3.0
 
   radix:
-    github: luislavena/radix
-    version: 0.3.9
+    git: https://github.com/luislavena/radix.git
+    version: 0.4.1
 
   redis:
-    github: stefanwille/crystal-redis
-    version: 2.5.3
+    git: https://github.com/stefanwille/crystal-redis.git
+    version: 2.8.0
 

+ 3 - 3
frameworks/Crystal/kemal/shard.yml

@@ -6,12 +6,12 @@ license: MIT
 dependencies:
   pg:
     github: will/crystal-pg
-    version: 0.20.0
+    version: 0.28.0
   kemal:
     github: kemalcr/kemal
-    version: 0.26.1
+    version: 1.5.0
   redis:
     github: stefanwille/crystal-redis
-    version: 2.5.3
+    version: 2.8.0
   commander:
     github: snluu/commander

+ 1 - 1
frameworks/Crystal/lucky/lucky.dockerfile

@@ -1,4 +1,4 @@
-FROM crystallang/crystal:1.1.0
+FROM crystallang/crystal:1.12.1
 
 WORKDIR /lucky
 COPY shard.lock shard.lock

+ 28 - 20
frameworks/Crystal/lucky/shard.lock

@@ -2,11 +2,15 @@ version: 2.0
 shards:
   avram:
     git: https://github.com/luckyframework/avram.git
-    version: 0.21.0
+    version: 1.2.0
 
   backtracer:
     git: https://github.com/sija/backtracer.cr.git
-    version: 1.2.1
+    version: 1.2.2
+
+  cadmium_transliterator:
+    git: https://github.com/cadmiumcr/transliterator.git
+    version: 0.1.0+git.commit.46c4c14594057dbcfaf27e7e7c8c164d3f0ce3f1
 
   cry:
     git: https://github.com/luckyframework/cry.git
@@ -14,53 +18,57 @@ shards:
 
   db:
     git: https://github.com/crystal-lang/crystal-db.git
-    version: 0.10.1
+    version: 0.13.1
 
   dexter:
     git: https://github.com/luckyframework/dexter.git
-    version: 0.3.3
+    version: 0.3.4
 
   exception_page:
     git: https://github.com/crystal-loot/exception_page.git
-    version: 0.2.0
-
-  future:
-    git: https://github.com/crystal-community/future.cr.git
-    version: 1.0.0+git.commit.9fe168418c6884cb3552c13b004763eb4815ceb9
+    version: 0.4.1
 
   habitat:
     git: https://github.com/luckyframework/habitat.git
-    version: 0.4.7
+    version: 0.4.8
 
   lucky:
     git: https://github.com/luckyframework/lucky.git
-    version: 0.28.0
+    version: 1.2.0
+
+  lucky_cache:
+    git: https://github.com/luckyframework/lucky_cache.git
+    version: 0.1.1
 
   lucky_router:
     git: https://github.com/luckyframework/lucky_router.git
-    version: 0.5.0
+    version: 0.5.2
 
   lucky_task:
     git: https://github.com/luckyframework/lucky_task.git
-    version: 0.1.0
+    version: 0.3.0
+
+  lucky_template:
+    git: https://github.com/luckyframework/lucky_template.git
+    version: 0.2.0
 
   pg:
     git: https://github.com/will/crystal-pg.git
-    version: 0.24.0
+    version: 0.28.0
 
   pulsar:
     git: https://github.com/luckyframework/pulsar.git
-    version: 0.2.2
+    version: 0.2.3
 
   shell-table:
     git: https://github.com/luckyframework/shell-table.cr.git
-    version: 0.9.3+git.commit.fefbc8b19d18630660b2653de755217597808b1b
+    version: 0.9.3
 
-  teeplate:
-    git: https://github.com/luckyframework/teeplate.git
-    version: 0.8.3
+  splay_tree_map:
+    git: https://github.com/wyhaines/splay_tree_map.cr.git
+    version: 0.2.2
 
   wordsmith:
     git: https://github.com/luckyframework/wordsmith.git
-    version: 0.3.0
+    version: 0.4.0
 

Some files were not shown because too many files changed in this diff