From 01906d84432c85899f51fef3c1a7b37e9811e762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=88=80?= Date: Mon, 1 Feb 2021 23:39:09 +0800 Subject: [PATCH 01/31] update smart-http (#6332) * update smart-servlet to 0.1.3-SNAPSHOT * update aio-enhance to 1.0.3-SNAPSHOT * smart-servlet bugfix * bugfix --- frameworks/Java/smart-socket/pom.xml | 11 ++++ .../java/org/smartboot/http/Bootstrap.java | 55 +++++----------- .../java/org/smartboot/servlet/Bootstrap.java | 63 ++++++------------- 3 files changed, 47 insertions(+), 82 deletions(-) diff --git a/frameworks/Java/smart-socket/pom.xml b/frameworks/Java/smart-socket/pom.xml index 20fc84bbe4c..01427d6c7be 100644 --- a/frameworks/Java/smart-socket/pom.xml +++ b/frameworks/Java/smart-socket/pom.xml @@ -63,6 +63,17 @@ postgresql 42.2.5 + + + org.apache.velocity + velocity + 1.7 + + + oro + oro + 2.0.8 + diff --git a/frameworks/Java/smart-socket/src/main/java/org/smartboot/http/Bootstrap.java b/frameworks/Java/smart-socket/src/main/java/org/smartboot/http/Bootstrap.java index 0228cc4c811..2a75ca95108 100755 --- a/frameworks/Java/smart-socket/src/main/java/org/smartboot/http/Bootstrap.java +++ b/frameworks/Java/smart-socket/src/main/java/org/smartboot/http/Bootstrap.java @@ -12,16 +12,11 @@ import com.zaxxer.hikari.HikariDataSource; import org.smartboot.Message; import org.smartboot.aio.EnhanceAsynchronousChannelProvider; -import org.smartboot.http.server.HttpMessageProcessor; -import org.smartboot.http.server.HttpRequestProtocol; import org.smartboot.http.server.Request; import org.smartboot.http.server.handle.HttpHandle; import org.smartboot.http.server.handle.HttpRouteHandle; import org.smartboot.socket.StateMachineEnum; -import org.smartboot.socket.buffer.BufferFactory; -import org.smartboot.socket.buffer.BufferPagePool; import org.smartboot.socket.extension.processor.AbstractMessageProcessor; -import org.smartboot.socket.transport.AioQuickServer; import org.smartboot.socket.transport.AioSession; import javax.sql.DataSource; @@ -55,45 +50,25 @@ public void doHandle(HttpRequest request, HttpResponse response) throws IOExcept } }); initDB(routeHandle); - HttpMessageProcessor processor = new HttpMessageProcessor(); - processor.pipeline(routeHandle); - http(processor); - } - - public static void http(final HttpMessageProcessor processor) { - AbstractMessageProcessor messageProcessor = new AbstractMessageProcessor() { - @Override - public void process0(AioSession session, Request msg) { - processor.process(session, msg); - } - - @Override - public void stateEvent0(AioSession session, StateMachineEnum stateMachineEnum, Throwable throwable) { - processor.stateEvent(session, stateMachineEnum, throwable); - } - }; -// messageProcessor.addPlugin(new MonitorPlugin(5)); -// messageProcessor.addPlugin(new SocketOptionPlugin()); - int cpuNum = Runtime.getRuntime().availableProcessors(); // 定义服务器接受的消息类型以及各类消息对应的处理器 - AioQuickServer server = new AioQuickServer<>(8080, new HttpRequestProtocol(), messageProcessor); - server.setThreadNum(cpuNum + 2) + HttpBootstrap bootstrap = new HttpBootstrap(); + bootstrap.setPort(8080).setThreadNum(cpuNum + 2) .setReadBufferSize(1024 * 4) - .setBufferFactory(new BufferFactory() { + .setReadPageSize(16384 * 1024 * 4) + .setBufferPool(10 * 1024 * 1024, cpuNum + 2, 1024 * 4) + .pipeline(routeHandle) + .wrapProcessor(processor -> new AbstractMessageProcessor<>() { @Override - public BufferPagePool create() { - return new BufferPagePool(10 * 1024 * 1024, cpuNum + 2, 64 * 1024 * 1024, true); + public void process0(AioSession session, Request msg) { + processor.process(session, msg); } - }) - .setWriteBuffer(1024 * 4, 8); -// messageProcessor.addPlugin(new BufferPageMonitorPlugin(server, 6)); - try { - server.start(); - } catch (IOException e) { - e.printStackTrace(); - } + @Override + public void stateEvent0(AioSession session, StateMachineEnum stateMachineEnum, Throwable throwable) { + processor.stateEvent(session, stateMachineEnum, throwable); + } + }).start(); } private static void initDB(HttpRouteHandle routeHandle) { @@ -107,9 +82,13 @@ private static void initDB(HttpRouteHandle routeHandle) { config.setUsername("benchmarkdbuser"); config.setPassword("benchmarkdbpass"); config.setMaximumPoolSize(64); + config.addDataSourceProperty("cachePrepStmts", "true"); + config.addDataSourceProperty("prepStmtCacheSize", "250"); + config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); DataSource dataSource = new HikariDataSource(config); routeHandle.route("/db", new SingleQueryHandler(dataSource)) .route("/queries", new MultipleQueriesHandler(dataSource)) .route("/updates", new UpdateHandler(dataSource)); +// .route("/fortunes", new FortunesHandler(dataSource)); } } diff --git a/frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java b/frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java index 99098b0472d..2323c5c0396 100644 --- a/frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java +++ b/frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java @@ -1,19 +1,14 @@ package org.smartboot.servlet; import org.smartboot.aio.EnhanceAsynchronousChannelProvider; +import org.smartboot.http.HttpBootstrap; import org.smartboot.http.HttpRequest; import org.smartboot.http.HttpResponse; -import org.smartboot.http.server.HttpMessageProcessor; -import org.smartboot.http.server.HttpRequestProtocol; import org.smartboot.http.server.Request; import org.smartboot.http.server.handle.HttpHandle; import org.smartboot.servlet.conf.ServletInfo; import org.smartboot.socket.StateMachineEnum; -import org.smartboot.socket.buffer.BufferFactory; -import org.smartboot.socket.buffer.BufferPagePool; -import org.smartboot.socket.extension.plugins.MonitorPlugin; import org.smartboot.socket.extension.processor.AbstractMessageProcessor; -import org.smartboot.socket.transport.AioQuickServer; import org.smartboot.socket.transport.AioSession; import java.io.IOException; @@ -44,50 +39,30 @@ public static void main(String[] args) { applicationRuntime.getDeploymentInfo().addServlet(jsonServletInfo); containerRuntime.addRuntime(applicationRuntime); containerRuntime.start(); - HttpMessageProcessor processor = new HttpMessageProcessor(); - processor.pipeline(new HttpHandle() { - @Override - public void doHandle(HttpRequest request, HttpResponse response) throws IOException { - containerRuntime.doHandle(request, response); - } - }); - http(processor); - } - - public static void http(final HttpMessageProcessor processor) { - AbstractMessageProcessor messageProcessor = new AbstractMessageProcessor() { - @Override - public void process0(AioSession session, Request msg) { - processor.process(session, msg); - } - - @Override - public void stateEvent0(AioSession session, StateMachineEnum stateMachineEnum, Throwable throwable) { - processor.stateEvent(session, stateMachineEnum, throwable); - } - }; - messageProcessor.addPlugin(new MonitorPlugin(5)); -// messageProcessor.addPlugin(new SocketOptionPlugin()); - int cpuNum = Runtime.getRuntime().availableProcessors(); // 定义服务器接受的消息类型以及各类消息对应的处理器 - AioQuickServer server = new AioQuickServer<>(8080, new HttpRequestProtocol(), messageProcessor); - server.setThreadNum(cpuNum + 2) + HttpBootstrap bootstrap = new HttpBootstrap(); + bootstrap.setPort(8080).setThreadNum(cpuNum + 2) .setReadBufferSize(1024 * 4) - .setBufferFactory(new BufferFactory() { + .setReadPageSize(16384 * 1024 * 4) + .setBannerEnabled(false) + .setBufferPool(10 * 1024 * 1024, cpuNum + 2, 1024 * 4) + .pipeline(new HttpHandle() { @Override - public BufferPagePool create() { - return new BufferPagePool(10 * 1024 * 1024, cpuNum + 2, 64 * 1024 * 1024, true); + public void doHandle(HttpRequest request, HttpResponse response) throws IOException { + containerRuntime.doHandle(request, response); } }) - .setBannerEnabled(false) - .setWriteBuffer(1024 * 4, 8); + .wrapProcessor(processor -> new AbstractMessageProcessor<>() { + @Override + public void process0(AioSession session, Request msg) { + processor.process(session, msg); + } -// messageProcessor.addPlugin(new BufferPageMonitorPlugin(server, 6)); - try { - server.start(); - } catch (IOException e) { - e.printStackTrace(); - } + @Override + public void stateEvent0(AioSession session, StateMachineEnum stateMachineEnum, Throwable throwable) { + processor.stateEvent(session, stateMachineEnum, throwable); + } + }).start(); } } From 4bc23b52b5cca040b9d996f5b4c6696f749a5f13 Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 1 Feb 2021 16:39:36 +0100 Subject: [PATCH 02/31] [go/echo] update version of Go to 1.15 and Echo to v4.1.17 (#6331) --- frameworks/Go/echo/README.md | 2 +- frameworks/Go/echo/echo.dockerfile | 19 ++------- frameworks/Go/echo/src/glide.lock | 37 ------------------ frameworks/Go/echo/src/glide.yaml | 5 --- frameworks/Go/echo/src/go.mod | 8 ++++ frameworks/Go/echo/src/go.sum | 50 ++++++++++++++++++++++++ frameworks/Go/echo/src/{app => }/main.go | 2 +- 7 files changed, 64 insertions(+), 59 deletions(-) delete mode 100644 frameworks/Go/echo/src/glide.lock delete mode 100644 frameworks/Go/echo/src/glide.yaml create mode 100644 frameworks/Go/echo/src/go.mod create mode 100644 frameworks/Go/echo/src/go.sum rename frameworks/Go/echo/src/{app => }/main.go (99%) diff --git a/frameworks/Go/echo/README.md b/frameworks/Go/echo/README.md index 2abe6e244f8..b8831d0d0df 100644 --- a/frameworks/Go/echo/README.md +++ b/frameworks/Go/echo/README.md @@ -2,7 +2,7 @@ This is the go portion of a [benchmarking test suite](https://www.techempower.com/benchmarks/) comparing a variety of web development platforms. -> Echo is a fast and unfancy micro web framework for Go +> High performance, extensible, minimalist Go web framework ## Test URLs diff --git a/frameworks/Go/echo/echo.dockerfile b/frameworks/Go/echo/echo.dockerfile index 959b0a0f220..8d5b813981b 100644 --- a/frameworks/Go/echo/echo.dockerfile +++ b/frameworks/Go/echo/echo.dockerfile @@ -1,21 +1,10 @@ -FROM golang:1.14 +FROM golang:1.15 -ADD ./ /echo +ADD ./src /echo WORKDIR /echo -RUN mkdir bin -ENV GOPATH /echo -ENV PATH ${GOPATH}/bin:${PATH} - -RUN curl -sL -o install_glide.sh https://glide.sh/get -RUN sh install_glide.sh - -WORKDIR src -RUN glide install -WORKDIR .. - -RUN go install app +RUN go build -ldflags="-s -w" -o app ./main.go EXPOSE 8080 -CMD app \ No newline at end of file +CMD ./app diff --git a/frameworks/Go/echo/src/glide.lock b/frameworks/Go/echo/src/glide.lock deleted file mode 100644 index 341e1bf3746..00000000000 --- a/frameworks/Go/echo/src/glide.lock +++ /dev/null @@ -1,37 +0,0 @@ -hash: bc2963fa49e9b909be640418639463f2ef41016c159da6d025252e7ca8075528 -updated: 2016-12-30T10:45:43.942020764+09:00 -imports: -- name: github.com/labstack/echo - version: 8d504c1b699c757b267255c53b3e5219f9974abc -- name: github.com/labstack/gommon - version: 2d272df536d051e737aea353b86c979d6e88bce0 - subpackages: - - color - - log -- name: github.com/lib/pq - version: 5bf161122cd640c2a5a2c1d7fa49ea9befff31dd - subpackages: - - oid -- name: github.com/mattn/go-colorable - version: d228849504861217f796da67fae4f6e347643f15 -- name: github.com/mattn/go-isatty - version: 30a891c33c7cde7b02a981314b4228ec99380cca -- name: github.com/tylerb/graceful - version: 4df1190835320af7076dfcf27b3d071fd3612caf -- name: github.com/valyala/fasttemplate - version: 3b874956e03f1636d171bda64b130f9135f42cff -- name: golang.org/x/crypto - version: f6b343c37ca80bfa8ea539da67a0b621f84fab1d - subpackages: - - acme - - acme/autocert -- name: golang.org/x/net - version: 8fd7f25955530b92e73e9e1932a41b522b22ccd9 - subpackages: - - context - - context/ctxhttp -- name: golang.org/x/sys - version: d75a52659825e75fff6158388dddc6a5b04f9ba5 - subpackages: - - unix -testImports: [] diff --git a/frameworks/Go/echo/src/glide.yaml b/frameworks/Go/echo/src/glide.yaml deleted file mode 100644 index 0b7f5f4d618..00000000000 --- a/frameworks/Go/echo/src/glide.yaml +++ /dev/null @@ -1,5 +0,0 @@ -package: app -import: -- package: github.com/labstack/echo - version: v3.0.3 -- package: github.com/lib/pq diff --git a/frameworks/Go/echo/src/go.mod b/frameworks/Go/echo/src/go.mod new file mode 100644 index 00000000000..f1c8a0264c3 --- /dev/null +++ b/frameworks/Go/echo/src/go.mod @@ -0,0 +1,8 @@ +module echo/src + +go 1.15 + +require ( + github.com/labstack/echo/v4 v4.1.17 + github.com/lib/pq v1.9.0 +) diff --git a/frameworks/Go/echo/src/go.sum b/frameworks/Go/echo/src/go.sum new file mode 100644 index 00000000000..d8a63731474 --- /dev/null +++ b/frameworks/Go/echo/src/go.sum @@ -0,0 +1,50 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/labstack/echo/v4 v4.1.17 h1:PQIBaRplyRy3OjwILGkPg89JRtH2x5bssi59G2EL3fo= +github.com/labstack/echo/v4 v4.1.17/go.mod h1:Tn2yRQL/UclUalpb5rPdXDevbkJ+lp/2svdyFBg6CHQ= +github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= +github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= +github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8= +github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= +github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= +github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6 h1:DvY3Zkh7KabQE/kfzMvYvKirSiguP9Q/veMtkYyf0o8= +golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/frameworks/Go/echo/src/app/main.go b/frameworks/Go/echo/src/main.go similarity index 99% rename from frameworks/Go/echo/src/app/main.go rename to frameworks/Go/echo/src/main.go index 29953ce24b9..5285cd27d51 100644 --- a/frameworks/Go/echo/src/app/main.go +++ b/frameworks/Go/echo/src/main.go @@ -12,7 +12,7 @@ import ( "sort" "strconv" - "github.com/labstack/echo" + "github.com/labstack/echo/v4" _ "github.com/lib/pq" ) From 8c140b6e1638c985806ebd95a7192f32bef11fa3 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 1 Feb 2021 23:40:53 +0800 Subject: [PATCH 03/31] [c#/beetlex] update v1.6.5, use System.Text.Json (#6330) * update beetlex 1.4.3 update beetlex 1.4.3 * docker add COMPlus_ReadyToRun variable update beetlex * update beetlex, enabled thread queue * beetlex framework add db and queries cases * add db code * change result json data * update query url * beetlex framework add fortunes cases * change Content-Type * add beetlex core cases * fix queries cases * update config * change try readline * update benchmark config * Update README.md * Update README.md * change versus property * beetlex-core update .net core to v3.0 * change beetlex-core project file * beetlex update raw db class * beetlex update raw db * beetlex debug plaintext * change debug docker file * update beetlex to 1.4.0 * update * beetlex update core 3.1 * [c#/beetlex] add updates cases * [c#/beetlex] change Server: TFB, change custom connection pool, add update docker * fix errors * change pool init * change connection pool maxsize * fix fortunes errors * clear DBRaw _connectionString value. * [c#beetlex] change update dbconnection pool size * [c#/beetlex] udpate spanjson to v3.0.1, Npgsql v5.0.0 * [c#/beetlex] add caching sample * set connectionstring multiplexing * remove connection multiplexing setting * [c#/beetlex]change NpgsqlParameter to NpgsqlParameter * [c#/beetlex] update dbraw * [c#/beetlex] change connection string * [c#/beetlex] add fortunes cases to core-updb * update beetlex 1.5.6 * update 5.0.0-alpha1 * update docker file * Enabled IOQueues * Set IOQueues debug mode * update * [c#/beetlex] udpate to v1.6.0.1-beta * update pg drive * [c#/beetlex] update to beetlex v1.6.3 and support pipelining * set options * [c#/beetlex] Optimized actions * [c#/beetlex] update plaintext * Bump ServiceStack in /frameworks/CSharp/servicestack/src/SelfHost Bumps [ServiceStack](https://github.com/ServiceStack/ServiceStack) from 3.9.59 to 5.9.2. - [Release notes](https://github.com/ServiceStack/ServiceStack/releases) - [Commits](https://github.com/ServiceStack/ServiceStack/commits/v5.9.2) Signed-off-by: dependabot[bot] * [c#/beetlex] change plaintext buffer size, optimize fortunes. * [c#/beetlex] update v1.6.5,use System.Text.Json * change docker files * update beetlex 1.6.5.2 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../beetlex/PlatformBenchmarks/HttpToken.cs | 3 +++ .../PlatformBenchmarks.csproj | 2 +- .../CSharp/beetlex/PlatformBenchmarks/db.cs | 6 +++--- .../CSharp/beetlex/PlatformBenchmarks/json.cs | 19 +++++++++++++++---- .../beetlex/PlatformBenchmarks/queries.cs | 4 ++-- .../beetlex/PlatformBenchmarks/updates.cs | 4 ++-- .../beetlex/beetlex-core-updb.dockerfile | 2 +- .../CSharp/beetlex/beetlex-core.dockerfile | 2 +- .../CSharp/beetlex/beetlex-debug.dockerfile | 2 +- frameworks/CSharp/beetlex/beetlex.dockerfile | 2 +- 10 files changed, 30 insertions(+), 16 deletions(-) diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs index c927229d907..62f0bee1849 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/HttpToken.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Concurrent; using System.Text; +using System.Text.Json; namespace PlatformBenchmarks { @@ -22,6 +23,8 @@ public HttpToken() public ConcurrentQueue Requests { get; set; } = new ConcurrentQueue(); + public Utf8JsonWriter Utf8JsonWriter { get; set; } + public ISession Session { get; set; } public RequestData CurrentRequest { get; set; } diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj b/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj index 80b5deba38d..caedea04988 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj @@ -8,7 +8,7 @@ - + diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs index 8480f46775d..639fbd7d531 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs @@ -11,14 +11,14 @@ namespace PlatformBenchmarks public partial class HttpHandler { - public async Task db(PipeStream stream, HttpToken token, ISession session) + public async ValueTask db(PipeStream stream, HttpToken token, ISession session) { try { var data = await token.Db.LoadSingleQueryRow(); - await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream); + System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), data, SerializerOptions); } - catch(Exception e_) + catch (Exception e_) { HttpServer.ApiServer.Log(BeetleX.EventArgs.LogType.Error, null, $"db error {e_.Message}@{e_.StackTrace}"); stream.Write(e_.Message); diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs index fac4a2f9f89..14bbe43b9df 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs @@ -4,18 +4,29 @@ using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; using System.Threading.Tasks; namespace PlatformBenchmarks { public partial class HttpHandler { - public async Task Json(PipeStream stream, HttpToken token, ISession session) + private static readonly JsonSerializerOptions SerializerOptions = new JsonSerializerOptions(); + + private static Utf8JsonWriter GetUtf8JsonWriter(PipeStream stream, HttpToken token) { - JsonMessage jsonMessage = default(JsonMessage); - jsonMessage.message = "Hello, World!"; - await JsonSerializer.NonGeneric.Utf8.SerializeAsync(jsonMessage, stream); + var buffer = stream.CreateBufferWriter(); + var writer = token.Utf8JsonWriter ??= new Utf8JsonWriter(buffer, new JsonWriterOptions { SkipValidation = true }); + writer.Reset(buffer); + return writer; + } + + public ValueTask Json(PipeStream stream, HttpToken token, ISession session) + { + + System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), new JsonMessage { message = "Hello, World!" }, SerializerOptions); OnCompleted(stream, session, token); + return ValueTask.CompletedTask; } } } diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/queries.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/queries.cs index f34c359bb91..befe85d5932 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/queries.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/queries.cs @@ -10,7 +10,7 @@ namespace PlatformBenchmarks { public partial class HttpHandler { - public async Task queries(string queryString, PipeStream stream, HttpToken token, ISession session) + public async ValueTask queries(string queryString, PipeStream stream, HttpToken token, ISession session) { int count = 1; if(!string.IsNullOrEmpty(queryString)) @@ -31,7 +31,7 @@ public async Task queries(string queryString, PipeStream stream, HttpToken token try { var data = await token.Db.LoadMultipleQueriesRows(count); - await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream); + System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), data, SerializerOptions); } catch (Exception e_) { diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/updates.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/updates.cs index 4eb341501cf..4ddff6e53cf 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/updates.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/updates.cs @@ -10,7 +10,7 @@ namespace PlatformBenchmarks { public partial class HttpHandler { - public async Task updates(string queryString, PipeStream stream, HttpToken token, ISession session) + public async ValueTask updates(string queryString, PipeStream stream, HttpToken token, ISession session) { int count = 1; if (!string.IsNullOrEmpty(queryString)) @@ -31,7 +31,7 @@ public async Task updates(string queryString, PipeStream stream, HttpToken token try { var data = await token.Db.LoadMultipleUpdatesRows(count); - await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream); + System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), data, SerializerOptions); } catch (Exception e_) { diff --git a/frameworks/CSharp/beetlex/beetlex-core-updb.dockerfile b/frameworks/CSharp/beetlex/beetlex-core-updb.dockerfile index 303340675dc..b813173db92 100644 --- a/frameworks/CSharp/beetlex/beetlex-core-updb.dockerfile +++ b/frameworks/CSharp/beetlex/beetlex-core-updb.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build WORKDIR /app COPY PlatformBenchmarks . RUN dotnet publish -c Release -o out diff --git a/frameworks/CSharp/beetlex/beetlex-core.dockerfile b/frameworks/CSharp/beetlex/beetlex-core.dockerfile index ba40f9a5bee..84f4b69a3ff 100644 --- a/frameworks/CSharp/beetlex/beetlex-core.dockerfile +++ b/frameworks/CSharp/beetlex/beetlex-core.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build WORKDIR /app COPY PlatformBenchmarks . RUN dotnet publish -c Release -o out diff --git a/frameworks/CSharp/beetlex/beetlex-debug.dockerfile b/frameworks/CSharp/beetlex/beetlex-debug.dockerfile index a4820945ab4..ae68a278647 100644 --- a/frameworks/CSharp/beetlex/beetlex-debug.dockerfile +++ b/frameworks/CSharp/beetlex/beetlex-debug.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build WORKDIR /app COPY PlatformBenchmarks . RUN dotnet publish -c Release -o out diff --git a/frameworks/CSharp/beetlex/beetlex.dockerfile b/frameworks/CSharp/beetlex/beetlex.dockerfile index 0d4a95d5820..8540e376359 100644 --- a/frameworks/CSharp/beetlex/beetlex.dockerfile +++ b/frameworks/CSharp/beetlex/beetlex.dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build WORKDIR /app COPY Benchmarks . RUN dotnet publish -c Release -o out From efed13de296e6aab7254bf53ffed06edae6d5584 Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Mon, 1 Feb 2021 23:41:51 +0800 Subject: [PATCH 04/31] update redkale 2.3.0-snapshot (#6329) * update redkale 2.3.0-snapshot * update redkale 2.3.0-snapshot * update redkale 2.3.0-test * update redkale 2.3.0-snapshot * update redkale 2.3.0-snapshot * update redkale 2.3.0 snapshot * update redkale 2.3.0 --- frameworks/Java/redkale/benchmark_config.json | 26 +-- frameworks/Java/redkale/conf/application.xml | 17 +- frameworks/Java/redkale/conf/persistence.xml | 3 +- frameworks/Java/redkale/pom.xml | 197 ++++++++++-------- .../Java/redkale/redkale-postgres.dockerfile | 15 -- frameworks/Java/redkale/redkale.dockerfile | 7 +- frameworks/Java/redkale/setup.bat | 2 +- .../org/redkalex/benchmark/CachedWorld.java | 18 ++ .../java/org/redkalex/benchmark/Message.java | 4 +- .../java/org/redkalex/benchmark/Service.java | 52 +++-- 10 files changed, 186 insertions(+), 155 deletions(-) delete mode 100644 frameworks/Java/redkale/redkale-postgres.dockerfile create mode 100644 frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/CachedWorld.java diff --git a/frameworks/Java/redkale/benchmark_config.json b/frameworks/Java/redkale/benchmark_config.json index 1c98d194db1..17a1f93db68 100644 --- a/frameworks/Java/redkale/benchmark_config.json +++ b/frameworks/Java/redkale/benchmark_config.json @@ -4,27 +4,11 @@ "default": { "json_url": "/json", "plaintext_url": "/plaintext", - "port": 8080, - "approach": "Realistic", - "classification": "Fullstack", - "database": "None", - "framework": "Redkale", - "language": "Java", - "flavor": "None", - "orm": "Raw", - "platform": "Redkale", - "webserver": "None", - "os": "Linux", - "database_os": "Linux", - "display_name": "redkale", - "notes": "", - "versus": "" - }, - "postgres": { - "db_url": "/db", - "query_url": "/queries?queries=", - "fortune_url": "/fortunes", - "update_url": "/updates?queries=", + "db_url2": "/db", + "query_url2": "/queries?queries=", + "fortune_url2": "/fortunes", + "update_url2": "/updates?queries=", + "cached_query_url2": "/cached-worlds?count=", "port": 8080, "approach": "Realistic", "classification": "Fullstack", diff --git a/frameworks/Java/redkale/conf/application.xml b/frameworks/Java/redkale/conf/application.xml index 5c655377e8a..4bfbe72377f 100644 --- a/frameworks/Java/redkale/conf/application.xml +++ b/frameworks/Java/redkale/conf/application.xml @@ -5,24 +5,21 @@ - - - + + - + - - - + + + - - + - diff --git a/frameworks/Java/redkale/conf/persistence.xml b/frameworks/Java/redkale/conf/persistence.xml index afb88ce9091..16a8260f8ea 100644 --- a/frameworks/Java/redkale/conf/persistence.xml +++ b/frameworks/Java/redkale/conf/persistence.xml @@ -6,8 +6,7 @@ ALL - - + diff --git a/frameworks/Java/redkale/pom.xml b/frameworks/Java/redkale/pom.xml index a0c97d3cf33..37f32635d47 100644 --- a/frameworks/Java/redkale/pom.xml +++ b/frameworks/Java/redkale/pom.xml @@ -1,94 +1,123 @@ - 4.0.0 - org.redkalex - redkale-benchmark - 0.0.1 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + org.redkalex + redkale-benchmark + 1.0.0 - - - org.redkale.boot.Application - 0.0.1 + + + org.redkale.boot.Application + 1.0.0 UTF-8 11 11 - + - - - - org.redkale - redkale - 2.0.0.alpha1 - + + + org.redkale + redkale + 2.3.0-SNAPSHOT + + + + org.redkalex + redkale-plugins + 2.3.0-SNAPSHOT + + + + com.fizzed + rocker-compiler + 1.3.0 + + - - org.redkalex - redkale-plugins - 2.0.0.alpha1 - - - com.fizzed - rocker-compiler - 1.2.1 - - + + + central + Central Repository + https://repo.maven.apache.org/maven2 + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + + + + central + Central Repository + https://repo.maven.apache.org/maven2 + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.0 + + + com.fizzed + rocker-maven-plugin + 1.3.0 + + + generate-rocker-templates + generate-sources + + generate + + + 1.8 + ${basedir}/src/main/templates + ${basedir}/target/generated-sources/rocker + false + true + true + true + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.1 + + + package + + shade + + + + + ${main.class} + + + + + + + - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - false - - - - com.fizzed - rocker-maven-plugin - 1.2.1 - - - generate-rocker-templates - generate-sources - - generate - - - 11 - ${basedir}/src/main/templates - ${basedir}/target/generated-sources/rocker - false - true - true - true - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.1 - - - package - - shade - - - - - ${main.class} - - - - - - - - - + diff --git a/frameworks/Java/redkale/redkale-postgres.dockerfile b/frameworks/Java/redkale/redkale-postgres.dockerfile deleted file mode 100644 index f93b1b94afb..00000000000 --- a/frameworks/Java/redkale/redkale-postgres.dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM maven:3.6.1-jdk-11-slim as maven -WORKDIR /redkale -COPY src src -COPY conf conf -COPY pom.xml pom.xml -RUN mvn package -q - -FROM openjdk:12 -WORKDIR /redkale -COPY conf conf -COPY --from=maven /redkale/target/redkale-benchmark-0.0.1.jar redkale-benchmark.jar - -EXPOSE 8080 - -CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-DAPP_HOME=./", "-jar", "redkale-benchmark.jar"] diff --git a/frameworks/Java/redkale/redkale.dockerfile b/frameworks/Java/redkale/redkale.dockerfile index f93b1b94afb..718f6fabdfc 100644 --- a/frameworks/Java/redkale/redkale.dockerfile +++ b/frameworks/Java/redkale/redkale.dockerfile @@ -5,11 +5,8 @@ COPY conf conf COPY pom.xml pom.xml RUN mvn package -q -FROM openjdk:12 +FROM openjdk:11.0.3-jdk-slim WORKDIR /redkale COPY conf conf -COPY --from=maven /redkale/target/redkale-benchmark-0.0.1.jar redkale-benchmark.jar - -EXPOSE 8080 - +COPY --from=maven /redkale/target/redkale-benchmark-1.0.0.jar redkale-benchmark.jar CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-DAPP_HOME=./", "-jar", "redkale-benchmark.jar"] diff --git a/frameworks/Java/redkale/setup.bat b/frameworks/Java/redkale/setup.bat index 04787db4583..5565e6ec423 100644 --- a/frameworks/Java/redkale/setup.bat +++ b/frameworks/Java/redkale/setup.bat @@ -2,4 +2,4 @@ call mvn clean package -call java -DAPP_HOME=./ -jar target/redkale-benchmark-0.0.1.jar +call java -DAPP_HOME=./ -jar target/redkale-benchmark-1.0.0.jar diff --git a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/CachedWorld.java b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/CachedWorld.java new file mode 100644 index 00000000000..9d97dc72b41 --- /dev/null +++ b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/CachedWorld.java @@ -0,0 +1,18 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.redkalex.benchmark; + +import javax.persistence.*; + +/** + * + * @author zhangjx + */ +@Cacheable +@Table(name = "World") +public class CachedWorld extends World { + +} diff --git a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Message.java b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Message.java index c5c6989cc01..1eda186cfe5 100644 --- a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Message.java +++ b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Message.java @@ -5,14 +5,16 @@ */ package org.redkalex.benchmark; +import org.redkale.convert.ConvertSmallString; import org.redkale.convert.json.JsonConvert; /** * * @author zhangjx */ -public class Message { +public class Message { + @ConvertSmallString private String message; public Message() { diff --git a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java index f24aaefed3d..5db458488a7 100644 --- a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java +++ b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java @@ -5,13 +5,13 @@ */ package org.redkalex.benchmark; -import java.nio.ByteBuffer; import java.util.*; import java.util.concurrent.CompletableFuture; import javax.annotation.Resource; import org.redkale.net.http.*; import org.redkale.service.AbstractService; -import org.redkale.source.DataSource; +import org.redkale.source.*; +import org.redkale.util.AnyValue; /** * @@ -27,6 +27,11 @@ public class Service extends AbstractService { @Resource private DataSource source; + @Override + public void init(AnyValue conf) { + source.queryList(CachedWorld.class); + } + @RestMapping(name = "json") public Message getHelloMessage() { return new Message("Hello, World!"); @@ -43,25 +48,40 @@ public CompletableFuture findWorld() { } @RestMapping(name = "queries") - public World[] queryWorld(@RestParam(name = "queries") int count) { - count = Math.min(500, Math.max(1, count)); - final World[] rs = new World[count]; - for (int i = 0; i < count; i++) { - rs[i] = source.find(World.class, randomId()); + public CompletableFuture queryWorld(@RestParam(name = "queries") int count) { + final int size = Math.min(500, Math.max(1, count)); + final World[] worlds = new World[size]; + final CompletableFuture[] futures = new CompletableFuture[size]; + for (int i = 0; i < size; i++) { + final int index = i; + futures[index] = source.findAsync(World.class, randomId()).thenApply(r -> worlds[index] = r); + } + return CompletableFuture.allOf(futures).thenApply(v -> worlds); + } + + @RestMapping(name = "cached-worlds") + public CachedWorld[] cachedWorlds(@RestParam(name = "count") int count) { + final int size = Math.min(500, Math.max(1, count)); + final CachedWorld[] worlds = new CachedWorld[size]; + for (int i = 0; i < size; i++) { + worlds[i] = source.find(CachedWorld.class, randomId()); } - return rs; + return worlds; } @RestMapping(name = "updates") - public World[] updateWorld(@RestParam(name = "queries") int count) { - count = Math.min(500, Math.max(1, count)); - final World[] rs = new World[count]; - for (int i = 0; i < count; i++) { - rs[i] = source.find(World.class, randomId()); - rs[i].setRandomNumber(randomId()); + public CompletableFuture updateWorld(@RestParam(name = "queries") int count) { + final int size = Math.min(500, Math.max(1, count)); + final World[] worlds = new World[size]; + final CompletableFuture[] futures = new CompletableFuture[size]; + for (int i = 0; i < size; i++) { + final int index = i; + futures[index] = source.findAsync(World.class, randomId()).thenAccept((World r) -> { + r.setRandomNumber(randomId()); + worlds[index] = r; + }); } - source.update(rs); - return rs; + return CompletableFuture.allOf(futures).thenCompose(v -> source.updateAsync(worlds)).thenApply(v -> worlds); } @RestMapping(name = "fortunes") From e49486dde0623c2df1f4fabe2851ff51ec1caad1 Mon Sep 17 00:00:00 2001 From: Yaron Elyashiv <3446467+yaronel@users.noreply.github.com> Date: Mon, 1 Feb 2021 17:42:18 +0200 Subject: [PATCH 05/31] Upgrade to Donkey 0.4.1 (#6322) - Set accept backlog to 20,000 --- frameworks/Clojure/donkey/README.md | 2 +- frameworks/Clojure/donkey/benchmark_config.json | 6 +++--- frameworks/Clojure/donkey/config.toml | 4 ++-- frameworks/Clojure/donkey/project.clj | 2 +- frameworks/Clojure/donkey/src/hello/handler.clj | 17 +++++++++-------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/frameworks/Clojure/donkey/README.md b/frameworks/Clojure/donkey/README.md index b4268cb95a6..9c521cd74ff 100755 --- a/frameworks/Clojure/donkey/README.md +++ b/frameworks/Clojure/donkey/README.md @@ -11,7 +11,7 @@ Benchmark tests for Donkey - Ring compliant Clojure HTTP server The tests were run with: * [Donkey](https://github.com/AppsFlyer/donkey) * [Clojure 1.10.1](https://clojure.org/) -* [Vert.x Web 3.9.2](https://vertx.io/docs/vertx-web/java/) +* [Vert.x Web 4.0.0](https://vertx.io/docs/vertx-web/java/) ## Test URLs ### JSON diff --git a/frameworks/Clojure/donkey/benchmark_config.json b/frameworks/Clojure/donkey/benchmark_config.json index 1cb80fdb188..efc5a6570c2 100755 --- a/frameworks/Clojure/donkey/benchmark_config.json +++ b/frameworks/Clojure/donkey/benchmark_config.json @@ -9,17 +9,17 @@ "approach": "Realistic", "classification": "Micro", "database": "None", - "framework": "Donkey", + "framework": "donkey", "language": "Clojure", "flavor": "None", "orm": "None", - "platform": "Netty", + "platform": "Vert.x", "webserver": "None", "os": "Linux", "database_os": "Linux", "display_name": "Donkey", "notes": "", - "versus": "Vertx" + "versus": "vertx-web" } } ] diff --git a/frameworks/Clojure/donkey/config.toml b/frameworks/Clojure/donkey/config.toml index 4da31017ad8..763b4551d7b 100644 --- a/frameworks/Clojure/donkey/config.toml +++ b/frameworks/Clojure/donkey/config.toml @@ -10,6 +10,6 @@ database = "None" database_os = "Linux" os = "Linux" orm = "None" -platform = "Netty" +platform = "Vert.x" webserver = "None" -versus = "Vertx" +versus = "vertx-web" diff --git a/frameworks/Clojure/donkey/project.clj b/frameworks/Clojure/donkey/project.clj index 555460e351f..00dd3bd84e3 100644 --- a/frameworks/Clojure/donkey/project.clj +++ b/frameworks/Clojure/donkey/project.clj @@ -1,7 +1,7 @@ (defproject hello "donkey" :description "Donkey Server" :dependencies [[org.clojure/clojure "1.10.1"] - [com.appsflyer/donkey "0.1.0"]] + [com.appsflyer/donkey "0.4.1"]] :jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true"] :main hello.handler :aot :all) diff --git a/frameworks/Clojure/donkey/src/hello/handler.clj b/frameworks/Clojure/donkey/src/hello/handler.clj index 46b02573c36..69e57953f0a 100644 --- a/frameworks/Clojure/donkey/src/hello/handler.clj +++ b/frameworks/Clojure/donkey/src/hello/handler.clj @@ -35,12 +35,13 @@ (-> (donkey-core/create-donkey {:event-loops concurrency}) - (donkey-core/create-server {:port 8080 - :routes [hello-world-route json-route] - :instances concurrency - :compression false - :decompression false - :date-header true - :server-header true - :keep-alive true}) + (donkey-core/create-server {:port 8080 + :routes [hello-world-route json-route] + :instances concurrency + :compression false + :decompression false + :accept-backlog 20000 + :date-header true + :server-header true + :keep-alive true}) (donkey-server/start-sync)))) From 1b068fbd24129db48ef411c931f4eefaa63e8d23 Mon Sep 17 00:00:00 2001 From: Anton Kirilov Date: Mon, 1 Feb 2021 15:44:19 +0000 Subject: [PATCH 06/31] H2O: Switch the build system to Ninja (#6319) Also clean up the sources and fix a couple of minor issues. --- frameworks/C/h2o/README.md | 4 ++++ frameworks/C/h2o/h2o.dockerfile | 7 ++++--- frameworks/C/h2o/h2o.sh | 10 ++++----- frameworks/C/h2o/src/database.c | 4 ++++ frameworks/C/h2o/src/database.h | 1 - frameworks/C/h2o/src/error.h | 2 +- frameworks/C/h2o/src/event_loop.c | 4 ++-- frameworks/C/h2o/src/event_loop.h | 1 + frameworks/C/h2o/src/global_data.h | 1 + frameworks/C/h2o/src/handlers/fortune.c | 5 ++--- frameworks/C/h2o/src/handlers/world.c | 16 ++++++++------- frameworks/C/h2o/src/main.c | 2 ++ frameworks/C/h2o/src/thread.c | 4 +--- frameworks/C/h2o/src/thread.h | 3 +-- frameworks/C/h2o/src/utility.c | 27 ++++++++++++------------- frameworks/C/h2o/src/utility.h | 6 ++++-- 16 files changed, 53 insertions(+), 44 deletions(-) diff --git a/frameworks/C/h2o/README.md b/frameworks/C/h2o/README.md index 830216f2a8d..8183ac6ecc0 100644 --- a/frameworks/C/h2o/README.md +++ b/frameworks/C/h2o/README.md @@ -6,6 +6,10 @@ This is a framework implementation using the [H2O](https://h2o.examp1e.net) HTTP [CMake](https://cmake.org), [H2O](https://h2o.examp1e.net), [libpq](https://www.postgresql.org), [mustache-c](https://github.com/x86-64/mustache-c), [OpenSSL](https://www.openssl.org), [YAJL](https://lloyd.github.io/yajl) +## Test implementations + +The test implementations are located into the `src/handlers` directory. + ## Performance tuning If the test environment changes, it will probably be necessary to tune some of the framework settings in order to achieve the best performance possible. The most significant parameter is the maximum number of database connections per thread, which is controlled by the `DB_CONN` variable in the `h2o.sh` script. diff --git a/frameworks/C/h2o/h2o.dockerfile b/frameworks/C/h2o/h2o.dockerfile index 149b26d44e9..4a710f82ac8 100644 --- a/frameworks/C/h2o/h2o.dockerfile +++ b/frameworks/C/h2o/h2o.dockerfile @@ -6,7 +6,7 @@ COPY ./ ./ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && \ apt-get install -yqq autoconf bison cmake curl file flex g++ git libnuma-dev libpq-dev \ - libssl-dev libtool libyajl-dev libz-dev make wget + libssl-dev libtool libyajl-dev libz-dev make ninja-build wget ### Install mustache-c @@ -37,8 +37,9 @@ RUN mkdir -p "${H2O_BUILD_DIR}/build" && \ tar xz --strip-components=1 && \ cd build && \ cmake -DCMAKE_INSTALL_PREFIX="$H2O_PREFIX" -DCMAKE_C_FLAGS="-flto -march=native" \ - -DCMAKE_AR=/usr/bin/gcc-ar -DCMAKE_RANLIB=/usr/bin/gcc-ranlib .. && \ - make -j "$(nproc)" install && \ + -DCMAKE_AR=/usr/bin/gcc-ar -DCMAKE_RANLIB=/usr/bin/gcc-ranlib -G Ninja .. && \ + cmake --build . -j && \ + cmake --install . && \ cd ../.. && \ rm -rf "$H2O_BUILD_DIR" diff --git a/frameworks/C/h2o/h2o.sh b/frameworks/C/h2o/h2o.sh index 58a1554884d..3187419cf4e 100755 --- a/frameworks/C/h2o/h2o.sh +++ b/frameworks/C/h2o/h2o.sh @@ -2,7 +2,6 @@ set -e -CPU_COUNT=$(nproc) H2O_APP_PROFILE_PORT=54321 H2O_APP_PROFILE_URL="http://127.0.0.1:$H2O_APP_PROFILE_PORT" SCRIPT_PATH=$(realpath "$0") @@ -26,7 +25,7 @@ if [[ -z "$MUSTACHE_C_PREFIX" ]]; then fi # A hacky way to detect whether we are running in the physical hardware or the cloud environment. -if [[ "$CPU_COUNT" -gt 16 ]]; then +if [[ $(nproc) -gt 16 ]]; then echo "Running h2o_app in the physical hardware environment." DB_CONN=5 else @@ -38,8 +37,8 @@ build_h2o_app() { cmake -DCMAKE_INSTALL_PREFIX="$H2O_APP_PREFIX" -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH="${H2O_PREFIX};${MUSTACHE_C_PREFIX}" \ - -DCMAKE_C_FLAGS="-march=native $1" "$H2O_APP_SRC_ROOT" - make -j "$CPU_COUNT" + -DCMAKE_C_FLAGS="-march=native $1" -G Ninja "$H2O_APP_SRC_ROOT" + cmake --build . --clean-first -j } run_curl() @@ -77,10 +76,9 @@ install -d "$H2O_APP_BUILD_DIR" pushd "$H2O_APP_BUILD_DIR" build_h2o_app "-fprofile-generate" generate_profile_data -make clean rm -f CMakeCache.txt build_h2o_app "-fprofile-use" -make -j "$CPU_COUNT" install +cmake --install . popd rm -rf "$H2O_APP_BUILD_DIR" echo "Maximum database connections per thread: $DB_CONN" diff --git a/frameworks/C/h2o/src/database.c b/frameworks/C/h2o/src/database.c index 8227cd7363c..b8df1780112 100644 --- a/frameworks/C/h2o/src/database.c +++ b/frameworks/C/h2o/src/database.c @@ -17,11 +17,15 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include #include #include #include +#include +#include #include #include +#include #include #include "database.h" diff --git a/frameworks/C/h2o/src/database.h b/frameworks/C/h2o/src/database.h index 2e8ac4da651..1f9e98cc012 100644 --- a/frameworks/C/h2o/src/database.h +++ b/frameworks/C/h2o/src/database.h @@ -22,7 +22,6 @@ #define DATABASE_H_ #include -#include #include #include diff --git a/frameworks/C/h2o/src/error.h b/frameworks/C/h2o/src/error.h index a535d5c18b0..82b8c1ff36c 100644 --- a/frameworks/C/h2o/src/error.h +++ b/frameworks/C/h2o/src/error.h @@ -22,7 +22,7 @@ #define ERROR_H_ #include -#include +#include #include #define CHECK_ERRNO(function, ...) \ diff --git a/frameworks/C/h2o/src/event_loop.c b/frameworks/C/h2o/src/event_loop.c index ff4b5dbf7bc..60aac0ffb5b 100644 --- a/frameworks/C/h2o/src/event_loop.c +++ b/frameworks/C/h2o/src/event_loop.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -39,7 +38,6 @@ #include "event_loop.h" #include "global_data.h" #include "thread.h" -#include "utility.h" #define DEFAULT_TCP_FASTOPEN_QUEUE_LEN 4096 @@ -66,6 +64,8 @@ static void accept_connection(h2o_socket_t *listener, const char *err) if (!ctx->shutdown) { size_t accepted = ctx->config->max_accept; + assert(accepted); + do { h2o_socket_t * const sock = h2o_evloop_socket_accept(listener); diff --git a/frameworks/C/h2o/src/event_loop.h b/frameworks/C/h2o/src/event_loop.h index 1c73857696a..64ee8b0bf76 100644 --- a/frameworks/C/h2o/src/event_loop.h +++ b/frameworks/C/h2o/src/event_loop.h @@ -23,6 +23,7 @@ #include #include +#include #include "global_data.h" diff --git a/frameworks/C/h2o/src/global_data.h b/frameworks/C/h2o/src/global_data.h index 8b7b2a3be1f..9449e430886 100644 --- a/frameworks/C/h2o/src/global_data.h +++ b/frameworks/C/h2o/src/global_data.h @@ -22,6 +22,7 @@ #define GLOBAL_DATA_H_ #include +#include #include #include diff --git a/frameworks/C/h2o/src/handlers/fortune.c b/frameworks/C/h2o/src/handlers/fortune.c index db556d9d157..8ddb4b1200b 100644 --- a/frameworks/C/h2o/src/handlers/fortune.c +++ b/frameworks/C/h2o/src/handlers/fortune.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -39,9 +38,9 @@ #include "thread.h" #include "utility.h" -#define ID_FIELD_NAME "id" #define FORTUNE_TABLE_NAME "Fortune" #define FORTUNE_QUERY "SELECT * FROM " FORTUNE_TABLE_NAME ";" +#define ID_FIELD_NAME "id" #define MAX_IOVEC 64 #define MESSAGE_FIELD_NAME "message" #define NEW_FORTUNE_ID "0" @@ -438,7 +437,7 @@ void initialize_fortunes_handler(const config_t *config, h2o_access_log_filehandle_t *log_handle) { mustache_template_t *template = NULL; - const size_t template_path_prefix_len = strlen(config->template_path); + const size_t template_path_prefix_len = config->template_path ? strlen(config->template_path) : 0; char path[template_path_prefix_len + sizeof(TEMPLATE_PATH_SUFFIX)]; memcpy(path, config->template_path, template_path_prefix_len); diff --git a/frameworks/C/h2o/src/handlers/world.c b/frameworks/C/h2o/src/handlers/world.c index 30f8c049653..6f39ce94c74 100644 --- a/frameworks/C/h2o/src/handlers/world.c +++ b/frameworks/C/h2o/src/handlers/world.c @@ -20,11 +20,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -48,6 +50,8 @@ #define IS_COMPLETED 8 #define MAX_ID 10000 #define MAX_QUERIES 500 +#define WORLD_TABLE_NAME "World" +#define POPULATE_CACHE_QUERY "SELECT * FROM " WORLD_TABLE_NAME ";" #define QUERIES_PARAMETER "queries=" #define RANDOM_NUM_KEY "randomNumber" @@ -66,18 +70,11 @@ 2 * (sizeof(MKSTR(MAX_ID)) - 1) - 2 * (sizeof(PRIu32) - 1) - 2)) #define USE_CACHE 2 -#define WORLD_TABLE_NAME "World" -#define POPULATE_CACHE_QUERY "SELECT * FROM " WORLD_TABLE_NAME ";" #define WORLD_QUERY "SELECT * FROM " WORLD_TABLE_NAME " WHERE id = $1::integer;" typedef struct multiple_query_ctx_t multiple_query_ctx_t; typedef struct update_ctx_t update_ctx_t; -typedef struct { - uint32_t id; - uint32_t random_number; -} query_result_t; - typedef struct { thread_context_t *ctx; db_query_param_t param; @@ -92,6 +89,11 @@ typedef struct { db_query_param_t param; } query_param_t; +typedef struct { + uint32_t id; + uint32_t random_number; +} query_result_t; + typedef struct { const char *id_pointer; h2o_req_t *req; diff --git a/frameworks/C/h2o/src/main.c b/frameworks/C/h2o/src/main.c index 5cb2ac87161..0a99ed5f27b 100644 --- a/frameworks/C/h2o/src/main.c +++ b/frameworks/C/h2o/src/main.c @@ -30,9 +30,11 @@ #include #include +#include "database.h" #include "error.h" #include "event_loop.h" #include "global_data.h" +#include "list.h" #include "request_handler.h" #include "thread.h" #include "tls.h" diff --git a/frameworks/C/h2o/src/thread.c b/frameworks/C/h2o/src/thread.c index 11b0b9f8121..81a8ab1549f 100644 --- a/frameworks/C/h2o/src/thread.c +++ b/frameworks/C/h2o/src/thread.c @@ -19,11 +19,11 @@ #define _GNU_SOURCE -#include #include #include #include #include +#include #include #include #include @@ -37,8 +37,6 @@ #include "global_data.h" #include "request_handler.h" #include "thread.h" -#include "tls.h" -#include "utility.h" static void *run_thread(void *arg); static void set_thread_memory_allocation_policy(size_t thread_num); diff --git a/frameworks/C/h2o/src/thread.h b/frameworks/C/h2o/src/thread.h index baa55de73d7..8ecb9879ad9 100644 --- a/frameworks/C/h2o/src/thread.h +++ b/frameworks/C/h2o/src/thread.h @@ -21,15 +21,14 @@ #define THREAD_H_ -#include #include #include #include -#include #include "database.h" #include "event_loop.h" #include "global_data.h" +#include "list.h" #include "handlers/request_handler_data.h" typedef struct thread_context_t thread_context_t; diff --git a/frameworks/C/h2o/src/utility.c b/frameworks/C/h2o/src/utility.c index 33c798b7b65..4d9d0761f07 100644 --- a/frameworks/C/h2o/src/utility.c +++ b/frameworks/C/h2o/src/utility.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -226,6 +225,19 @@ bool is_power_of_2(size_t x) return !!x & !(x & (x - 1)); } +size_t round_up_to_power_of_2(size_t x) +{ + static_assert(sizeof(size_t) == sizeof(unsigned long), + "The size_t type must have the same size as unsigned long."); + + size_t ret = (SIZE_MAX ^ SIZE_MAX >> 1) >> __builtin_clzl(x); + + if (x - ret) + ret <<= 1; + + return ret; +} + // merge sort list_t *sort_list(list_t *head, int (*compare)(const list_t *, const list_t *)) { @@ -256,16 +268,3 @@ list_t *sort_list(list_t *head, int (*compare)(const list_t *, const list_t *)) return head; } - -size_t round_up_to_power_of_2(size_t x) -{ - static_assert(sizeof(size_t) == sizeof(unsigned long), - "The size_t type must have the same size as unsigned long."); - - size_t ret = (SIZE_MAX ^ SIZE_MAX >> 1) >> __builtin_clzl(x); - - if (x - ret) - ret <<= 1; - - return ret; -} diff --git a/frameworks/C/h2o/src/utility.h b/frameworks/C/h2o/src/utility.h index 36b7bf178f0..b98986bfcea 100644 --- a/frameworks/C/h2o/src/utility.h +++ b/frameworks/C/h2o/src/utility.h @@ -28,14 +28,16 @@ #include "list.h" +// Note that the parameter must be an actual array, and not an array that has decayed into a +// pointer, for example. #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) // mainly used to silence compiler warnings about unused function parameters #define IGNORE_FUNCTION_PARAMETER(p) ((void) (p)) // Do not use the following MAX and MIN macros with parameters that have side effects. #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) -#define MKSTR(x) TOSTRING(x) #define TOSTRING(x) # x +#define MKSTR(x) TOSTRING(x) #define YAJL_STRLIT(s) (const unsigned char *) (s), sizeof(s) - 1 typedef struct { @@ -49,8 +51,8 @@ json_generator_t *get_json_generator(list_t **pool, size_t *gen_num); size_t get_maximum_cache_line_size(void); uint32_t get_random_number(uint32_t max_rand, unsigned int *seed); bool is_power_of_2(size_t x); +size_t round_up_to_power_of_2(size_t x); // stable sort list_t *sort_list(list_t *head, int (*compare)(const list_t *, const list_t *)); -size_t round_up_to_power_of_2(size_t x); #endif // UTILITY_H_ From c108ec9ac75a5082b3c7be412a6d507e39364cdd Mon Sep 17 00:00:00 2001 From: vic <1018595261@qq.com> Date: Mon, 1 Feb 2021 23:45:30 +0800 Subject: [PATCH 07/31] [one] add ext bcmath (#6299) * Update IndexController.php * bcmath * Update one.dockerfile --- frameworks/PHP/one/one.dockerfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frameworks/PHP/one/one.dockerfile b/frameworks/PHP/one/one.dockerfile index 856bc7e5713..4bd510f1d6a 100644 --- a/frameworks/PHP/one/one.dockerfile +++ b/frameworks/PHP/one/one.dockerfile @@ -3,13 +3,20 @@ FROM php:8.0-cli RUN pecl install swoole > /dev/null && \ docker-php-ext-enable swoole -RUN docker-php-ext-install opcache pdo_mysql > /dev/null +RUN docker-php-ext-install opcache pdo_mysql bcmath > /dev/null RUN apt -yqq update > /dev/null && \ apt -yqq install git unzip > /dev/null COPY . /one COPY php.ini /usr/local/etc/php/ +RUN echo "opcache.enable=1" >> /usr/local/etc/php/php.ini +RUN echo "opcache.enable_cli=1" >> /usr/local/etc/php/php.ini +RUN echo "pcre.jit=1" >> /usr/local/etc/php/php.ini +RUN echo "opcache.jit=1205" >> /usr/local/etc/php/php.ini +RUN echo "opcache.jit_buffer_size=256M" >> /usr/local/etc/php/php.ini + +RUN php -v && php -i | grep opcache WORKDIR /one @@ -22,4 +29,4 @@ RUN chmod -R 777 /one/App/RunCache EXPOSE 8080 -CMD php App/swoole.php \ No newline at end of file +CMD php App/swoole.php From 5f6ae8e05403d0c5b074336fd5c6138fd9c7c89f Mon Sep 17 00:00:00 2001 From: peterliu <2202055828@qq.com> Date: Mon, 1 Feb 2021 23:46:49 +0800 Subject: [PATCH 08/31] Add Mark (#6320) --- frameworks/PHP/mark/README.md | 23 +++++++++++++ frameworks/PHP/mark/benchmark_config.json | 23 +++++++++++++ frameworks/PHP/mark/composer.json | 5 +++ frameworks/PHP/mark/config.toml | 15 +++++++++ frameworks/PHP/mark/mark.dockerfile | 24 +++++++++++++ frameworks/PHP/mark/php.ini | 13 +++++++ frameworks/PHP/mark/start.php | 41 +++++++++++++++++++++++ 7 files changed, 144 insertions(+) create mode 100644 frameworks/PHP/mark/README.md create mode 100644 frameworks/PHP/mark/benchmark_config.json create mode 100644 frameworks/PHP/mark/composer.json create mode 100644 frameworks/PHP/mark/config.toml create mode 100644 frameworks/PHP/mark/mark.dockerfile create mode 100644 frameworks/PHP/mark/php.ini create mode 100644 frameworks/PHP/mark/start.php diff --git a/frameworks/PHP/mark/README.md b/frameworks/PHP/mark/README.md new file mode 100644 index 00000000000..828f330bcb0 --- /dev/null +++ b/frameworks/PHP/mark/README.md @@ -0,0 +1,23 @@ +# Mark Benchmarking Test + +[Mark](https://github.com/passwalls/mark) is a high performance micro framework based on [Workerman](https://github.com/walkor/workerman) helps you quickly write APIs with php. + + +## Infrastructure Software Versions +The tests were run with: + +* [Mark](https://github.com/passwalls/mark) +* [PHP-CLI](http://www.php.net/) + + +### JSON Encoding Test +Using the PHP standard [JSON encoder](http://www.php.net/manual/en/function.json-encode.php) + +## Test URLs + +### JSON Encoding Test +http://localhost:8080/json + +### Plain text +http://localhost:8080/plaintext + diff --git a/frameworks/PHP/mark/benchmark_config.json b/frameworks/PHP/mark/benchmark_config.json new file mode 100644 index 00000000000..360f07f8967 --- /dev/null +++ b/frameworks/PHP/mark/benchmark_config.json @@ -0,0 +1,23 @@ +{ + "framework": "mark", + "tests": [{ + "default": { + "json_url": "/json", + "plaintext_url": "/plaintext", + "port": 8080, + "approach": "Realistic", + "classification": "Micro", + "framework": "mark", + "language": "PHP", + "flavor": "PHP8", + "orm": "Raw", + "platform": "workerman", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "mark-php8-jit", + "notes": "", + "versus": "workerman" + } + }] +} diff --git a/frameworks/PHP/mark/composer.json b/frameworks/PHP/mark/composer.json new file mode 100644 index 00000000000..23ee27b2d05 --- /dev/null +++ b/frameworks/PHP/mark/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "mark-php/mark": "^1.1" + } +} diff --git a/frameworks/PHP/mark/config.toml b/frameworks/PHP/mark/config.toml new file mode 100644 index 00000000000..5a0b63ec695 --- /dev/null +++ b/frameworks/PHP/mark/config.toml @@ -0,0 +1,15 @@ +[framework] +name = "mark" + +[main] +urls.plaintext = "/plaintext" +urls.json = "/json" +approach = "Realistic" +classification = "Micro" +database = "Postgres" +database_os = "Linux" +os = "Linux" +orm = "Raw" +platform = "workerman" +webserver = "None" +versus = "workerman" \ No newline at end of file diff --git a/frameworks/PHP/mark/mark.dockerfile b/frameworks/PHP/mark/mark.dockerfile new file mode 100644 index 00000000000..60d5f641d86 --- /dev/null +++ b/frameworks/PHP/mark/mark.dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:20.10 + +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null +RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php +RUN apt-get update -yqq > /dev/null && \ + apt-get install -yqq php8.0-cli php8.0-pgsql php8.0-xml > /dev/null + +RUN apt-get install -yqq composer > /dev/null + +RUN apt-get install -y php-pear php8.0-dev libevent-dev > /dev/null +RUN pecl install event-3.0.2 > /dev/null && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini + +COPY php.ini /etc/php/8.0/cli/php.ini + +ADD ./ /mark +WORKDIR /mark + +RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet + +EXPOSE 8080 + +CMD php /mark/start.php start diff --git a/frameworks/PHP/mark/php.ini b/frameworks/PHP/mark/php.ini new file mode 100644 index 00000000000..f0c616f9fb2 --- /dev/null +++ b/frameworks/PHP/mark/php.ini @@ -0,0 +1,13 @@ +opcache.enable=1 +opcache.enable_cli=1 +opcache.validate_timestamps=0 +opcache.save_comments=0 +opcache.enable_file_override=1 +opcache.huge_code_pages=1 + +mysqlnd.collect_statistics = Off + +memory_limit = 512M + +opcache.jit_buffer_size=128M +opcache.jit=tracing diff --git a/frameworks/PHP/mark/start.php b/frameworks/PHP/mark/start.php new file mode 100644 index 00000000000..e495edffe0c --- /dev/null +++ b/frameworks/PHP/mark/start.php @@ -0,0 +1,41 @@ +count = (int) shell_exec('nproc'); + +$api->any('/plaintext', function () { + global $date; + return new Response(200, [ + 'Content-Type' => 'text/plain', + 'Date' => $date + ], 'Hello, World!'); +}); + +$api->get('/json', function () { + global $date; + return new Response(200, [ + 'Content-Type' => 'application/json', + 'Date' => $date + ], \json_encode(['message' => 'Hello, World!'])); +}); + +$date = gmdate('D, d M Y H:i:s').' GMT'; + +$api->onWorkerStart = function () { + Timer::add(1, function () { + global $date; + $date = gmdate('D, d M Y H:i:s').' GMT'; + }); +}; + +$api->reusePort = true; + +$api->start(); + + From 7a3168840962e8751dc341147f9f537c93c49a58 Mon Sep 17 00:00:00 2001 From: luyongshou Date: Mon, 1 Feb 2021 23:47:05 +0800 Subject: [PATCH 09/31] edit edap-http config (#6270) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 初始化edap-http-benchmark的项目 * 修改pom文件以及测试的配置 * 修改端口号,jdk版本以及去掉有问题的plaintext的测试项 * 修改Message启动时初始化为每次请求生成新的对象 * 去掉多余的"s"字符 * 增加plaintext的测试配置 * add edap-http framwork * cache plaintext's content. * add edap-http-fast * 解决docker构建文件编写错误 * 修改测试框架配置 * 增加dockerfile暴露端口的设置 Co-authored-by: louis --- frameworks/Java/edap-http/benchmark_config.json | 2 +- frameworks/Java/edap-http/edap-http-fast.dockerfile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/Java/edap-http/benchmark_config.json b/frameworks/Java/edap-http/benchmark_config.json index d4150c96fe1..b82b5c11521 100755 --- a/frameworks/Java/edap-http/benchmark_config.json +++ b/frameworks/Java/edap-http/benchmark_config.json @@ -21,7 +21,7 @@ "notes": "", "versus": "edap-http" }, - "http-fast":{ + "fast":{ "plaintext_url": "/plaintext", "json_url": "/json", "port": 8080, diff --git a/frameworks/Java/edap-http/edap-http-fast.dockerfile b/frameworks/Java/edap-http/edap-http-fast.dockerfile index fe838aae941..4142e4f5785 100644 --- a/frameworks/Java/edap-http/edap-http-fast.dockerfile +++ b/frameworks/Java/edap-http/edap-http-fast.dockerfile @@ -1,11 +1,11 @@ FROM maven:3.6.3-openjdk-8-slim as maven -WORKDIR /edap-http-fast +WORKDIR /edap-http COPY pom.xml pom.xml COPY src src RUN mvn compile assembly:single -q FROM openjdk:8u275-jdk-slim -WORKDIR /edap-http-fast +WORKDIR /edap-http COPY --from=maven /edap-http/target/edap-http-benchmark-1.0-SNAPSHOT-jar-with-dependencies.jar app.jar EXPOSE 8080 From a5fe5be0d7dbf2cb7bd737df331f545427d74276 Mon Sep 17 00:00:00 2001 From: Biao Xie Date: Mon, 1 Feb 2021 23:47:52 +0800 Subject: [PATCH 10/31] [laravel-s]Made some optimizations (#6324) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * unify port * optimize composer Co-authored-by: 谢彪 --- frameworks/PHP/laravel/benchmark_config.json | 2 +- .../deploy/laravel-s/install-composer.sh | 17 ----------------- .../PHP/laravel/laravel-laravel-s.dockerfile | 14 ++++++++------ frameworks/PHP/lumen/benchmark_config.json | 2 +- .../lumen/deploy/laravel-s/install-composer.sh | 17 ----------------- frameworks/PHP/lumen/lumen-laravel-s.dockerfile | 14 ++++++++------ 6 files changed, 18 insertions(+), 48 deletions(-) delete mode 100644 frameworks/PHP/laravel/deploy/laravel-s/install-composer.sh delete mode 100644 frameworks/PHP/lumen/deploy/laravel-s/install-composer.sh diff --git a/frameworks/PHP/laravel/benchmark_config.json b/frameworks/PHP/laravel/benchmark_config.json index 0f5b6d0d950..bd822aabd60 100644 --- a/frameworks/PHP/laravel/benchmark_config.json +++ b/frameworks/PHP/laravel/benchmark_config.json @@ -54,7 +54,7 @@ "fortune_url": "/fortunes", "update_url": "/updates/", "plaintext_url": "/plaintext", - "port": 5200, + "port": 8080, "approach": "Realistic", "classification": "Fullstack", "database": "MySQL", diff --git a/frameworks/PHP/laravel/deploy/laravel-s/install-composer.sh b/frameworks/PHP/laravel/deploy/laravel-s/install-composer.sh deleted file mode 100644 index f8e743d6a13..00000000000 --- a/frameworks/PHP/laravel/deploy/laravel-s/install-composer.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)" -php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" -ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")" - -if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] -then - >&2 echo 'ERROR: Invalid installer signature' - rm composer-setup.php - exit 1 -fi - -php composer-setup.php --quiet -RESULT=$? -rm composer-setup.php -exit $RESULT \ No newline at end of file diff --git a/frameworks/PHP/laravel/laravel-laravel-s.dockerfile b/frameworks/PHP/laravel/laravel-laravel-s.dockerfile index 32325c2fff3..bd117766b80 100644 --- a/frameworks/PHP/laravel/laravel-laravel-s.dockerfile +++ b/frameworks/PHP/laravel/laravel-laravel-s.dockerfile @@ -14,18 +14,20 @@ WORKDIR /laravel RUN mkdir -p /laravel/bootstrap/cache /laravel/storage/logs /laravel/storage/framework/sessions /laravel/storage/framework/views /laravel/storage/framework/cache RUN chmod -R 777 /laravel -RUN deploy/swoole/install-composer.sh RUN apt-get update > /dev/null && \ apt-get install -yqq git unzip > /dev/null -COPY deploy/laravel-s/composer* ./ +RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" && php composer-setup.php && php -r "unlink('composer-setup.php');" +RUN mv composer.phar /usr/local/bin/composer + +COPY deploy/laravel-s/composer.json ./ RUN echo "LARAVELS_LISTEN_IP=0.0.0.0" >> .env -RUN echo "LARAVELS_LISTEN_PORT=5200" >> .env +RUN echo "LARAVELS_LISTEN_PORT=8080" >> .env -RUN php composer.phar install -a --no-dev --quiet +RUN composer install -a --no-dev --quiet RUN php artisan optimize RUN php artisan laravels publish -EXPOSE 5200 +EXPOSE 8080 -CMD bin/laravels start +CMD php bin/laravels start diff --git a/frameworks/PHP/lumen/benchmark_config.json b/frameworks/PHP/lumen/benchmark_config.json index 1c52ab34a3c..dbe7d771dd7 100644 --- a/frameworks/PHP/lumen/benchmark_config.json +++ b/frameworks/PHP/lumen/benchmark_config.json @@ -54,7 +54,7 @@ "fortune_url": "/fortunes", "update_url": "/updates/", "plaintext_url": "/plaintext", - "port": 5200, + "port": 8080, "approach": "Realistic", "classification": "Micro", "database": "MySQL", diff --git a/frameworks/PHP/lumen/deploy/laravel-s/install-composer.sh b/frameworks/PHP/lumen/deploy/laravel-s/install-composer.sh deleted file mode 100644 index f8e743d6a13..00000000000 --- a/frameworks/PHP/lumen/deploy/laravel-s/install-composer.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)" -php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" -ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")" - -if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ] -then - >&2 echo 'ERROR: Invalid installer signature' - rm composer-setup.php - exit 1 -fi - -php composer-setup.php --quiet -RESULT=$? -rm composer-setup.php -exit $RESULT \ No newline at end of file diff --git a/frameworks/PHP/lumen/lumen-laravel-s.dockerfile b/frameworks/PHP/lumen/lumen-laravel-s.dockerfile index e30883a2e0a..cce84db5a4d 100644 --- a/frameworks/PHP/lumen/lumen-laravel-s.dockerfile +++ b/frameworks/PHP/lumen/lumen-laravel-s.dockerfile @@ -14,17 +14,19 @@ WORKDIR /lumen RUN mkdir -p /lumen/bootstrap/cache /lumen/storage/logs /lumen/storage/framework/sessions /lumen/storage/framework/views /lumen/storage/framework/cache RUN chmod -R 777 /lumen -RUN deploy/swoole/install-composer.sh RUN apt-get update > /dev/null && \ apt-get install -yqq git unzip > /dev/null -COPY deploy/laravel-s/composer* ./ +RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" && php composer-setup.php && php -r "unlink('composer-setup.php');" +RUN mv composer.phar /usr/local/bin/composer + +COPY deploy/laravel-s/composer.json ./ RUN echo "LARAVELS_LISTEN_IP=0.0.0.0" >> .env -RUN echo "LARAVELS_LISTEN_PORT=5200" >> .env +RUN echo "LARAVELS_LISTEN_PORT=8080" >> .env -RUN php composer.phar install -a --no-dev --quiet +RUN composer install -a --no-dev --quiet RUN php artisan laravels publish -EXPOSE 5200 +EXPOSE 8080 -CMD bin/laravels start +CMD php bin/laravels start From 547a5392f8d7dbfd31b055f933bce2062db3c6ac Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Mon, 1 Feb 2021 16:48:14 +0100 Subject: [PATCH 11/31] Update SNUnit Scala Native framework (#6321) * Update SNUnit Scala Native framework * Update SNUnit to 0.0.6 --- frameworks/Scala/snunit/.gitignore | 1 - frameworks/Scala/snunit/build.sbt | 17 +++++++++++------ .../Scala/snunit/project/build.properties | 2 +- frameworks/Scala/snunit/project/plugins.sbt | 2 +- frameworks/Scala/snunit/snunit.dockerfile | 2 +- .../Scala/snunit/src/main/scala/Main.scala | 6 +++--- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/frameworks/Scala/snunit/.gitignore b/frameworks/Scala/snunit/.gitignore index 2dc8eb3baff..8da16b22456 100644 --- a/frameworks/Scala/snunit/.gitignore +++ b/frameworks/Scala/snunit/.gitignore @@ -1,2 +1 @@ .bsp -/lowered.hnir diff --git a/frameworks/Scala/snunit/build.sbt b/frameworks/Scala/snunit/build.sbt index 5f70a909440..aa538378cba 100644 --- a/frameworks/Scala/snunit/build.sbt +++ b/frameworks/Scala/snunit/build.sbt @@ -1,12 +1,17 @@ -scalaVersion := "2.11.12" +import scala.scalanative.build._ +scalaVersion := "2.13.4" + +val snunitVersion = "0.0.6" libraryDependencies ++= Seq( - "com.github.lolgab" %%% "snunit" % "0.0.2", - "com.github.lolgab" %%% "snunit-async" % "0.0.2", - "com.lihaoyi" %%% "upickle" % "1.2.2" + "com.github.lolgab" %%% "snunit" % snunitVersion, + "com.github.lolgab" %%% "snunit-async" % snunitVersion, + "com.lihaoyi" %%% "upickle" % "1.2.3" ) -nativeMode := "release-full" -nativeLTO := "thin" +nativeConfig ~= { + _.withMode(Mode.releaseFull) + .withLTO(LTO.thin) +} enablePlugins(ScalaNativePlugin) diff --git a/frameworks/Scala/snunit/project/build.properties b/frameworks/Scala/snunit/project/build.properties index c06db1bb2ea..d91c272d4e4 100644 --- a/frameworks/Scala/snunit/project/build.properties +++ b/frameworks/Scala/snunit/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.5 +sbt.version=1.4.6 diff --git a/frameworks/Scala/snunit/project/plugins.sbt b/frameworks/Scala/snunit/project/plugins.sbt index 9663d2e0a99..2f4e38aae15 100644 --- a/frameworks/Scala/snunit/project/plugins.sbt +++ b/frameworks/Scala/snunit/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0-M2") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0") diff --git a/frameworks/Scala/snunit/snunit.dockerfile b/frameworks/Scala/snunit/snunit.dockerfile index 82de67ec12d..ed0f03114c9 100644 --- a/frameworks/Scala/snunit/snunit.dockerfile +++ b/frameworks/Scala/snunit/snunit.dockerfile @@ -20,6 +20,6 @@ FROM nginx/unit:1.21.0-minimal RUN apt-get update && apt-get install -y libuv1 COPY /config.json /docker-entrypoint.d/ -COPY --from=builder /workdir/target/scala-2.11/workdir-out /app/example +COPY --from=builder /workdir/target/scala-2.13/workdir-out /app/example EXPOSE 8080 diff --git a/frameworks/Scala/snunit/src/main/scala/Main.scala b/frameworks/Scala/snunit/src/main/scala/Main.scala index a4a1ac49f4b..cf019e7ac7c 100644 --- a/frameworks/Scala/snunit/src/main/scala/Main.scala +++ b/frameworks/Scala/snunit/src/main/scala/Main.scala @@ -13,19 +13,19 @@ object Main { .withRequestHandler(req => if (req.method == Method.GET && req.path == "/plaintext") req.send( - statusCode = 200, + statusCode = StatusCode.OK, content = "Hello, World!", headers = Seq("Content-Type" -> "text/plain") ) else if (req.method == Method.GET && req.path == "/json") req.send( - statusCode = 200, + statusCode = StatusCode.OK, content = stream(Message("Hello, World!")), headers = Seq.empty ) else req.send( - statusCode = 404, + statusCode = StatusCode.NotFound, content = "Not found", headers = Seq("Content-Type" -> "text/plain") ) From 7461c27131da7dbdfee63e0c24efe226be548981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Mon, 1 Feb 2021 16:48:48 +0100 Subject: [PATCH 12/31] Replace RootAllApplicationAssemblies with TrimMode (#6327) CoreRT aligned trimming settings with how official .NET 5 does trimming. --- .../PlatformBenchmarks/PlatformBenchmarks.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj index 334c5e4dd1f..1410e71ba51 100644 --- a/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj +++ b/frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/PlatformBenchmarks.csproj @@ -6,8 +6,7 @@ true - false - false + link false From 4a1e95776e20b3061033cfce3318680964f8f946 Mon Sep 17 00:00:00 2001 From: James Kleeh Date: Tue, 2 Feb 2021 13:29:48 -0500 Subject: [PATCH 13/31] Update to Micronaut 2.3.1 (#6334) --- frameworks/Java/micronaut/README.md | 2 +- frameworks/Java/micronaut/micronaut-cli.yml | 9 +- frameworks/Java/micronaut/pom.xml | 172 ++++++++---------- .../src/main/java/benchmark/Database.java | 25 ++- .../java/benchmark/JsonSerialization.java | 4 +- .../src/main/java/benchmark/PlainText.java | 8 +- .../repository/PgClientDbRepository.java | 23 +-- .../benchmark/repository/PgClientFactory.java | 32 ++-- .../java/benchmark/repository/PgClients.java | 10 +- .../benchmark/view/MustacheViewRenderer.java | 40 ---- .../java/benchmark/views/fortunes.rocker.html | 25 +++ .../src/main/resources/application.yml | 2 +- .../src/main/resources/fortunes.mustache | 4 - 13 files changed, 153 insertions(+), 203 deletions(-) delete mode 100644 frameworks/Java/micronaut/src/main/java/benchmark/view/MustacheViewRenderer.java create mode 100644 frameworks/Java/micronaut/src/main/java/benchmark/views/fortunes.rocker.html delete mode 100644 frameworks/Java/micronaut/src/main/resources/fortunes.mustache diff --git a/frameworks/Java/micronaut/README.md b/frameworks/Java/micronaut/README.md index 4f674e576f0..6d37e476ea5 100755 --- a/frameworks/Java/micronaut/README.md +++ b/frameworks/Java/micronaut/README.md @@ -1,4 +1,4 @@ -# [Micronaut](http://micronaut.io) Benchmarking Test (1.2.7) +# [Micronaut](http://micronaut.io) Benchmarking Test (2.3.1) ### Test Type Implementation Source Code diff --git a/frameworks/Java/micronaut/micronaut-cli.yml b/frameworks/Java/micronaut/micronaut-cli.yml index fc856826b2e..63dfab097d4 100644 --- a/frameworks/Java/micronaut/micronaut-cli.yml +++ b/frameworks/Java/micronaut/micronaut-cli.yml @@ -1,5 +1,6 @@ -profile: service -defaultPackage: benchmark ---- +applicationType: default +defaultPackage: com.example testFramework: junit -sourceLanguage: java \ No newline at end of file +sourceLanguage: java +buildTool: maven +features: [annotation-api, app-name, http-client, java, java-application, junit, logback, maven, netty-server, readme, shade, yaml] diff --git a/frameworks/Java/micronaut/pom.xml b/frameworks/Java/micronaut/pom.xml index e861c15ebd8..ae6ab042c48 100644 --- a/frameworks/Java/micronaut/pom.xml +++ b/frameworks/Java/micronaut/pom.xml @@ -2,86 +2,72 @@ 4.0.0 - io.micronaut + benchmark hello-micronaut 0.1 + ${packaging} + + + io.micronaut + micronaut-parent + 2.3.1 + + - 11 - 11 + jar + 11 + 11 + 2.3.1 benchmark.Application - 1.2.7 + netty + - jcenter + jcenter.bintray.com https://jcenter.bintray.com - - bintray - https://dl.bintray.com/micronaut/core-releases-local - - - oss-snapshot - https://oss.sonatype.org/content/repositories/snapshots - - - - - io.micronaut - micronaut-bom - ${micronaut.version} - pom - import - - - + io.micronaut - micronaut-http-client + micronaut-inject compile io.micronaut - micronaut-http-server-netty + micronaut-validation compile - - - io.netty - netty-common - - io.micronaut - micronaut-inject + micronaut-http-server-netty compile io.micronaut - micronaut-runtime + micronaut-http-client compile io.micronaut - micronaut-views + micronaut-runtime compile javax.annotation javax.annotation-api - 1.3.2 compile - io.micronaut - micronaut-inject-java - provided + io.micronaut.views + micronaut-views-rocker + compile - io.micronaut.configuration - micronaut-postgres-reactive + javax.annotation + javax.annotation-api compile @@ -92,98 +78,90 @@ io.vertx vertx-core - 3.5.4 + 3.9.2 + compile + + + io.vertx + vertx-pg-client + 3.9.2 compile io.vertx vertx-codegen - 3.5.4 + 3.9.2 compile io.vertx vertx-rx-java2 - 3.5.4 + 3.9.2 compile - com.github.spullara.mustache.java - compiler - 0.9.5 + com.fizzed + rocker-runtime + 1.3.0 ch.qos.logback logback-classic - 1.2.3 runtime - junit - junit - 4.13.1 + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + io.micronaut.test + micronaut-test-junit5 test + + io.micronaut.build + micronaut-maven-plugin + org.apache.maven.plugins - maven-shade-plugin - 3.1.0 + maven-compiler-plugin + + + + + + + -Amicronaut.processing.group=com.example + -Amicronaut.processing.module=demo + + + + + com.fizzed + rocker-maven-plugin + 1.3.0 - package + generate-rocker-templates + generate-sources - shade + generate - - - ${exec.mainClass} - - - + true - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - java - - -classpath - - ${exec.mainClass} - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - - -parameters - - - - io.micronaut - micronaut-inject-java - ${micronaut.version} - - - - - - diff --git a/frameworks/Java/micronaut/src/main/java/benchmark/Database.java b/frameworks/Java/micronaut/src/main/java/benchmark/Database.java index 13d46a22122..6821266d645 100644 --- a/frameworks/Java/micronaut/src/main/java/benchmark/Database.java +++ b/frameworks/Java/micronaut/src/main/java/benchmark/Database.java @@ -3,20 +3,17 @@ import benchmark.entity.Fortune; import benchmark.entity.World; import benchmark.repository.DbRepository; -import com.github.mustachejava.DefaultMustacheFactory; -import com.github.mustachejava.Mustache; +import io.micronaut.http.HttpResponse; import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Get; import io.micronaut.http.annotation.QueryValue; -import io.micronaut.views.ModelAndView; -import io.micronaut.views.View; +import io.micronaut.views.rocker.RockerWritable; import io.reactivex.Flowable; import io.reactivex.Single; +import benchmark.views.fortunes; import java.util.Arrays; -import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.concurrent.ThreadLocalRandom; import static java.util.Comparator.comparing; @@ -24,7 +21,6 @@ @Controller("/") public class Database { - private final DbRepository dbRepository; public Database(DbRepository dbRepository) { @@ -39,17 +35,18 @@ public Single db() { @Get("/queries") public Single> queries(@QueryValue String queries) { Flowable[] worlds = new Flowable[parseQueryCount(queries)]; - Arrays.setAll(worlds, i -> db().toFlowable()); + Arrays.setAll(worlds, i -> dbRepository.getWorld(randomWorldNumber()).toFlowable()); return Flowable.merge(Arrays.asList(worlds)).toList(); } - @Get(value = "/fortunes", produces = "text/html;charset=utf-8") - public Single> fortune() { - return dbRepository.fortunes().toList().flatMap(fortunes -> { - fortunes.add(new Fortune(0, "Additional fortune added at request time.")); - fortunes.sort(comparing(fortune -> fortune.message)); - return Single.just(new ModelAndView<>("fortunes", Collections.singletonMap("fortunes", fortunes))); + @Get(value = "/fortunes") + public Single> fortune() { + return dbRepository.fortunes().toList().map(fortuneList -> { + fortuneList.add(new Fortune(0, "Additional fortune added at request time.")); + fortuneList.sort(comparing(fortune -> fortune.message)); + return HttpResponse.ok(new RockerWritable(fortunes.template(fortuneList))) + .contentType("text/html;charset=utf-8"); }); } diff --git a/frameworks/Java/micronaut/src/main/java/benchmark/JsonSerialization.java b/frameworks/Java/micronaut/src/main/java/benchmark/JsonSerialization.java index d670ebbf7a3..b5fc0359fba 100644 --- a/frameworks/Java/micronaut/src/main/java/benchmark/JsonSerialization.java +++ b/frameworks/Java/micronaut/src/main/java/benchmark/JsonSerialization.java @@ -11,9 +11,9 @@ public class JsonSerialization { @Get("/") - Single getJson() { + Map getJson() { Map map = new HashMap<>(); map.put("message", "Hello, World!"); - return Single.just(map); + return map; } } diff --git a/frameworks/Java/micronaut/src/main/java/benchmark/PlainText.java b/frameworks/Java/micronaut/src/main/java/benchmark/PlainText.java index 862ed744a3c..5f0f94e9e6e 100644 --- a/frameworks/Java/micronaut/src/main/java/benchmark/PlainText.java +++ b/frameworks/Java/micronaut/src/main/java/benchmark/PlainText.java @@ -3,15 +3,17 @@ import io.micronaut.http.MediaType; import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Get; -import io.reactivex.Single; +import io.micronaut.scheduling.TaskExecutors; +import io.micronaut.scheduling.annotation.ExecuteOn; @Controller("/plaintext") +@ExecuteOn(TaskExecutors.IO) public class PlainText { private static final String TEXT = "Hello, World!"; @Get(value = "/", produces = MediaType.TEXT_PLAIN) - Single getPlainText() { - return Single.just(TEXT); + String getPlainText() { + return TEXT; } } diff --git a/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClientDbRepository.java b/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClientDbRepository.java index 860226266a5..a682424c81a 100644 --- a/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClientDbRepository.java +++ b/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClientDbRepository.java @@ -2,20 +2,17 @@ import benchmark.entity.Fortune; import benchmark.entity.World; -import io.reactiverse.pgclient.PgIterator; -import io.reactiverse.pgclient.Row; -import io.reactiverse.pgclient.Tuple; import io.reactivex.BackpressureStrategy; import io.reactivex.Flowable; import io.reactivex.Single; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import io.vertx.reactivex.sqlclient.Row; +import io.vertx.reactivex.sqlclient.Tuple; import javax.inject.Singleton; @Singleton public class PgClientDbRepository implements DbRepository { - private final Logger log = LoggerFactory.getLogger(getClass()); + private final PgClients pgClients; public PgClientDbRepository(PgClients pgClients) { @@ -25,13 +22,11 @@ public PgClientDbRepository(PgClients pgClients) { @Override public Single getWorld(int id) { return Single.create(sink -> - pgClients.getOne().preparedQuery("SELECT * FROM world WHERE id = $1", Tuple.of(id), ar -> { + pgClients.getOne().preparedQuery("SELECT * FROM world WHERE id = $1").execute(Tuple.of(id), ar -> { if (ar.failed()) { sink.onError(ar.cause()); } else { - final Row row = ar.result().iterator().next(); - World world = new World(row.getInteger(0), row.getInteger(1)); sink.onSuccess(world); } @@ -39,7 +34,7 @@ public Single getWorld(int id) { } private Single updateWorld(World world) { - return Single.create(sink -> pgClients.getOne().preparedQuery("UPDATE world SET randomnumber = $1 WHERE id = $2", Tuple.of(world.randomNumber, world.id), ar -> { + return Single.create(sink -> pgClients.getOne().preparedQuery("UPDATE world SET randomnumber = $1 WHERE id = $2").execute(Tuple.of(world.randomNumber, world.id), ar -> { if (ar.failed()) { sink.onError(ar.cause()); } else { @@ -59,18 +54,16 @@ public Single findAndUpdateWorld(int id, int randomNumber) { @Override public Flowable fortunes() { return Flowable.create(sink -> - pgClients.getOne().preparedQuery("SELECT * FROM fortune", ar -> { + pgClients.getOne().preparedQuery("SELECT * FROM fortune").execute(ar -> { if (ar.failed()) { sink.onError(ar.cause()); return; } - PgIterator resultSet = ar.result().iterator(); - while (resultSet.hasNext()) { - Tuple row = resultSet.next(); + for (Row row : ar.result()) { sink.onNext(new Fortune(row.getInteger(0), row.getString(1))); } sink.onComplete(); }), BackpressureStrategy.BUFFER); } -} \ No newline at end of file +} diff --git a/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClientFactory.java b/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClientFactory.java index 531d4c88ce3..bbee6f2e939 100644 --- a/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClientFactory.java +++ b/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClientFactory.java @@ -1,11 +1,10 @@ package benchmark.repository; -import io.micronaut.context.annotation.Bean; import io.micronaut.context.annotation.Factory; -import io.reactiverse.pgclient.PgClient; -import io.reactiverse.pgclient.PgPool; -import io.reactiverse.pgclient.PgPoolOptions; -import io.vertx.core.Vertx; +import io.vertx.pgclient.PgConnectOptions; +import io.vertx.reactivex.core.Vertx; +import io.vertx.reactivex.pgclient.PgPool; +import io.vertx.sqlclient.PoolOptions; import javax.inject.Singleton; import java.util.ArrayList; @@ -20,16 +19,14 @@ public PgClientFactory(PgClientConfig config) { this.config = config; } - @Bean @Singleton public Vertx vertx() { return Vertx.vertx(); } - @Bean @Singleton public PgClients pgClients(Vertx vertx) { - List clients = new ArrayList<>(); + List clients = new ArrayList<>(); for (int i = 0; i < Runtime.getRuntime().availableProcessors(); i++) { clients.add(pgClient(vertx)); @@ -40,14 +37,15 @@ public PgClients pgClients(Vertx vertx) { private PgPool pgClient(Vertx vertx) { - PgPoolOptions options = new PgPoolOptions(); - options.setDatabase(config.getName()); - options.setHost(config.getHost()); - options.setPort(config.getPort()); - options.setUser(config.getUsername()); - options.setPassword(config.getPassword()); - options.setCachePreparedStatements(true); - options.setMaxSize(1); - return PgClient.pool(vertx, options); + PgConnectOptions connectOptions = new PgConnectOptions(); + connectOptions.setDatabase(config.getName()); + connectOptions.setHost(config.getHost()); + connectOptions.setPort(config.getPort()); + connectOptions.setUser(config.getUsername()); + connectOptions.setPassword(config.getPassword()); + connectOptions.setCachePreparedStatements(true); + PoolOptions poolOptions = new PoolOptions(); + poolOptions.setMaxSize(1); + return PgPool.pool(vertx, connectOptions, poolOptions); } } diff --git a/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClients.java b/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClients.java index dac6c72339e..a5a836c21d1 100644 --- a/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClients.java +++ b/frameworks/Java/micronaut/src/main/java/benchmark/repository/PgClients.java @@ -1,19 +1,19 @@ package benchmark.repository; -import io.reactiverse.pgclient.PgClient; +import io.vertx.reactivex.pgclient.PgPool; import java.util.Collection; import java.util.Iterator; import java.util.stream.Stream; class PgClients { - private final Iterator iterator; + private final Iterator iterator; - PgClients(Collection clients) { + PgClients(Collection clients) { iterator = Stream.generate(() -> clients).flatMap(Collection::stream).iterator(); } - synchronized PgClient getOne() { + synchronized PgPool getOne() { return iterator.next(); } -} \ No newline at end of file +} diff --git a/frameworks/Java/micronaut/src/main/java/benchmark/view/MustacheViewRenderer.java b/frameworks/Java/micronaut/src/main/java/benchmark/view/MustacheViewRenderer.java deleted file mode 100644 index 31154523377..00000000000 --- a/frameworks/Java/micronaut/src/main/java/benchmark/view/MustacheViewRenderer.java +++ /dev/null @@ -1,40 +0,0 @@ -package benchmark.view; - - -import com.github.mustachejava.DefaultMustacheFactory; -import com.github.mustachejava.Mustache; -import io.micronaut.core.io.ResourceLoader; -import io.micronaut.core.io.Writable; -import io.micronaut.core.io.scan.ClassPathResourceLoader; -import io.micronaut.http.MediaType; -import io.micronaut.http.annotation.Produces; -import io.micronaut.views.ViewsRenderer; - -import javax.annotation.Nullable; -import javax.inject.Singleton; -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; - -@Singleton -@Produces(MediaType.TEXT_HTML) -public class MustacheViewRenderer implements ViewsRenderer { - protected final ResourceLoader resourceLoader; - private final Mustache mustache; - - public MustacheViewRenderer(ClassPathResourceLoader resourceLoader) { - this.resourceLoader = resourceLoader; - this.mustache = new DefaultMustacheFactory().compile("fortunes.mustache"); - } - - @Override - public Writable render(String viewName, @Nullable Object data) { - return out -> mustache.execute(out, data); - } - - @Override - public boolean exists(String viewName) { - return viewName.equals("fortunes"); - } - -} diff --git a/frameworks/Java/micronaut/src/main/java/benchmark/views/fortunes.rocker.html b/frameworks/Java/micronaut/src/main/java/benchmark/views/fortunes.rocker.html new file mode 100644 index 00000000000..47cb23c2b65 --- /dev/null +++ b/frameworks/Java/micronaut/src/main/java/benchmark/views/fortunes.rocker.html @@ -0,0 +1,25 @@ +@import benchmark.entity.Fortune +@import java.util.List + +@args (List fortunes) + + + + + Fortunes + + + + + + + + @for (Fortune fortune : fortunes) { + + + + + } +
idmessage
@fortune.getId()@fortune.getMessage()
+ + diff --git a/frameworks/Java/micronaut/src/main/resources/application.yml b/frameworks/Java/micronaut/src/main/resources/application.yml index e7c0cffa32e..58ab85af4db 100644 --- a/frameworks/Java/micronaut/src/main/resources/application.yml +++ b/frameworks/Java/micronaut/src/main/resources/application.yml @@ -3,4 +3,4 @@ micronaut: name: benchmark server: port: 8080 - serverHeader: Micronaut \ No newline at end of file + serverHeader: Micronaut diff --git a/frameworks/Java/micronaut/src/main/resources/fortunes.mustache b/frameworks/Java/micronaut/src/main/resources/fortunes.mustache deleted file mode 100644 index 0ec91cac0e9..00000000000 --- a/frameworks/Java/micronaut/src/main/resources/fortunes.mustache +++ /dev/null @@ -1,4 +0,0 @@ - - - -Fortunes{{# fortunes}}{{/ fortunes}}
idmessage
{{id}}{{message}}
From 6978e855e8ddcd1d0ec92bf1cdb7512c2d74848d Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 4 Feb 2021 00:41:56 +0800 Subject: [PATCH 14/31] [c#/beetlex] update v1.6.5.3-beta (#6335) * update beetlex 1.4.3 update beetlex 1.4.3 * docker add COMPlus_ReadyToRun variable update beetlex * update beetlex, enabled thread queue * beetlex framework add db and queries cases * add db code * change result json data * update query url * beetlex framework add fortunes cases * change Content-Type * add beetlex core cases * fix queries cases * update config * change try readline * update benchmark config * Update README.md * Update README.md * change versus property * beetlex-core update .net core to v3.0 * change beetlex-core project file * beetlex update raw db class * beetlex update raw db * beetlex debug plaintext * change debug docker file * update beetlex to 1.4.0 * update * beetlex update core 3.1 * [c#/beetlex] add updates cases * [c#/beetlex] change Server: TFB, change custom connection pool, add update docker * fix errors * change pool init * change connection pool maxsize * fix fortunes errors * clear DBRaw _connectionString value. * [c#beetlex] change update dbconnection pool size * [c#/beetlex] udpate spanjson to v3.0.1, Npgsql v5.0.0 * [c#/beetlex] add caching sample * set connectionstring multiplexing * remove connection multiplexing setting * [c#/beetlex]change NpgsqlParameter to NpgsqlParameter * [c#/beetlex] update dbraw * [c#/beetlex] change connection string * [c#/beetlex] add fortunes cases to core-updb * update beetlex 1.5.6 * update 5.0.0-alpha1 * update docker file * Enabled IOQueues * Set IOQueues debug mode * update * [c#/beetlex] udpate to v1.6.0.1-beta * update pg drive * [c#/beetlex] update to beetlex v1.6.3 and support pipelining * set options * [c#/beetlex] Optimized actions * [c#/beetlex] update plaintext * Bump ServiceStack in /frameworks/CSharp/servicestack/src/SelfHost Bumps [ServiceStack](https://github.com/ServiceStack/ServiceStack) from 3.9.59 to 5.9.2. - [Release notes](https://github.com/ServiceStack/ServiceStack/releases) - [Commits](https://github.com/ServiceStack/ServiceStack/commits/v5.9.2) Signed-off-by: dependabot[bot] * [c#/beetlex] change plaintext buffer size, optimize fortunes. * [c#/beetlex] update v1.6.5,use System.Text.Json * change docker files * update beetlex 1.6.5.2 * [c#/beetlex] update v1.6.5.3-beta Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj | 2 +- frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs | 6 +++++- frameworks/CSharp/beetlex/beetlex-debug.dockerfile | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj b/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj index caedea04988..37251f29352 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj @@ -8,7 +8,7 @@ - + diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs index 14bbe43b9df..785d6b021e3 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs @@ -16,7 +16,11 @@ public partial class HttpHandler private static Utf8JsonWriter GetUtf8JsonWriter(PipeStream stream, HttpToken token) { var buffer = stream.CreateBufferWriter(); - var writer = token.Utf8JsonWriter ??= new Utf8JsonWriter(buffer, new JsonWriterOptions { SkipValidation = true }); + if (token.Utf8JsonWriter == null) + { + token.Utf8JsonWriter = new Utf8JsonWriter(buffer, new JsonWriterOptions { SkipValidation = true }); + } + var writer = token.Utf8JsonWriter; writer.Reset(buffer); return writer; } diff --git a/frameworks/CSharp/beetlex/beetlex-debug.dockerfile b/frameworks/CSharp/beetlex/beetlex-debug.dockerfile index ae68a278647..98d247f328f 100644 --- a/frameworks/CSharp/beetlex/beetlex-debug.dockerfile +++ b/frameworks/CSharp/beetlex/beetlex-debug.dockerfile @@ -4,6 +4,7 @@ COPY PlatformBenchmarks . RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS runtime +ENV DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS 1 WORKDIR /app COPY --from=build /app/out ./ From b3322f4f94e2ddd37800808ad0b5fae3f6955edf Mon Sep 17 00:00:00 2001 From: Brad Wood Date: Wed, 3 Feb 2021 11:29:32 -0600 Subject: [PATCH 15/31] WIP: Initial addition of cfml-lucee (#6325) * Initial addition of cfml-lucee * Additional tests * remove debuggingn port * Expose port and pin docker image --- frameworks/CFML/cfml-lucee/README.md | 46 +++++++++++++++++++ .../CFML/cfml-lucee/benchmark_config.json | 30 ++++++++++++ .../CFML/cfml-lucee/cfml-lucee.dockerfile | 14 ++++++ frameworks/CFML/cfml-lucee/src/.cfconfig.json | 14 ++++++ frameworks/CFML/cfml-lucee/src/db.cfm | 9 ++++ frameworks/CFML/cfml-lucee/src/fortunes.cfm | 13 ++++++ frameworks/CFML/cfml-lucee/src/json.cfm | 4 ++ frameworks/CFML/cfml-lucee/src/plaintext.cfm | 3 ++ frameworks/CFML/cfml-lucee/src/queries.cfm | 20 ++++++++ frameworks/CFML/cfml-lucee/src/server.json | 6 +++ frameworks/CFML/cfml-lucee/src/updates.cfm | 28 +++++++++++ 11 files changed, 187 insertions(+) create mode 100644 frameworks/CFML/cfml-lucee/README.md create mode 100644 frameworks/CFML/cfml-lucee/benchmark_config.json create mode 100644 frameworks/CFML/cfml-lucee/cfml-lucee.dockerfile create mode 100644 frameworks/CFML/cfml-lucee/src/.cfconfig.json create mode 100644 frameworks/CFML/cfml-lucee/src/db.cfm create mode 100644 frameworks/CFML/cfml-lucee/src/fortunes.cfm create mode 100644 frameworks/CFML/cfml-lucee/src/json.cfm create mode 100644 frameworks/CFML/cfml-lucee/src/plaintext.cfm create mode 100644 frameworks/CFML/cfml-lucee/src/queries.cfm create mode 100644 frameworks/CFML/cfml-lucee/src/server.json create mode 100644 frameworks/CFML/cfml-lucee/src/updates.cfm diff --git a/frameworks/CFML/cfml-lucee/README.md b/frameworks/CFML/cfml-lucee/README.md new file mode 100644 index 00000000000..c1ef75777c1 --- /dev/null +++ b/frameworks/CFML/cfml-lucee/README.md @@ -0,0 +1,46 @@ +# CFML Lucee Benchmarking Test + +### Test Type Implementation Source Code + +* [JSON](src/json.cfm) +* [PLAINTEXT](src/plaintext.cfm) +* [DB](src/db.cfm) +* [QUERY](src/query.cfm) +* [CACHED QUERY](src/cached_query.cfm) +* [UPDATE](src/update.cfm) +* [FORTUNES](src/fortunes.cfm) + +## Important Libraries +The tests were run with: +* [CommandBox](https://commandbox.ortusbooks.com/) +* [ortussolutions/commandbox Docker image](https://hub.docker.com/r/ortussolutions/commandbox/) +* [Lucee Server](https://www.lucee.org/) + +## Test URLs +### JSON + +http://localhost:8080/json.cfm + +### PLAINTEXT + +http://localhost:8080/plaintext.cfm + +### DB + +http://localhost:8080/db.cfm + +### QUERY + +http://localhost:8080/query.cfm?queries= + +### CACHED QUERY + +http://localhost:8080/cached_query.cfm?queries= + +### UPDATE + +http://localhost:8080/update.cfm?queries= + +### FORTUNES + +http://localhost:8080/fortunes.cfm diff --git a/frameworks/CFML/cfml-lucee/benchmark_config.json b/frameworks/CFML/cfml-lucee/benchmark_config.json new file mode 100644 index 00000000000..279ed80d4c2 --- /dev/null +++ b/frameworks/CFML/cfml-lucee/benchmark_config.json @@ -0,0 +1,30 @@ +{ + "framework": "cfml-lucee", + "tests": [ + { + "default": { + "json_url": "/json.cfm", + "db_url": "/db.cfm", + "query_url":"/queries.cfm?queries=", + "fortune_url": "/fortunes.cfm", + "plaintext_url": "/plaintext.cfm", + "update_url": "/updates.cfm?queries=", + "port": 8080, + "approach": "Realistic", + "classification": "Platform", + "database": "Postgres", + "framework": "None", + "language": "CFML", + "flavor": "None", + "orm": "raw", + "platform": "None", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "cfml-lucee", + "notes": "", + "versus": "None" + } + } + ] +} diff --git a/frameworks/CFML/cfml-lucee/cfml-lucee.dockerfile b/frameworks/CFML/cfml-lucee/cfml-lucee.dockerfile new file mode 100644 index 00000000000..efd14ef1ecf --- /dev/null +++ b/frameworks/CFML/cfml-lucee/cfml-lucee.dockerfile @@ -0,0 +1,14 @@ +FROM ortussolutions/commandbox:3.2.1 + +COPY ./src/server.json /app/server.json +COPY ./src/.cfconfig.json /app/.cfconfig.json + +RUN box install commandbox-cfconfig --verbose --force + +RUN ${BUILD_DIR}/util/warmup-server.sh + +RUN export FINALIZE_STARTUP=true;$BUILD_DIR/run.sh;unset FINALIZE_STARTUP + +EXPOSE 8080 + +COPY ./src /app/ \ No newline at end of file diff --git a/frameworks/CFML/cfml-lucee/src/.cfconfig.json b/frameworks/CFML/cfml-lucee/src/.cfconfig.json new file mode 100644 index 00000000000..08a455de3ff --- /dev/null +++ b/frameworks/CFML/cfml-lucee/src/.cfconfig.json @@ -0,0 +1,14 @@ +{ + "datasources":{ + "world":{ + "database":"hello_world", + "dbdriver":"PostgreSQL", + "host":"tfb-database", + "password":"benchmarkdbpass", + "port":"5432", + "username":"benchmarkdbuser" + } + }, + "inspectTemplate":"never", + "maxCFThreads":"512" +} \ No newline at end of file diff --git a/frameworks/CFML/cfml-lucee/src/db.cfm b/frameworks/CFML/cfml-lucee/src/db.cfm new file mode 100644 index 00000000000..b4aad70ee54 --- /dev/null +++ b/frameworks/CFML/cfml-lucee/src/db.cfm @@ -0,0 +1,9 @@ + + + + + SELECT id, randomNumber + FROM World + WHERE id = + +#serializeJSON( qry[ 1 ] )# \ No newline at end of file diff --git a/frameworks/CFML/cfml-lucee/src/fortunes.cfm b/frameworks/CFML/cfml-lucee/src/fortunes.cfm new file mode 100644 index 00000000000..7c99ca089c2 --- /dev/null +++ b/frameworks/CFML/cfml-lucee/src/fortunes.cfm @@ -0,0 +1,13 @@ + + + + + SELECT id, message + FROM Fortune + + +compareNoCase(a.message,b.message) )> +Fortunes + +
idmessage
#row.id##htmlEditFormat( row.message )#
+
\ No newline at end of file diff --git a/frameworks/CFML/cfml-lucee/src/json.cfm b/frameworks/CFML/cfml-lucee/src/json.cfm new file mode 100644 index 00000000000..0f752426a4b --- /dev/null +++ b/frameworks/CFML/cfml-lucee/src/json.cfm @@ -0,0 +1,4 @@ + + + +#serializeJSON( { 'message' : 'Hello, World!' } )# \ No newline at end of file diff --git a/frameworks/CFML/cfml-lucee/src/plaintext.cfm b/frameworks/CFML/cfml-lucee/src/plaintext.cfm new file mode 100644 index 00000000000..d809c0f05ce --- /dev/null +++ b/frameworks/CFML/cfml-lucee/src/plaintext.cfm @@ -0,0 +1,3 @@ + + +Hello, World! \ No newline at end of file diff --git a/frameworks/CFML/cfml-lucee/src/queries.cfm b/frameworks/CFML/cfml-lucee/src/queries.cfm new file mode 100644 index 00000000000..ba7f39eda6a --- /dev/null +++ b/frameworks/CFML/cfml-lucee/src/queries.cfm @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + SELECT id, randomNumber + FROM World + WHERE id = + + + +#serializeJSON( results )# \ No newline at end of file diff --git a/frameworks/CFML/cfml-lucee/src/server.json b/frameworks/CFML/cfml-lucee/src/server.json new file mode 100644 index 00000000000..82f9cfe8101 --- /dev/null +++ b/frameworks/CFML/cfml-lucee/src/server.json @@ -0,0 +1,6 @@ +{ + "profile" : "none", + "web" : { + "maxRequests" : 512 + } +} \ No newline at end of file diff --git a/frameworks/CFML/cfml-lucee/src/updates.cfm b/frameworks/CFML/cfml-lucee/src/updates.cfm new file mode 100644 index 00000000000..7b0226266f4 --- /dev/null +++ b/frameworks/CFML/cfml-lucee/src/updates.cfm @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + SELECT id, randomNumber + FROM World + WHERE id = + + + + + update World as w set + randomNumber = w2.randomNumber + from (values + #results.map( (r)=>"(#val( r.id )#, #val( r.randomNumber )#)" ).toList( ',' )# + ) as w2(id,randomNumber) + where w2.id = w.id; + +#serializeJSON( results )# \ No newline at end of file From caf55d6583e5c61cc33e42c7d3968213b3276b68 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 3 Feb 2021 13:28:26 -0800 Subject: [PATCH 16/31] Remove google groups / add discussions tab link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9116f3f57b4..a630313260a 100644 --- a/README.md +++ b/README.md @@ -95,4 +95,4 @@ If you have a `results.json` file that you would like to visualize, you can [do The community has consistently helped in making these tests better, and we welcome any and all changes. Reviewing our contribution practices and guidelines will help to keep us all on the same page. The [contribution guide](https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Development-Contributing-Guide) can be found in the [TFB documentation](https://github.com/TechEmpower/FrameworkBenchmarks/wiki). -Join in the conversation on our [mailing list](https://groups.google.com/forum/?fromgroups=#!forum/framework-benchmarks), on [Twitter](https://twitter.com/tfbenchmarks), or chat with us on [Freenode](https://webchat.freenode.net/) at `#techempower-fwbm`. +Join in the conversation in the [Discussions tab](https://github.com/TechEmpower/FrameworkBenchmarks/discussions), on [Twitter](https://twitter.com/tfbenchmarks), or chat with us on [Freenode](https://webchat.freenode.net/) at `#techempower-fwbm`. From 985f2155ab9c43babf4524b5f1c5e427494c504f Mon Sep 17 00:00:00 2001 From: Matthieu Garrigues Date: Thu, 4 Feb 2021 19:16:18 +0100 Subject: [PATCH 17/31] Lithium update (#6336) * Lithium update. * Lithium update. --- frameworks/C++/lithium/lithium.cc | 17 ++++++++++++----- frameworks/C++/lithium/lithium_batch.cc | 14 ++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/frameworks/C++/lithium/lithium.cc b/frameworks/C++/lithium/lithium.cc index b4030e0276e..d992212681f 100644 --- a/frameworks/C++/lithium/lithium.cc +++ b/frameworks/C++/lithium/lithium.cc @@ -9,6 +9,7 @@ #include "symbols.hh" using namespace li; + template void escape_html_entities(B& buffer, const std::string_view& data) { @@ -41,6 +42,12 @@ void escape_html_entities(B& buffer, const std::string_view& data) } } +int g_seed = 0; +inline int random_int() { + g_seed = (214013*g_seed+2531011); + return (g_seed>>16)&0x7FFF; +} + #ifdef PROFILE_MODE void siege(int port) { auto sockets = http_benchmark_connect(512, port); @@ -137,7 +144,7 @@ int main(int argc, char* argv[]) { }; my_api.get("/db") = [&](http_request& request, http_response& response) { sql_db.max_async_connections_per_thread_ = db_nconn; - response.write_json(*random_numbers.connect(request.fiber).find_one(s::id = 1 + rand() % 10000)); + response.write_json(*random_numbers.connect(request.fiber).find_one(s::id = 1 + random_int() % 10000)); }; my_api.get("/queries") = [&](http_request& request, http_response& response) { @@ -148,7 +155,7 @@ int main(int argc, char* argv[]) { N = std::max(1, std::min(N, 500)); auto c = random_numbers.connect(request.fiber); - response.write_json_generator(N, [&] { return *c.find_one(s::id = 1 + rand() % 10000); }); + response.write_json_generator(N, [&] { return *c.find_one(s::id = 1 + random_int() % 10000); }); }; random_numbers.connect().forall([&] (const auto& number) { @@ -160,7 +167,7 @@ int main(int argc, char* argv[]) { int N = atoi(N_str.c_str()); response.write_json_generator(std::max(1, std::min(N, 500)), - [&] { return world_cache.get(1 + rand() % 10000); }); + [&] { return world_cache.get(1 + random_int() % 10000); }); }; my_api.get("/updates") = [&](http_request& request, http_response& response) { @@ -180,8 +187,8 @@ int main(int argc, char* argv[]) { #endif for (int i = 0; i < N; i++) { - numbers[i] = *c.find_one(s::id = 1 + rand() % 10000); - numbers[i].randomNumber = 1 + rand() % 10000; + numbers[i] = *c.find_one(s::id = 1 + random_int() % 10000); + numbers[i].randomNumber = 1 + random_int() % 10000; } std::sort(numbers.begin(), numbers.end(), [] (auto a, auto b) { return a.id < b.id; }); diff --git a/frameworks/C++/lithium/lithium_batch.cc b/frameworks/C++/lithium/lithium_batch.cc index 6e390ddc958..b281cb946bd 100644 --- a/frameworks/C++/lithium/lithium_batch.cc +++ b/frameworks/C++/lithium/lithium_batch.cc @@ -41,6 +41,12 @@ void escape_html_entities(B& buffer, const std::string_view& data) } } +int g_seed = 0; +inline int random_int() { + g_seed = (214013*g_seed+2531011); + return (g_seed>>16)&0x7FFF; +} + #ifdef PROFILE_MODE void siege(int port) { auto sockets = http_benchmark_connect(256, port); @@ -98,7 +104,7 @@ int main(int argc, char* argv[]) { std::vector results; for (int i = 0; i < N; i++) - results.push_back(orm.find_one(s::id = 1 + (i*10000/N) + rand() % (10000/N))); + results.push_back(orm.find_one(s::id = 1 + (i*10000/N) + random_int() % (10000/N))); for (int i = 0; i < N; i++){ // println(" read result " , i); numbers[i] = results[i]().value(); @@ -115,7 +121,7 @@ int main(int argc, char* argv[]) { response.write_json(s::message = "Hello, World!"); }; my_api.get("/db") = [&](http_request& request, http_response& response) { - response.write_json(random_numbers.connect(request.fiber).find_one(s::id = 1 + rand() % 10000)()); + response.write_json(random_numbers.connect(request.fiber).find_one(s::id = 1 + random_int() % 10000)()); }; my_api.get("/queries") = [&](http_request& request, http_response& response) { @@ -127,7 +133,7 @@ int main(int argc, char* argv[]) { auto orm = random_numbers.connect(request.fiber); std::vector results; for (int i = 0; i < N; i++) - results.push_back(orm.find_one(s::id = 1 + (i*10000/N) + rand() % (10000/N))); + results.push_back(orm.find_one(s::id = 1 + (i*10000/N) + random_int() % (10000/N))); int i = 0; response.write_json_generator(N, [&] { return results[i++]().value(); }); @@ -142,7 +148,7 @@ int main(int argc, char* argv[]) { auto numbers = select_N_random_numbers(c, N); for (int i = 0; i < N; i++) - numbers[i].randomNumber = 1 + rand() % 10000; + numbers[i].randomNumber = 1 + random_int() % 10000; auto req = c.bulk_update(numbers); if (N_SQL_CONNECTIONS * nthreads > 1) c.backend_connection().end_of_batch(); From a2d3dee6e3b7a962e10c1555b754ec079cd279f3 Mon Sep 17 00:00:00 2001 From: vic <1018595261@qq.com> Date: Tue, 9 Feb 2021 00:03:41 +0800 Subject: [PATCH 18/31] [one] modify the number of connection pools (#6340) * Update IndexController.php * modify the number of connection pools --- frameworks/PHP/one/App/Config/mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/PHP/one/App/Config/mysql.php b/frameworks/PHP/one/App/Config/mysql.php index 545ad7d43c2..15cfcf4e022 100644 --- a/frameworks/PHP/one/App/Config/mysql.php +++ b/frameworks/PHP/one/App/Config/mysql.php @@ -3,7 +3,7 @@ return [ 'debug_log' => false, // 是否打印sql日志 'default' => [ - 'max_connect_count' => 30, + 'max_connect_count' => 6, 'dns' => env('mysql.default.dns', 'mysql:host=127.0.0.1;dbname=test'), 'username' => env('mysql.default.username', 'root'), 'password' => env('mysql.default.password', '123456'), From 73202caf854d6d57826614499808862105276cec Mon Sep 17 00:00:00 2001 From: Brad Wood Date: Mon, 8 Feb 2021 10:04:06 -0600 Subject: [PATCH 19/31] Add Adobe CFML Engine and re-org folders (#6337) * Add Adobe CF Engine and re-org folders * Remove debugging --- frameworks/CFML/CFML/README.md | 46 +++++++++++++++++++ frameworks/CFML/CFML/benchmark_config.json | 53 ++++++++++++++++++++++ frameworks/CFML/CFML/cfml-adobe.dockerfile | 14 ++++++ frameworks/CFML/CFML/cfml.dockerfile | 14 ++++++ frameworks/CFML/CFML/src/.cfconfig.json | 14 ++++++ frameworks/CFML/CFML/src/db.cfm | 9 ++++ frameworks/CFML/CFML/src/fortunes.cfm | 13 ++++++ frameworks/CFML/CFML/src/json.cfm | 4 ++ frameworks/CFML/CFML/src/plaintext.cfm | 3 ++ frameworks/CFML/CFML/src/queries.cfm | 20 ++++++++ frameworks/CFML/CFML/src/server-adobe.json | 9 ++++ frameworks/CFML/CFML/src/server-lucee.json | 9 ++++ frameworks/CFML/CFML/src/updates.cfm | 31 +++++++++++++ 13 files changed, 239 insertions(+) create mode 100644 frameworks/CFML/CFML/README.md create mode 100644 frameworks/CFML/CFML/benchmark_config.json create mode 100644 frameworks/CFML/CFML/cfml-adobe.dockerfile create mode 100644 frameworks/CFML/CFML/cfml.dockerfile create mode 100644 frameworks/CFML/CFML/src/.cfconfig.json create mode 100644 frameworks/CFML/CFML/src/db.cfm create mode 100644 frameworks/CFML/CFML/src/fortunes.cfm create mode 100644 frameworks/CFML/CFML/src/json.cfm create mode 100644 frameworks/CFML/CFML/src/plaintext.cfm create mode 100644 frameworks/CFML/CFML/src/queries.cfm create mode 100644 frameworks/CFML/CFML/src/server-adobe.json create mode 100644 frameworks/CFML/CFML/src/server-lucee.json create mode 100644 frameworks/CFML/CFML/src/updates.cfm diff --git a/frameworks/CFML/CFML/README.md b/frameworks/CFML/CFML/README.md new file mode 100644 index 00000000000..c1ef75777c1 --- /dev/null +++ b/frameworks/CFML/CFML/README.md @@ -0,0 +1,46 @@ +# CFML Lucee Benchmarking Test + +### Test Type Implementation Source Code + +* [JSON](src/json.cfm) +* [PLAINTEXT](src/plaintext.cfm) +* [DB](src/db.cfm) +* [QUERY](src/query.cfm) +* [CACHED QUERY](src/cached_query.cfm) +* [UPDATE](src/update.cfm) +* [FORTUNES](src/fortunes.cfm) + +## Important Libraries +The tests were run with: +* [CommandBox](https://commandbox.ortusbooks.com/) +* [ortussolutions/commandbox Docker image](https://hub.docker.com/r/ortussolutions/commandbox/) +* [Lucee Server](https://www.lucee.org/) + +## Test URLs +### JSON + +http://localhost:8080/json.cfm + +### PLAINTEXT + +http://localhost:8080/plaintext.cfm + +### DB + +http://localhost:8080/db.cfm + +### QUERY + +http://localhost:8080/query.cfm?queries= + +### CACHED QUERY + +http://localhost:8080/cached_query.cfm?queries= + +### UPDATE + +http://localhost:8080/update.cfm?queries= + +### FORTUNES + +http://localhost:8080/fortunes.cfm diff --git a/frameworks/CFML/CFML/benchmark_config.json b/frameworks/CFML/CFML/benchmark_config.json new file mode 100644 index 00000000000..7026b016162 --- /dev/null +++ b/frameworks/CFML/CFML/benchmark_config.json @@ -0,0 +1,53 @@ +{ + "framework": "cfml", + "tests": [ + { + "default": { + "json_url": "/json.cfm", + "db_url": "/db.cfm", + "query_url":"/queries.cfm?queries=", + "fortune_url": "/fortunes.cfm", + "plaintext_url": "/plaintext.cfm", + "update_url": "/updates.cfm?queries=", + "port": 8080, + "approach": "Realistic", + "classification": "Platform", + "database": "Postgres", + "framework": "None", + "language": "CFML", + "flavor": "None", + "orm": "raw", + "platform": "None", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "cfml-lucee", + "notes": "Lucee Server", + "versus": "None" + }, + "adobe": { + "json_url": "/json.cfm", + "db_url": "/db.cfm", + "query_url":"/queries.cfm?queries=", + "fortune_url": "/fortunes.cfm", + "plaintext_url": "/plaintext.cfm", + "update_url": "/updates.cfm?queries=", + "port": 8080, + "approach": "Realistic", + "classification": "Platform", + "database": "Postgres", + "framework": "None", + "language": "CFML", + "flavor": "None", + "orm": "raw", + "platform": "None", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "cfml-adobe", + "notes": "Adobe ColdFusion", + "versus": "None" + } + } + ] +} diff --git a/frameworks/CFML/CFML/cfml-adobe.dockerfile b/frameworks/CFML/CFML/cfml-adobe.dockerfile new file mode 100644 index 00000000000..f0c683230a6 --- /dev/null +++ b/frameworks/CFML/CFML/cfml-adobe.dockerfile @@ -0,0 +1,14 @@ +FROM ortussolutions/commandbox:3.2.1 + +COPY ./src/server-adobe.json /app/server.json +COPY ./src/.cfconfig.json /app/.cfconfig.json + +RUN box install commandbox-cfconfig --verbose --force + +RUN ${BUILD_DIR}/util/warmup-server.sh + +RUN export FINALIZE_STARTUP=true;$BUILD_DIR/run.sh;unset FINALIZE_STARTUP + +EXPOSE 8080 + +COPY ./src /app/ \ No newline at end of file diff --git a/frameworks/CFML/CFML/cfml.dockerfile b/frameworks/CFML/CFML/cfml.dockerfile new file mode 100644 index 00000000000..ba90f4960f2 --- /dev/null +++ b/frameworks/CFML/CFML/cfml.dockerfile @@ -0,0 +1,14 @@ +FROM ortussolutions/commandbox:3.2.1 + +COPY ./src/server-lucee.json /app/server.json +COPY ./src/.cfconfig.json /app/.cfconfig.json + +RUN box install commandbox-cfconfig --verbose --force + +RUN ${BUILD_DIR}/util/warmup-server.sh + +RUN export FINALIZE_STARTUP=true;$BUILD_DIR/run.sh;unset FINALIZE_STARTUP + +EXPOSE 8080 + +COPY ./src /app/ \ No newline at end of file diff --git a/frameworks/CFML/CFML/src/.cfconfig.json b/frameworks/CFML/CFML/src/.cfconfig.json new file mode 100644 index 00000000000..08a455de3ff --- /dev/null +++ b/frameworks/CFML/CFML/src/.cfconfig.json @@ -0,0 +1,14 @@ +{ + "datasources":{ + "world":{ + "database":"hello_world", + "dbdriver":"PostgreSQL", + "host":"tfb-database", + "password":"benchmarkdbpass", + "port":"5432", + "username":"benchmarkdbuser" + } + }, + "inspectTemplate":"never", + "maxCFThreads":"512" +} \ No newline at end of file diff --git a/frameworks/CFML/CFML/src/db.cfm b/frameworks/CFML/CFML/src/db.cfm new file mode 100644 index 00000000000..e3bfb6c08e0 --- /dev/null +++ b/frameworks/CFML/CFML/src/db.cfm @@ -0,0 +1,9 @@ + + + + + SELECT id, randomNumber + FROM World + WHERE id = + +#serializeJSON( qry.getRow( 1 ) )# \ No newline at end of file diff --git a/frameworks/CFML/CFML/src/fortunes.cfm b/frameworks/CFML/CFML/src/fortunes.cfm new file mode 100644 index 00000000000..6840fa2efc9 --- /dev/null +++ b/frameworks/CFML/CFML/src/fortunes.cfm @@ -0,0 +1,13 @@ + + + + + SELECT id, message + FROM Fortune + + +compareNoCase(a.message,b.message) )> +Fortunes + +
idmessage
#qry.id##htmlEditFormat( qry.message )#
+
\ No newline at end of file diff --git a/frameworks/CFML/CFML/src/json.cfm b/frameworks/CFML/CFML/src/json.cfm new file mode 100644 index 00000000000..0f752426a4b --- /dev/null +++ b/frameworks/CFML/CFML/src/json.cfm @@ -0,0 +1,4 @@ + + + +#serializeJSON( { 'message' : 'Hello, World!' } )# \ No newline at end of file diff --git a/frameworks/CFML/CFML/src/plaintext.cfm b/frameworks/CFML/CFML/src/plaintext.cfm new file mode 100644 index 00000000000..d809c0f05ce --- /dev/null +++ b/frameworks/CFML/CFML/src/plaintext.cfm @@ -0,0 +1,3 @@ + + +Hello, World! \ No newline at end of file diff --git a/frameworks/CFML/CFML/src/queries.cfm b/frameworks/CFML/CFML/src/queries.cfm new file mode 100644 index 00000000000..59e91cc5586 --- /dev/null +++ b/frameworks/CFML/CFML/src/queries.cfm @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + SELECT id, randomNumber + FROM World + WHERE id = + + + +#serializeJSON( results )# \ No newline at end of file diff --git a/frameworks/CFML/CFML/src/server-adobe.json b/frameworks/CFML/CFML/src/server-adobe.json new file mode 100644 index 00000000000..a033d9307c8 --- /dev/null +++ b/frameworks/CFML/CFML/src/server-adobe.json @@ -0,0 +1,9 @@ +{ + "profile":"none", + "web":{ + "maxRequests":512 + }, + "app":{ + "cfengine":"adobe@2018" + } +} \ No newline at end of file diff --git a/frameworks/CFML/CFML/src/server-lucee.json b/frameworks/CFML/CFML/src/server-lucee.json new file mode 100644 index 00000000000..0c27d5a1413 --- /dev/null +++ b/frameworks/CFML/CFML/src/server-lucee.json @@ -0,0 +1,9 @@ +{ + "profile" : "none", + "web" : { + "maxRequests" : 512 + }, + "app" : { + "cfengine" : "lucee@5.3.8-rc" + } +} \ No newline at end of file diff --git a/frameworks/CFML/CFML/src/updates.cfm b/frameworks/CFML/CFML/src/updates.cfm new file mode 100644 index 00000000000..f7fe981da92 --- /dev/null +++ b/frameworks/CFML/CFML/src/updates.cfm @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + SELECT id, randomNumber + FROM World + WHERE id = + + + + + update World as w set + randomNumber = w2.randomNumber + from (values + #results.reduce( (acc,r)=>{ + acc = acc.listAppend( "(#val( r.id )#, #val( r.randomNumber )#)" ); + return acc; + }, '')# + ) as w2(id,randomNumber) + where w2.id = w.id; + +#serializeJSON( results )# \ No newline at end of file From 3e9e01b2c04795cfc6b6b28512ed3dff142ffe9d Mon Sep 17 00:00:00 2001 From: TreeFrog Framework Date: Tue, 9 Feb 2021 01:14:07 +0900 Subject: [PATCH 20/31] Update TreeFrog Framework to version 1.31 (#6349) * Updated TreeFrog Framework to version 1.31.0. * Added caching tests. * modified to use redis server for cache. * Updated TreeFrog Framework to version 1.31.1. * bugfixes of cached_pqueries(). * bugfixes of cached_pqueries(). * modified config.toml Co-authored-by: AOYAMA Kazuharu <> --- frameworks/C++/treefrog/benchmark_config.json | 31 +++- frameworks/C++/treefrog/config.toml | 23 ++- .../C++/treefrog/config/application.ini | 8 +- frameworks/C++/treefrog/config/cache.ini | 30 ++++ .../controllers/fortunecontroller.cpp | 4 +- .../treefrog/controllers/worldcontroller.cpp | 151 +++++++++++++++++- .../treefrog/controllers/worldcontroller.h | 13 ++ frameworks/C++/treefrog/models/fortune.cpp | 2 +- frameworks/C++/treefrog/models/models.pro | 3 + frameworks/C++/treefrog/models/pworld.cpp | 106 ++++++++++++ frameworks/C++/treefrog/models/pworld.h | 49 ++++++ .../treefrog/models/sqlobjects/pworldobject.h | 31 ++++ frameworks/C++/treefrog/models/world.cpp | 4 +- .../C++/treefrog/treefrog-epoll.dockerfile | 10 +- .../C++/treefrog/treefrog-mongodb.dockerfile | 10 +- .../C++/treefrog/treefrog-postgres.dockerfile | 10 +- frameworks/C++/treefrog/treefrog.dockerfile | 10 +- 17 files changed, 462 insertions(+), 33 deletions(-) create mode 100644 frameworks/C++/treefrog/config/cache.ini create mode 100644 frameworks/C++/treefrog/models/pworld.cpp create mode 100644 frameworks/C++/treefrog/models/pworld.h create mode 100644 frameworks/C++/treefrog/models/sqlobjects/pworldobject.h diff --git a/frameworks/C++/treefrog/benchmark_config.json b/frameworks/C++/treefrog/benchmark_config.json index b35e935ccfe..8ed650b51f9 100644 --- a/frameworks/C++/treefrog/benchmark_config.json +++ b/frameworks/C++/treefrog/benchmark_config.json @@ -8,6 +8,7 @@ "fortune_url": "/fortune/index", "update_url": "/world/updates/", "plaintext_url": "/world/plain", + "cached_query_url": "/world/cached_queries/", "port": 8080, "approach": "Realistic", "classification": "Fullstack", @@ -24,16 +25,41 @@ "versus": "" }, "postgres": { + "json_url": "/json/json", + "db_url": "/world/prandom", + "query_url": "/world/pqueries/", + "fortune_url": "/fortune/index", + "update_url": "/world/pupdates/", + "plaintext_url": "/world/plain", + "cached_query_url": "/world/cached_pqueries/", + "port": 8080, + "approach": "Realistic", + "classification": "Fullstack", + "database": "Postgres", + "framework": "treefrog", + "language": "C++", + "flavor": "None", + "orm": "Micro", + "platform": "None", + "webserver": "None", + "os": "Linux", + "database_os": "Linux", + "display_name": "treefrog-postgres", + "notes": "", + "versus": "" + }, + "epoll": { "json_url": "/json/json", "db_url": "/world/random", "query_url": "/world/queries/", "fortune_url": "/fortune/index", "update_url": "/world/updates/", "plaintext_url": "/world/plain", + "cached_query_url": "/world/cached_queries/", "port": 8080, "approach": "Realistic", "classification": "Fullstack", - "database": "Postgres", + "database": "MySQL", "framework": "treefrog", "language": "C++", "flavor": "None", @@ -42,7 +68,7 @@ "webserver": "None", "os": "Linux", "database_os": "Linux", - "display_name": "treefrog-postgres", + "display_name": "treefrog-epoll", "notes": "", "versus": "" }, @@ -53,6 +79,7 @@ "fortune_url": "/fortune/mindex", "update_url": "/world/mupdates/", "plaintext_url": "/world/plain", + "cached_query_url": "/world/cached_mqueries/", "port": 8080, "approach": "Realistic", "classification": "Fullstack", diff --git a/frameworks/C++/treefrog/config.toml b/frameworks/C++/treefrog/config.toml index 264f8d1d405..e8b1026eba0 100644 --- a/frameworks/C++/treefrog/config.toml +++ b/frameworks/C++/treefrog/config.toml @@ -8,6 +8,7 @@ urls.db = "/world/random" urls.query = "/world/queries/" urls.update = "/world/updates/" urls.fortune = "/fortune/index" +urls.cached_query = "/world/cached_queries/" approach = "Realistic" classification = "Fullstack" database = "MySQL" @@ -25,6 +26,7 @@ urls.db = "/world/mrandom" urls.query = "/world/mqueries/" urls.update = "/world/mupdates/" urls.fortune = "/fortune/mindex" +urls.cached_query = "/world/cached_mqueries/" approach = "Realistic" classification = "Fullstack" database = "MongoDB" @@ -38,13 +40,32 @@ versus = "treefrog" [postgres] urls.plaintext = "/world/plain" urls.json = "/json/json" +urls.db = "/world/prandom" +urls.query = "/world/pqueries/" +urls.update = "/world/pupdates/" +urls.fortune = "/fortune/index" +urls.cached_query = "/world/cached_pqueries/" +approach = "Realistic" +classification = "Fullstack" +database = "Postgres" +database_os = "Linux" +os = "Linux" +orm = "Micro" +platform = "None" +webserver = "None" +versus = "" + +[epoll] +urls.plaintext = "/world/plain" +urls.json = "/json/json" urls.db = "/world/random" urls.query = "/world/queries/" urls.update = "/world/updates/" urls.fortune = "/fortune/index" +urls.cached_query = "/world/cached_queries/" approach = "Realistic" classification = "Fullstack" -database = "Postgres" +database = "MySQL" database_os = "Linux" os = "Linux" orm = "Micro" diff --git a/frameworks/C++/treefrog/config/application.ini b/frameworks/C++/treefrog/config/application.ini index 530d8391c2e..ba913471063 100644 --- a/frameworks/C++/treefrog/config/application.ini +++ b/frameworks/C++/treefrog/config/application.ini @@ -242,16 +242,16 @@ ActionMailer.smtp.DelayedDelivery=false # Specify the settings file to enable the cache module. # Comment out the following line. -#Cache.SettingsFile=cache.ini +Cache.SettingsFile=cache.ini # Specify the cache backend, such as 'sqlite', 'mongodb' # or 'redis'. -Cache.Backend=sqlite +Cache.Backend=redis # Probability of starting garbage collection (GC) for cache. # If 100 is specified, GC will be started at a rate of once per 100 # sets. If 0 is specified, the GC never starts. -Cache.GcProbability=100 +Cache.GcProbability=10000 # If true, enable LZ4 compression when storing data. -Cache.EnableCompression=true +Cache.EnableCompression=no diff --git a/frameworks/C++/treefrog/config/cache.ini b/frameworks/C++/treefrog/config/cache.ini new file mode 100644 index 00000000000..c2cb0b451f0 --- /dev/null +++ b/frameworks/C++/treefrog/config/cache.ini @@ -0,0 +1,30 @@ +# +# Cache settings +# + +[sqlite] +DatabaseName=tmp/cachedb +HostName= +Port= +UserName= +Password= +ConnectOptions= +PostOpenStatements=PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000; PRAGMA synchronous=NORMAL; VACUUM; + +[redis] +DatabaseName= +HostName=localhost +Port= +UserName= +Password= +ConnectOptions= +PostOpenStatements=SELECT 1; + +[mongodb] +DatabaseName=mdb +HostName=localhost +Port= +UserName= +Password= +ConnectOptions= +PostOpenStatements= diff --git a/frameworks/C++/treefrog/controllers/fortunecontroller.cpp b/frameworks/C++/treefrog/controllers/fortunecontroller.cpp index 55e3ca8c3bd..859260daf1e 100644 --- a/frameworks/C++/treefrog/controllers/fortunecontroller.cpp +++ b/frameworks/C++/treefrog/controllers/fortunecontroller.cpp @@ -20,7 +20,7 @@ void FortuneController::index() fortune.setMessage(QStringLiteral("Additional fortune added at request time.")); fortuneList << fortune; // Sort - qSort(fortuneList.begin(), fortuneList.end(), caseSensitiveLessThan); + std::sort(fortuneList.begin(), fortuneList.end(), caseSensitiveLessThan); texport(fortuneList); render(); } @@ -32,7 +32,7 @@ void FortuneController::mindex() fortune.setMessage(QStringLiteral("Additional fortune added at request time.")); fortuneList << fortune; // Sort - qSort(fortuneList.begin(), fortuneList.end(), caseSensitiveMngFortuneLessThan); + std::sort(fortuneList.begin(), fortuneList.end(), caseSensitiveMngFortuneLessThan); texport(fortuneList); render("mindex"); } diff --git a/frameworks/C++/treefrog/controllers/worldcontroller.cpp b/frameworks/C++/treefrog/controllers/worldcontroller.cpp index 8f3735d902d..ea5a74b1026 100644 --- a/frameworks/C++/treefrog/controllers/worldcontroller.cpp +++ b/frameworks/C++/treefrog/controllers/worldcontroller.cpp @@ -1,6 +1,8 @@ #include "worldcontroller.h" #include "world.h" +#include "pworld.h" #include "mngworld.h" +#include void WorldController::index() @@ -31,7 +33,7 @@ void WorldController::queries() void WorldController::queries(const QString &num) { QVariantList worlds; - int d = qMin(qMax(num.toInt(), 1), 500); + int d = std::min(std::max(num.toInt(), 1), 500); for (int i = 0; i < d; ++i) { int id = Tf::random(1, 10000); @@ -40,6 +42,37 @@ void WorldController::queries(const QString &num) renderJson(worlds); } +void WorldController::cached_queries() +{ + cached_queries("1"); +} + +void WorldController::cached_queries(const QString &num) +{ + constexpr int SECONDS = 60 * 10; // cache time + QVariantList worlds; + QVariantMap world; + int d = std::min(std::max(num.toInt(), 1), 500); + + for (int i = 0; i < d; ++i) { + int id = Tf::random(1, 10000); + auto key = QByteArray::number(id); + auto randomNumber = Tf::cache()->get(key); // Gets from cache + + if (randomNumber.isEmpty()) { + auto w = World::get(id); + worlds << w.toVariantMap(); + // Cache the value + Tf::cache()->set(key, QByteArray::number(w.randomNumber()), SECONDS); + } else { + world.insert("id", id); + world.insert("randomNumber", randomNumber.toInt()); + worlds << world; + } + } + renderJson(worlds); +} + void WorldController::random() { int id = Tf::random(1, 10000); @@ -129,7 +162,7 @@ void WorldController::updates() void WorldController::updates(const QString &num) { QVariantList worlds; - int d = qMin(qMax(num.toInt(), 1), 500); + int d = std::min(std::max(num.toInt(), 1), 500); World world; for (int i = 0; i < d; ++i) { @@ -153,10 +186,87 @@ void WorldController::remove(const QString &pk) redirect(urla("index")); } +/* + * PostgreSQL + */ +void WorldController::prandom() +{ + int id = Tf::random(1, 10000); + PWorld world = PWorld::get(id); + renderJson(world.toVariantMap()); +} + +void WorldController::pqueries() +{ + pqueries("1"); +} + +void WorldController::pqueries(const QString &num) +{ + QVariantList worlds; + int d = std::min(std::max(num.toInt(), 1), 500); + + for (int i = 0; i < d; ++i) { + int id = Tf::random(1, 10000); + worlds << PWorld::get(id).toVariantMap(); + } + renderJson(worlds); +} + +void WorldController::cached_pqueries() +{ + cached_pqueries("1"); +} + +void WorldController::cached_pqueries(const QString &num) +{ + constexpr int SECONDS = 60 * 10; // cache time + QVariantList worlds; + QVariantMap world; + int d = std::min(std::max(num.toInt(), 1), 500); + + for (int i = 0; i < d; ++i) { + int id = Tf::random(1, 10000); + auto key = QByteArray::number(id); + auto randomNumber = Tf::cache()->get(key); // Gets from cache + + if (randomNumber.isEmpty()) { + auto w = PWorld::get(id); + worlds << w.toVariantMap(); + // Cache the value + Tf::cache()->set(key, QByteArray::number(w.randomNumber()), SECONDS); + } else { + world.insert("id", id); + world.insert("randomnumber", randomNumber.toInt()); + worlds << world; + } + } + renderJson(worlds); +} + +void WorldController::pupdates(const QString &num) +{ + QVariantList worlds; + int d = std::min(std::max(num.toInt(), 1), 500); + PWorld world; + + for (int i = 0; i < d; ++i) { + int id = Tf::random(1, 10000); + world = PWorld::get(id); + world.setRandomNumber( Tf::random(1, 10000) ); + world.update(); + worlds << world.toVariantMap(); + } + renderJson(worlds); +} +void WorldController::pupdates() +{ + pupdates("1"); +} /* - MongoDB + * MongoDB */ void WorldController::mqueries() { @@ -166,7 +276,7 @@ void WorldController::mqueries() void WorldController::mqueries(const QString &num) { QVariantList worlds; - int d = qMin(qMax(num.toInt(), 1), 500); + int d = std::min(std::max(num.toInt(), 1), 500); for (int i = 0; i < d; ++i) { QString id = QString::number(Tf::random(1, 10000)); @@ -175,6 +285,37 @@ void WorldController::mqueries(const QString &num) renderJson(worlds); } +void WorldController::cached_mqueries() +{ + cached_mqueries("1"); +} + +void WorldController::cached_mqueries(const QString &num) +{ + constexpr int SECONDS = 60 * 10; // cache time + QVariantList worlds; + QVariantMap world; + int d = std::min(std::max(num.toInt(), 1), 500); + + for (int i = 0; i < d; ++i) { + int id = Tf::random(1, 10000); + QByteArray key = QByteArray::number(id); + auto randomNumber = Tf::cache()->get(key); // Gets from cache + + if (randomNumber.isEmpty()) { + auto w = MngWorld::get(key); + worlds << w.toVariantMap(); + // Cache the value + Tf::cache()->set(key, QByteArray::number(w.randomNumber()), SECONDS); + } else { + world.insert("id", id); + world.insert("randomNumber", randomNumber.toInt()); + worlds << world; + } + } + renderJson(worlds); +} + void WorldController::mrandom() { QString id = QString::number(Tf::random(1, 10000)); @@ -190,7 +331,7 @@ void WorldController::mupdates() void WorldController::mupdates(const QString &num) { QVariantList worlds; - int d = qMin(qMax(num.toInt(), 1), 500); + int d = std::min(std::max(num.toInt(), 1), 500); MngWorld world; for (int i = 0; i < d; ++i) { diff --git a/frameworks/C++/treefrog/controllers/worldcontroller.h b/frameworks/C++/treefrog/controllers/worldcontroller.h index 90167b71205..a5860c672fe 100644 --- a/frameworks/C++/treefrog/controllers/worldcontroller.h +++ b/frameworks/C++/treefrog/controllers/worldcontroller.h @@ -18,6 +18,8 @@ public slots: void show(const QString &pk); void queries(); void queries(const QString &num); + void cached_queries(); + void cached_queries(const QString &num); void random(); void entry(); void create(); @@ -27,9 +29,20 @@ public slots: void updates(); void remove(const QString &pk); + // PostgreSQL + void prandom(); + void pqueries(); + void pqueries(const QString &num); + void cached_pqueries(); + void cached_pqueries(const QString &num); + void pupdates(const QString &num); + void pupdates(); + // MongoDB void mqueries(); void mqueries(const QString &num); + void cached_mqueries(); + void cached_mqueries(const QString &num); void mrandom(); void mupdates(const QString &num); void mupdates(); diff --git a/frameworks/C++/treefrog/models/fortune.cpp b/frameworks/C++/treefrog/models/fortune.cpp index de0fde7c8a5..22da64d8de0 100644 --- a/frameworks/C++/treefrog/models/fortune.cpp +++ b/frameworks/C++/treefrog/models/fortune.cpp @@ -78,7 +78,7 @@ int Fortune::count() QList Fortune::getAll() { TSqlQueryORMapper mapper; - mapper.prepare(QStringLiteral("SELECT * from Fortune")); + mapper.prepare(QStringLiteral("SELECT * from fortune")); QList fortunes; if (mapper.exec()) { diff --git a/frameworks/C++/treefrog/models/models.pro b/frameworks/C++/treefrog/models/models.pro index 137c545288c..e470f1bc6aa 100644 --- a/frameworks/C++/treefrog/models/models.pro +++ b/frameworks/C++/treefrog/models/models.pro @@ -17,6 +17,9 @@ SOURCES += fortune.cpp HEADERS += sqlobjects/worldobject.h HEADERS += world.h SOURCES += world.cpp +HEADERS += sqlobjects/pworldobject.h +HEADERS += pworld.h +SOURCES += pworld.cpp HEADERS += mongoobjects/mngworldobject.h HEADERS += mngworld.h SOURCES += mngworld.cpp diff --git a/frameworks/C++/treefrog/models/pworld.cpp b/frameworks/C++/treefrog/models/pworld.cpp new file mode 100644 index 00000000000..748086cbe1c --- /dev/null +++ b/frameworks/C++/treefrog/models/pworld.cpp @@ -0,0 +1,106 @@ +#include +#include "pworld.h" +#include "pworldobject.h" + +// +// World class for PostgreSQL +// + +PWorld::PWorld() + : TAbstractModel(), d(new PWorldObject) +{ + d->id = 0; + d->randomnumber = 0; +} + +PWorld::PWorld(const PWorld &other) + : TAbstractModel(), d(other.d) +{ } + +PWorld::PWorld(const PWorldObject &object) + : TAbstractModel(), d(new PWorldObject(object)) +{ } + +PWorld::~PWorld() +{ + // If the reference count becomes 0, + // the shared data object 'PWorldObject' is deleted. +} + +uint PWorld::id() const +{ + return d->id; +} + +int PWorld::randomNumber() const +{ + return d->randomnumber; +} + +void PWorld::setRandomNumber(int randomNumber) +{ + d->randomnumber = randomNumber; +} + +PWorld &PWorld::operator=(const PWorld &other) +{ + d = other.d; // increments the reference count of the data + return *this; +} + +bool PWorld::update() +{ + TSqlQueryORMapper mapper; + mapper.prepare(QStringLiteral("UPDATE world SET randomnumber=? WHERE id=?")); + mapper.addBind(randomNumber()).addBind(id()); + return mapper.exec(); +} + +PWorld PWorld::create(int randomNumber) +{ + PWorldObject obj; + obj.randomnumber = randomNumber; + if (!obj.create()) { + return PWorld(); + } + return PWorld(obj); +} + +PWorld PWorld::create(const QVariantMap &values) +{ + PWorld model; + model.setProperties(values); + if (!model.d->create()) { + model.d->clear(); + } + return model; +} + +PWorld PWorld::get(uint id) +{ + TSqlQueryORMapper mapper; + mapper.prepare(QStringLiteral("SELECT * from world WHERE id=?")); + mapper.addBind(id); + return PWorld(mapper.execFirst()); +} + +int PWorld::count() +{ + TSqlORMapper mapper; + return mapper.findCount(); +} + +QList PWorld::getAll() +{ + return tfGetModelListByCriteria(TCriteria()); +} + +TModelObject *PWorld::modelData() +{ + return d.data(); +} + +const TModelObject *PWorld::modelData() const +{ + return d.data(); +} diff --git a/frameworks/C++/treefrog/models/pworld.h b/frameworks/C++/treefrog/models/pworld.h new file mode 100644 index 00000000000..0d2427093e5 --- /dev/null +++ b/frameworks/C++/treefrog/models/pworld.h @@ -0,0 +1,49 @@ +#ifndef PWORLD_H +#define PWORLD_H + +#include +#include +#include +#include +#include +#include + +class TModelObject; +class PWorldObject; + + +class T_MODEL_EXPORT PWorld : public TAbstractModel +{ +public: + PWorld(); + PWorld(const PWorld &other); + PWorld(const PWorldObject &object); + ~PWorld(); + + uint id() const; + int randomNumber() const; + void setRandomNumber(int randomNumber); + PWorld &operator=(const PWorld &other); + + bool create() { return TAbstractModel::create(); } + bool update(); + bool save() { return TAbstractModel::save(); } + bool remove() { return TAbstractModel::remove(); } + + static PWorld create(int randomNumber); + static PWorld create(const QVariantMap &values); + static PWorld get(uint id); + static int count(); + static QList getAll(); + +private: + QSharedDataPointer d; + + TModelObject *modelData(); + const TModelObject *modelData() const; +}; + +Q_DECLARE_METATYPE(PWorld) +Q_DECLARE_METATYPE(QList) + +#endif // PWORLD_H diff --git a/frameworks/C++/treefrog/models/sqlobjects/pworldobject.h b/frameworks/C++/treefrog/models/sqlobjects/pworldobject.h new file mode 100644 index 00000000000..945d5ebbf65 --- /dev/null +++ b/frameworks/C++/treefrog/models/sqlobjects/pworldobject.h @@ -0,0 +1,31 @@ +#ifndef PWORLDOBJECT_H +#define PWORLDOBJECT_H + +#include +#include + + +class T_MODEL_EXPORT PWorldObject : public TSqlObject, public QSharedData +{ +public: + uint id {0}; + int randomnumber {0}; + + enum PropertyIndex { + Id = 0, + Randomnumber, + }; + + int primaryKeyIndex() const override { return Id; } + int autoValueIndex() const override { return Id; } + QString tableName() const override { return QStringLiteral("world"); } + +private: /*** Don't modify below this line ***/ + Q_OBJECT + Q_PROPERTY(uint id READ getid WRITE setid) + T_DEFINE_PROPERTY(uint, id) + Q_PROPERTY(int randomnumber READ getrandomnumber WRITE setrandomnumber) + T_DEFINE_PROPERTY(int, randomnumber) +}; + +#endif // PWORLDOBJECT_H diff --git a/frameworks/C++/treefrog/models/world.cpp b/frameworks/C++/treefrog/models/world.cpp index 85878452a22..13d65a7c97f 100644 --- a/frameworks/C++/treefrog/models/world.cpp +++ b/frameworks/C++/treefrog/models/world.cpp @@ -47,7 +47,7 @@ World &World::operator=(const World &other) bool World::update() { TSqlQueryORMapper mapper; - mapper.prepare(QStringLiteral("UPDATE World SET randomNumber=? WHERE id=?")); + mapper.prepare(QStringLiteral("UPDATE world SET randomNumber=? WHERE id=?")); mapper.addBind(randomNumber()).addBind(id()); return mapper.exec(); } @@ -75,7 +75,7 @@ World World::create(const QVariantMap &values) World World::get(uint id) { TSqlQueryORMapper mapper; - mapper.prepare(QStringLiteral("SELECT * from World WHERE id=?")); + mapper.prepare(QStringLiteral("SELECT * from world WHERE id=?")); mapper.addBind(id); return World(mapper.execFirst()); } diff --git a/frameworks/C++/treefrog/treefrog-epoll.dockerfile b/frameworks/C++/treefrog/treefrog-epoll.dockerfile index 7364ba0af69..1b7e4ee8d9d 100644 --- a/frameworks/C++/treefrog/treefrog-epoll.dockerfile +++ b/frameworks/C++/treefrog/treefrog-epoll.dockerfile @@ -1,14 +1,15 @@ -FROM buildpack-deps:bionic +FROM buildpack-deps:focal ENV DEBIAN_FRONTEND noninteractive ENV DEBCONF_NOWARNINGS yes -ENV TFVER=1.30.0 +ENV TFVER=1.31.1 RUN apt-get update -yqq && apt-get upgrade -yq && apt-get install -yqq --no-install-recommends \ software-properties-common unzip wget make cmake gcc clang libjemalloc-dev qt5-qmake qt5-default qtbase5-dev \ qtbase5-dev-tools libqt5sql5 libqt5sql5-mysql libqt5sql5-psql libqt5qml5 libqt5xml5 \ qtdeclarative5-dev libqt5quick5 libqt5quickparticles5 libqt5gui5 libqt5printsupport5 \ - libqt5widgets5 libqt5opengl5-dev libqt5quicktest5 libqt5sql5-sqlite libsqlite3-dev libmongoc-dev libbson-dev + libqt5widgets5 libqt5opengl5-dev libqt5quicktest5 libqt5sql5-sqlite libsqlite3-dev libmongoc-dev libbson-dev \ + redis-server WORKDIR /usr/src RUN wget -q https://github.com/treefrogframework/treefrog-framework/archive/v${TFVER}.tar.gz @@ -36,4 +37,5 @@ RUN sed -i 's|MultiProcessingModule=.*|MultiProcessingModule=epoll|g' config/app EXPOSE 8080 # 3. Start TreeFrog -CMD treefrog /workspace +CMD service redis-server start && \ + treefrog /workspace \ No newline at end of file diff --git a/frameworks/C++/treefrog/treefrog-mongodb.dockerfile b/frameworks/C++/treefrog/treefrog-mongodb.dockerfile index b77db2f3f84..900e41c26a4 100644 --- a/frameworks/C++/treefrog/treefrog-mongodb.dockerfile +++ b/frameworks/C++/treefrog/treefrog-mongodb.dockerfile @@ -1,14 +1,15 @@ -FROM buildpack-deps:bionic +FROM buildpack-deps:focal ENV DEBIAN_FRONTEND noninteractive ENV DEBCONF_NOWARNINGS yes -ENV TFVER=1.30.0 +ENV TFVER=1.31.1 RUN apt-get update -yqq && apt-get upgrade -yq && apt-get install -yqq --no-install-recommends \ software-properties-common unzip wget make cmake gcc clang libjemalloc-dev qt5-qmake qt5-default qtbase5-dev \ qtbase5-dev-tools libqt5sql5 libqt5sql5-mysql libqt5sql5-psql libqt5qml5 libqt5xml5 \ qtdeclarative5-dev libqt5quick5 libqt5quickparticles5 libqt5gui5 libqt5printsupport5 \ - libqt5widgets5 libqt5opengl5-dev libqt5quicktest5 libqt5sql5-sqlite libsqlite3-dev libmongoc-dev libbson-dev + libqt5widgets5 libqt5opengl5-dev libqt5quicktest5 libqt5sql5-sqlite libsqlite3-dev libmongoc-dev libbson-dev \ + redis-server WORKDIR /usr/src RUN wget -q https://github.com/treefrogframework/treefrog-framework/archive/v${TFVER}.tar.gz @@ -36,4 +37,5 @@ RUN sed -i 's|MultiProcessingModule=.*|MultiProcessingModule=thread|g' config/ap EXPOSE 8080 # 3. Start TreeFrog -CMD treefrog /workspace +CMD service redis-server start && \ + treefrog /workspace diff --git a/frameworks/C++/treefrog/treefrog-postgres.dockerfile b/frameworks/C++/treefrog/treefrog-postgres.dockerfile index c2be9430d2d..b612e191fa9 100644 --- a/frameworks/C++/treefrog/treefrog-postgres.dockerfile +++ b/frameworks/C++/treefrog/treefrog-postgres.dockerfile @@ -1,14 +1,15 @@ -FROM buildpack-deps:bionic +FROM buildpack-deps:focal ENV DEBIAN_FRONTEND noninteractive ENV DEBCONF_NOWARNINGS yes -ENV TFVER=1.30.0 +ENV TFVER=1.31.1 RUN apt-get update -yqq && apt-get upgrade -yq && apt-get install -yqq --no-install-recommends \ software-properties-common unzip wget make cmake gcc clang libjemalloc-dev qt5-qmake qt5-default qtbase5-dev \ qtbase5-dev-tools libqt5sql5 libqt5sql5-mysql libqt5sql5-psql libqt5qml5 libqt5xml5 \ qtdeclarative5-dev libqt5quick5 libqt5quickparticles5 libqt5gui5 libqt5printsupport5 \ - libqt5widgets5 libqt5opengl5-dev libqt5quicktest5 libqt5sql5-sqlite libsqlite3-dev libmongoc-dev libbson-dev + libqt5widgets5 libqt5opengl5-dev libqt5quicktest5 libqt5sql5-sqlite libsqlite3-dev libmongoc-dev libbson-dev \ + redis-server WORKDIR /usr/src RUN wget -q https://github.com/treefrogframework/treefrog-framework/archive/v${TFVER}.tar.gz @@ -36,4 +37,5 @@ RUN sed -i 's|MultiProcessingModule=.*|MultiProcessingModule=thread|g' config/ap EXPOSE 8080 # 3. Start TreeFrog -CMD treefrog /workspace +CMD service redis-server start && \ + treefrog /workspace diff --git a/frameworks/C++/treefrog/treefrog.dockerfile b/frameworks/C++/treefrog/treefrog.dockerfile index b77db2f3f84..900e41c26a4 100644 --- a/frameworks/C++/treefrog/treefrog.dockerfile +++ b/frameworks/C++/treefrog/treefrog.dockerfile @@ -1,14 +1,15 @@ -FROM buildpack-deps:bionic +FROM buildpack-deps:focal ENV DEBIAN_FRONTEND noninteractive ENV DEBCONF_NOWARNINGS yes -ENV TFVER=1.30.0 +ENV TFVER=1.31.1 RUN apt-get update -yqq && apt-get upgrade -yq && apt-get install -yqq --no-install-recommends \ software-properties-common unzip wget make cmake gcc clang libjemalloc-dev qt5-qmake qt5-default qtbase5-dev \ qtbase5-dev-tools libqt5sql5 libqt5sql5-mysql libqt5sql5-psql libqt5qml5 libqt5xml5 \ qtdeclarative5-dev libqt5quick5 libqt5quickparticles5 libqt5gui5 libqt5printsupport5 \ - libqt5widgets5 libqt5opengl5-dev libqt5quicktest5 libqt5sql5-sqlite libsqlite3-dev libmongoc-dev libbson-dev + libqt5widgets5 libqt5opengl5-dev libqt5quicktest5 libqt5sql5-sqlite libsqlite3-dev libmongoc-dev libbson-dev \ + redis-server WORKDIR /usr/src RUN wget -q https://github.com/treefrogframework/treefrog-framework/archive/v${TFVER}.tar.gz @@ -36,4 +37,5 @@ RUN sed -i 's|MultiProcessingModule=.*|MultiProcessingModule=thread|g' config/ap EXPOSE 8080 # 3. Start TreeFrog -CMD treefrog /workspace +CMD service redis-server start && \ + treefrog /workspace From 2348cc6c3a11f29fcfa1ae2086c1da1b72011a21 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 9 Feb 2021 00:15:01 +0800 Subject: [PATCH 21/31] [c#/beetlex] update 1.6.5.36-beta (#6344) * update beetlex 1.4.3 update beetlex 1.4.3 * docker add COMPlus_ReadyToRun variable update beetlex * update beetlex, enabled thread queue * beetlex framework add db and queries cases * add db code * change result json data * update query url * beetlex framework add fortunes cases * change Content-Type * add beetlex core cases * fix queries cases * update config * change try readline * update benchmark config * Update README.md * Update README.md * change versus property * beetlex-core update .net core to v3.0 * change beetlex-core project file * beetlex update raw db class * beetlex update raw db * beetlex debug plaintext * change debug docker file * update beetlex to 1.4.0 * update * beetlex update core 3.1 * [c#/beetlex] add updates cases * [c#/beetlex] change Server: TFB, change custom connection pool, add update docker * fix errors * change pool init * change connection pool maxsize * fix fortunes errors * clear DBRaw _connectionString value. * [c#beetlex] change update dbconnection pool size * [c#/beetlex] udpate spanjson to v3.0.1, Npgsql v5.0.0 * [c#/beetlex] add caching sample * set connectionstring multiplexing * remove connection multiplexing setting * [c#/beetlex]change NpgsqlParameter to NpgsqlParameter * [c#/beetlex] update dbraw * [c#/beetlex] change connection string * [c#/beetlex] add fortunes cases to core-updb * update beetlex 1.5.6 * update 5.0.0-alpha1 * update docker file * Enabled IOQueues * Set IOQueues debug mode * update * [c#/beetlex] udpate to v1.6.0.1-beta * update pg drive * [c#/beetlex] update to beetlex v1.6.3 and support pipelining * set options * [c#/beetlex] Optimized actions * [c#/beetlex] update plaintext * Bump ServiceStack in /frameworks/CSharp/servicestack/src/SelfHost Bumps [ServiceStack](https://github.com/ServiceStack/ServiceStack) from 3.9.59 to 5.9.2. - [Release notes](https://github.com/ServiceStack/ServiceStack/releases) - [Commits](https://github.com/ServiceStack/ServiceStack/commits/v5.9.2) Signed-off-by: dependabot[bot] * [c#/beetlex] change plaintext buffer size, optimize fortunes. * [c#/beetlex] update v1.6.5,use System.Text.Json * change docker files * update beetlex 1.6.5.2 * [c#/beetlex] update v1.6.5.3-beta * [c#/beetlex] update 1.6.5.36-beta * update * update json Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../beetlex/PlatformBenchmarks/DBRaw.cs | 2 +- .../beetlex/PlatformBenchmarks/HttpHandler.cs | 30 ++++++++++--------- .../PlatformBenchmarks.csproj | 4 +-- .../beetlex/PlatformBenchmarks/RequestData.cs | 2 +- .../CSharp/beetlex/PlatformBenchmarks/db.cs | 9 +++++- .../CSharp/beetlex/PlatformBenchmarks/json.cs | 10 +++++-- .../beetlex/PlatformBenchmarks/plaintext.cs | 4 +-- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs index 60a922bf12b..55008603979 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/DBRaw.cs @@ -167,7 +167,7 @@ public async Task> LoadFortunesRows() { await db.OpenAsync(); FortuneCommand.Connection = db; - using (var rdr = await FortuneCommand.ExecuteReaderAsync(CommandBehavior.Default)) + using (var rdr = await FortuneCommand.ExecuteReaderAsync()) { while (await rdr.ReadAsync()) { diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.cs index 247cd75b74c..e0ee9ba0481 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/HttpHandler.cs @@ -99,30 +99,34 @@ 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.IndexOf(_line.Data); + var result = pipeStream.IndexOfLine(); while (result.End != null) { if (result.Length == 2) { - if (token.CurrentRequest != null) + pipeStream.ReadFree(result.Length); + if (Program.Debug) { - token.Requests.Enqueue(token.CurrentRequest); - token.CurrentRequest = null; - token.ThreadDispatcher.Enqueue(token); + if (token.CurrentRequest != null) + { + token.Requests.Enqueue(token.CurrentRequest); + token.CurrentRequest = null; + token.ThreadDispatcher.Enqueue(token); + } } - pipeStream.ReadFree(result.Length); + else + { + OnStartRequest(token.CurrentRequest, e.Session, token, pipeStream); + } + } else { if (token.CurrentRequest == null) { var request = new RequestData(); - byte[] buffer = null; - if (Program.Debug) - buffer = new byte[result.Length]; - else - buffer = System.Buffers.ArrayPool.Shared.Rent(result.Length); + buffer = new byte[result.Length]; pipeStream.Read(buffer, 0, result.Length); request.Data = new ArraySegment(buffer, 0, result.Length); AnalysisAction(request); @@ -143,7 +147,7 @@ public override void SessionReceive(IServer server, SessionReceiveEventArgs e) } } if (pipeStream.Length > 0) - result = pipeStream.IndexOf(_line.Data); + result = pipeStream.IndexOfLine(); else break; } @@ -287,8 +291,6 @@ public virtual async Task OnStartRequest(RequestData data, ISession session, Htt OnWriteContentLength(stream, token); await Default(stream, token, session); } - if (!Program.Debug) - data.Dispose(); } diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj b/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj index 37251f29352..0c71fee173f 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/PlatformBenchmarks.csproj @@ -8,10 +8,10 @@ - + - + diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/RequestData.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/RequestData.cs index 4cc6e58ee1e..ab5b8080aee 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/RequestData.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/RequestData.cs @@ -18,7 +18,7 @@ public ReadOnlySpan GetSpan() public void Dispose() { - System.Buffers.ArrayPool.Shared.Return(Data.Array); + //System.Buffers.ArrayPool.Shared.Return(Data.Array); } public string QueryString { get; set; } diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs index 639fbd7d531..ce3d7e42ca5 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/db.cs @@ -16,7 +16,14 @@ public async ValueTask db(PipeStream stream, HttpToken token, ISession session) try { var data = await token.Db.LoadSingleQueryRow(); - System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), data, SerializerOptions); + if (Program.Debug) + { + await JsonSerializer.NonGeneric.Utf8.SerializeAsync(data, stream); + } + else + { + System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), data, SerializerOptions); + } } catch (Exception e_) { diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs index 785d6b021e3..9319771ef47 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/json.cs @@ -27,8 +27,14 @@ private static Utf8JsonWriter GetUtf8JsonWriter(PipeStream stream, HttpToken tok public ValueTask Json(PipeStream stream, HttpToken token, ISession session) { - - System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), new JsonMessage { message = "Hello, World!" }, SerializerOptions); + if (Program.Debug) + { + System.Text.Json.JsonSerializer.Serialize(GetUtf8JsonWriter(stream, token), new JsonMessage { message = "Hello, World!" }, SerializerOptions); + } + else + { + SpanJson.JsonSerializer.NonGeneric.Utf8.SerializeAsync(new JsonMessage { message = "Hello, World!" }, stream); + } OnCompleted(stream, session, token); return ValueTask.CompletedTask; } diff --git a/frameworks/CSharp/beetlex/PlatformBenchmarks/plaintext.cs b/frameworks/CSharp/beetlex/PlatformBenchmarks/plaintext.cs index e8d01c29989..623c4edddac 100644 --- a/frameworks/CSharp/beetlex/PlatformBenchmarks/plaintext.cs +++ b/frameworks/CSharp/beetlex/PlatformBenchmarks/plaintext.cs @@ -9,11 +9,11 @@ namespace PlatformBenchmarks { public partial class HttpHandler { - public Task Plaintext(PipeStream stream, HttpToken token, ISession session) + public ValueTask Plaintext(PipeStream stream, HttpToken token, ISession session) { stream.Write(_result_plaintext.Data, 0, _result_plaintext.Length); OnCompleted(stream, session, token); - return Task.CompletedTask; + return ValueTask.CompletedTask; } } } From f34037cef59727c88939b6b690704ac213443a67 Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Tue, 9 Feb 2021 00:18:06 +0800 Subject: [PATCH 22/31] Update application.xml (#6348) * Update application.xml * Update Service.java --- frameworks/Java/redkale/conf/application.xml | 17 ++++++++--------- .../java/org/redkalex/benchmark/Service.java | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/frameworks/Java/redkale/conf/application.xml b/frameworks/Java/redkale/conf/application.xml index 4bfbe72377f..ca1cc5facc5 100644 --- a/frameworks/Java/redkale/conf/application.xml +++ b/frameworks/Java/redkale/conf/application.xml @@ -4,24 +4,23 @@ - - + + + - - + - - - + + + - - + diff --git a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java index 5db458488a7..3523b7adcd5 100644 --- a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java +++ b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java @@ -29,7 +29,7 @@ public class Service extends AbstractService { @Override public void init(AnyValue conf) { - source.queryList(CachedWorld.class); + //source.queryList(CachedWorld.class); } @RestMapping(name = "json") From 2b9976bc52666cabad9644cb7871c798aa3c8945 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Feb 2021 09:12:42 -0800 Subject: [PATCH 23/31] Bump netty.version in /frameworks/Java/netty (#6352) Bumps `netty.version` from 4.1.54.Final to 4.1.59.Final. Updates `netty-codec-http` from 4.1.54.Final to 4.1.59.Final - [Release notes](https://github.com/netty/netty/releases) - [Commits](https://github.com/netty/netty/compare/netty-4.1.54.Final...netty-4.1.59.Final) Updates `netty-transport-native-epoll` from 4.1.54.Final to 4.1.59.Final - [Release notes](https://github.com/netty/netty/releases) - [Commits](https://github.com/netty/netty/compare/netty-4.1.54.Final...netty-4.1.59.Final) Updates `netty-transport-native-kqueue` from 4.1.54.Final to 4.1.59.Final - [Release notes](https://github.com/netty/netty/releases) - [Commits](https://github.com/netty/netty/compare/netty-4.1.54.Final...netty-4.1.59.Final) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- frameworks/Java/netty/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/Java/netty/pom.xml b/frameworks/Java/netty/pom.xml index dcb8f839490..d146a078773 100644 --- a/frameworks/Java/netty/pom.xml +++ b/frameworks/Java/netty/pom.xml @@ -11,7 +11,7 @@ 11 11 - 4.1.54.Final + 4.1.59.Final jar From 7be3d36e26d7d4bd7e733fcebc43939eef88cb65 Mon Sep 17 00:00:00 2001 From: Gerik Bonaert Date: Wed, 10 Feb 2021 17:32:37 +0100 Subject: [PATCH 24/31] Update hapi to 20.1.0 (#6355) - plugin registration code and handlers were refactored to support hapi 20.1.0. - vision package was upgraded to be compatible with hapi 20.1.0 - mongoose code was updated in order to remove deprecated methods and features. (useNewUrlParser, useUnifiedTopology, updateOne instead of update) - mongoose implementation of /queries was not reading all queries from the database, causing tests to fail. --- frameworks/JavaScript/hapi/README.md | 4 +- frameworks/JavaScript/hapi/create-server.js | 86 ++++++++++--------- .../JavaScript/hapi/handlers/mongoose.js | 40 +++++---- .../hapi/handlers/sequelize-postgres.js | 41 +++++---- .../JavaScript/hapi/handlers/sequelize.js | 36 ++++---- frameworks/JavaScript/hapi/helper.js | 9 -- frameworks/JavaScript/hapi/package.json | 6 +- 7 files changed, 114 insertions(+), 108 deletions(-) diff --git a/frameworks/JavaScript/hapi/README.md b/frameworks/JavaScript/hapi/README.md index 01f20c47fdb..0f287b2b582 100644 --- a/frameworks/JavaScript/hapi/README.md +++ b/frameworks/JavaScript/hapi/README.md @@ -12,8 +12,8 @@ This is the Hapi portion of a [benchmarking test suite](../) comparing a variety ## Infrastructure Software Versions The tests were run with: -* [Node.js v7.5.0](http://nodejs.org/) -* [Hapi 16.1.0](http://hapijs.com/) +* [Node.js v14.15.1](http://nodejs.org/) +* [Hapi 20.1.0](http://hapijs.com/) ## Resources * http://nodejs.org/api/cluster.html diff --git a/frameworks/JavaScript/hapi/create-server.js b/frameworks/JavaScript/hapi/create-server.js index a12254ff4d3..6286264fd2e 100644 --- a/frameworks/JavaScript/hapi/create-server.js +++ b/frameworks/JavaScript/hapi/create-server.js @@ -3,54 +3,58 @@ * working implementation for the benchmark suite. */ -const Hapi = require('hapi'); -const Vision = require('vision'); +const Hapi = require('@hapi/hapi'); +const Vision = require('@hapi/vision'); const options = { - connections: { - compression: false - } + port: process.env.PORT || 8080, + host: '0.0.0.0', + compression: false }; -const server = new Hapi.Server(options); +const server = new Hapi.server(options); -server.connection({port: process.env.PORT || 8080, host: '0.0.0.0'}); -server.register(Vision, (err) => { - if (err) { - throw err; - } - - server.views({ - engines: { html: require('handlebars') }, - path: __dirname + '/views/' - }); -}); - -const Handler = require(`./handlers/${process.env.NODE_HANDLER}`); - -// Makes routing simpler as tfb routes are all GET's -// We also don't use the nifty route features that Hapi has -// to offer such as attaching a validator -const Route = (path, handler) => - server.route({ method: 'GET', path, handler }); +const provision = async () => { -const JsonSerialization = (req, reply) => - reply({ message: 'Hello, World!' }).header('Server', 'hapi'); - -const Plaintext = (req, reply) => - reply('Hello, World!') - .header('Server', 'hapi') - .header('Content-Type', 'text/plain'); + await server.register({ + plugin: Vision, + options: { + engines: { html: require('handlebars') }, + path: __dirname + '/views/' + } + }) + + const Handler = require(`./handlers/${process.env.NODE_HANDLER}`); + + // Makes routing simpler as tfb routes are all GET's + // We also don't use the nifty route features that Hapi has + // to offer such as attaching a validator + const Route = (path, handler) => + server.route({ method: 'GET', path, handler }); + + const JsonSerialization = (request, h) => + h.response({ message: 'Hello, World!' }).header('Server', 'hapi'); + + const Plaintext = (request, h) => + h.response('Hello, World!') + .header('Server', 'hapi') + .header('Content-Type', 'text/plain'); + + + Route('/json', JsonSerialization); + Route('/plaintext', Plaintext); + + Route('/db', Handler.SingleQuery); + Route('/queries', Handler.MultipleQueries); + Route('/fortunes', Handler.Fortunes); + Route('/updates', Handler.Updates); + + await server.start(); + console.log('Hapi worker started and listening on ' + server.info.uri + " " + + new Date().toISOString(" ")); +} -Route('/json', JsonSerialization); -Route('/plaintext', Plaintext); +provision() -Route('/db', Handler.SingleQuery); -Route('/queries', Handler.MultipleQueries); -Route('/fortunes', Handler.Fortunes); -Route('/updates', Handler.Updates); -server.start((err) => - console.log('Hapi worker started and listening on ' + server.info.uri + " " - + new Date().toISOString(" "))); diff --git a/frameworks/JavaScript/hapi/handlers/mongoose.js b/frameworks/JavaScript/hapi/handlers/mongoose.js index f52428ac810..85857ff131c 100644 --- a/frameworks/JavaScript/hapi/handlers/mongoose.js +++ b/frameworks/JavaScript/hapi/handlers/mongoose.js @@ -1,9 +1,9 @@ // Connects to MongoDB using the mongoose driver // Handles related routes -const h = require('../helper'); +const helper = require('../helper'); const Mongoose = require('mongoose'); -Mongoose.connect('mongodb://tfb-database/hello_world'); +Mongoose.connect('mongodb://tfb-database/hello_world', { useNewUrlParser: true, useUnifiedTopology: true }); const WorldSchema = new Mongoose.Schema({ id: Number, @@ -22,52 +22,56 @@ const FortuneSchema = new Mongoose.Schema({ const Worlds = Mongoose.model('world', WorldSchema); const Fortunes = Mongoose.model('fortune', FortuneSchema); -const randomWorld = async () => - await Worlds.findOne({ id: h.randomTfbNumber() }); +const randomWorld = () => Worlds.findOne({ id: helper.randomTfbNumber() }); const updateWorld = async (world) => - await Worlds.update( + await Worlds.updateOne( { id: world.randomNumber }, { randomNumber: world.randomNumber } ); module.exports = { - SingleQuery: async (req, reply) => { - reply(await randomWorld()).header('Server', 'hapi'); + SingleQuery: async (request, h) => { + return h.response(await randomWorld()).header('Server', 'hapi'); }, - MultipleQueries: async (req, reply) => { - const queries = h.getQueries(req); - const results = h.fillArray(await randomWorld(), queries); + MultipleQueries: async (request, h) => { + const queries = helper.getQueries(request); + const results = []; + + for (let i = 0; i < queries; i++) { + results.push(await randomWorld()); + } + - reply(results).header('Server', 'hapi'); + return h.response(results).header('Server', 'hapi'); }, - Fortunes: async (req, reply) => { + Fortunes: async (request, h) => { const fortunes = await Fortunes.find(); - fortunes.push(h.additionalFortune()); + fortunes.push(helper.additionalFortune()); fortunes.sort((a, b) => a.message.localeCompare(b.message)); - reply.view('fortunes', { + return h.view('fortunes', { fortunes: fortunes }) .header('Content-Type', 'text/html') .header('Server', 'hapi'); }, - Updates: async (req, reply) => { - const queries = h.getQueries(req); + Updates: async (request, h) => { + const queries = helper.getQueries(request); const results = []; for (let i = 0; i < queries; i++) { const world = await randomWorld(); - world.randomNumber = h.randomTfbNumber(); + world.randomNumber = helper.randomTfbNumber(); await updateWorld(world); results.push(world); } - reply(results) + return h.response(results) .header('Content-Type', 'application/json') .header('Server', 'hapi'); } diff --git a/frameworks/JavaScript/hapi/handlers/sequelize-postgres.js b/frameworks/JavaScript/hapi/handlers/sequelize-postgres.js index ad3b72aecbe..7a5473fe727 100644 --- a/frameworks/JavaScript/hapi/handlers/sequelize-postgres.js +++ b/frameworks/JavaScript/hapi/handlers/sequelize-postgres.js @@ -1,7 +1,7 @@ // Connects to Postgres using the sequelize driver // Handles related routes -const h = require('../helper'); +const helper = require('../helper'); const Sequelize = require('sequelize'); const sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpass', { @@ -32,53 +32,58 @@ const Fortunes = sequelize.define('fortune', { freezeTableName: true }); -const randomWorld = async () => - await Worlds.findOne({ where: { id: h.randomTfbNumber() } }); +const randomWorld = () => Worlds.findOne({ where: { id: helper.randomTfbNumber() } }); module.exports = { - SingleQuery: (req, reply) => { - reply(randomWorld()) + SingleQuery: async (request, h) => { + return h.response(await randomWorld()) .header('Content-Type', 'application/json') .header('Server', 'hapi'); }, - MultipleQueries: async (req, reply) => { - const queries = h.getQueries(req); + MultipleQueries: async (request, h) => { + const queries = helper.getQueries(request); const results = []; for (let i = 0; i < queries; i++) { results.push(await randomWorld()); } - reply(results) + return h.response(results) .header('Content-Type', 'application/json') .header('Server', 'hapi'); }, - Fortunes: (req, reply) => { - Fortunes.findAll().then((fortunes) => { - fortunes.push(h.additionalFortune()); + Fortunes: async (request, h) => { + try { + const fortunes = await Fortunes.findAll() + fortunes.push(helper.additionalFortune()); fortunes.sort((a, b) => a.message.localeCompare(b.message)); - reply.view('fortunes', { fortunes }) + return h.view('fortunes', { fortunes }) .header('Content-Type', 'text/html') .header('Server', 'hapi'); - }).catch((err) => process.exit(1)); + } catch (err) { + process.exit(1) + } }, - Updates: async (req, reply) => { - const queries = h.getQueries(req); + Updates: async (request, h) => { + const queries = helper.getQueries(request); const results = []; for (let i = 0; i < queries; i++) { const world = await randomWorld(); - await world.set('randomnumber', h.randomTfbNumber()); - await world.save(); + world.randomnumber = helper.randomTfbNumber(); + await Worlds.update( + { randomnumber: world.randomnumber }, + { where: { id: world.id } } + ); results.push(world); } - reply(results) + return h.response(results) .header('Content-Type', 'application/json') .header('Server', 'hapi'); } diff --git a/frameworks/JavaScript/hapi/handlers/sequelize.js b/frameworks/JavaScript/hapi/handlers/sequelize.js index 273000e493e..402a10e9807 100644 --- a/frameworks/JavaScript/hapi/handlers/sequelize.js +++ b/frameworks/JavaScript/hapi/handlers/sequelize.js @@ -1,7 +1,7 @@ // Connects to MySQL using the sequelize driver // Handles related routes -const h = require('../helper'); +const helper = require('../helper'); const Sequelize = require('sequelize'); const sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpass', { @@ -32,48 +32,50 @@ const Fortunes = sequelize.define('Fortune', { freezeTableName: true }); -const randomWorld = async () => - await Worlds.findOne({ where: { id: h.randomTfbNumber() } }); +const randomWorld = () => Worlds.findOne({ where: { id: helper.randomTfbNumber() } }); module.exports = { - SingleQuery: (req, reply) => { - reply(randomWorld()) + SingleQuery: async (request, h) => { + return h.response(await randomWorld()) .header('Content-Type', 'application/json') .header('Server', 'hapi'); }, - MultipleQueries: async (req, reply) => { - const queries = h.getQueries(req); + MultipleQueries: async (request, h) => { + const queries = helper.getQueries(request); const results = []; for (let i = 0; i < queries; i++) { results.push(await randomWorld()); } - reply(results) + return h.response(results) .header('Content-Type', 'application/json') .header('Server', 'hapi'); }, - Fortunes: (req, reply) => { - Fortunes.findAll().then((fortunes) => { - fortunes.push(h.additionalFortune()); + Fortunes: async (request, h) => { + try { + const fortunes = await Fortunes.findAll() + fortunes.push(helper.additionalFortune()); fortunes.sort((a, b) => a.message.localeCompare(b.message)); - reply.view('fortunes', { fortunes }) + return h.view('fortunes', { fortunes }) .header('Content-Type', 'text/html') .header('Server', 'hapi'); - }).catch((err) => process.exit(1)); + } catch (err) { + process.exit(1) + } }, - Updates: async (req, reply) => { - const queries = h.getQueries(req); + Updates: async (request, h) => { + const queries = helper.getQueries(request); const results = []; for (let i = 0; i < queries; i++) { const world = await randomWorld(); - world.randomNumber = h.randomTfbNumber(); + world.randomNumber = helper.randomTfbNumber(); await Worlds.update( { randomNumber: world.randomNumber }, { where: { id: world.id } } @@ -81,7 +83,7 @@ module.exports = { results.push(world); } - reply(results) + return h.response(results) .header('Content-Type', 'application/json') .header('Server', 'hapi'); } diff --git a/frameworks/JavaScript/hapi/helper.js b/frameworks/JavaScript/hapi/helper.js index a9ecb4f385a..f7dcb5ba08a 100644 --- a/frameworks/JavaScript/hapi/helper.js +++ b/frameworks/JavaScript/hapi/helper.js @@ -1,15 +1,6 @@ module.exports = { randomTfbNumber: () => Math.floor(Math.random() * 10000) + 1, - fillArray: (value, len) => { - const filled = []; - - for (let i = 0; i < len; i++) { - filled.push(value); - } - return filled; - }, - getQueries: (req) => { let queries = ~~(req.query.queries) || 1; queries = Math.min(Math.max(queries, 1), 500); diff --git a/frameworks/JavaScript/hapi/package.json b/frameworks/JavaScript/hapi/package.json index 4edf6148a9f..b2a88acacbf 100644 --- a/frameworks/JavaScript/hapi/package.json +++ b/frameworks/JavaScript/hapi/package.json @@ -3,12 +3,12 @@ "version": "0.0.1", "private": true, "dependencies": { + "@hapi/hapi": "20.1.0", + "@hapi/vision": "6.0.1", "async": "2.1.5", "bluebird": "3.4.7", "handlebars": "4.3.0", - "hapi": "16.1.1", - "vision": "4.1.0", - "mongoose": "5.7.5", + "mongoose": "5.11.15", "mysql": "2.16.0", "mysql2": "1.6.5", "pg": "8.5.1", From d57aa8983b0c254ca1a8d0f9a8249abaf1a134fc Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Wed, 10 Feb 2021 17:33:34 +0100 Subject: [PATCH 25/31] Migrate warp-rust to use sqlx (#6354) In the past, warp-rust has used tokio-postgres which because it was compatible with async code and there was no real alternative to it - it wasn't great, but there was nothing better. However, since then sqlx was released which provides a nicer interface than very low-level interface of tokio-postgres while providing nice features such as built-in connection pooling, automatic statement preparation and caching, fetching results directly into structures, and more. --- frameworks/Rust/warp-rust/Cargo.toml | 2 +- frameworks/Rust/warp-rust/README.md | 7 ++- frameworks/Rust/warp-rust/src/db.rs | 58 ----------------------- frameworks/Rust/warp-rust/src/main.rs | 67 +++++++++++++++++---------- 4 files changed, 49 insertions(+), 85 deletions(-) delete mode 100644 frameworks/Rust/warp-rust/src/db.rs diff --git a/frameworks/Rust/warp-rust/Cargo.toml b/frameworks/Rust/warp-rust/Cargo.toml index e9404a24ae4..f9f4cf7ae10 100644 --- a/frameworks/Rust/warp-rust/Cargo.toml +++ b/frameworks/Rust/warp-rust/Cargo.toml @@ -8,8 +8,8 @@ edition = "2018" futures = "0.3.12" rand = { version = "0.8.2", features = ["small_rng"] } serde = { version = "1.0.120", features = ["derive"] } +sqlx = { version = "0.5.1", features = ["runtime-tokio-rustls", "postgres"] } tokio = { version = "1.0.2", features = ["macros", "rt-multi-thread"] } -tokio-postgres = "0.7.0" warp = "0.3.0" yarte = "0.14.1" diff --git a/frameworks/Rust/warp-rust/README.md b/frameworks/Rust/warp-rust/README.md index 6832317edb2..f0e4b51fec4 100755 --- a/frameworks/Rust/warp-rust/README.md +++ b/frameworks/Rust/warp-rust/README.md @@ -2,7 +2,7 @@ warp is a composable web server framework based on hyper. -* [API Documentation](https://docs.rs/warp/0.2) +* [API Documentation](https://docs.rs/warp/0.3) ### Test Type Implementation Source Code @@ -10,6 +10,7 @@ warp is a composable web server framework based on hyper. * [PLAINTEXT](src/main.rs) * [DB](src/main.rs) * [QUERIES](src/main.rs) +* [FORTUNES](src/main.rs) ## Test URLs ### JSON @@ -27,3 +28,7 @@ http://localhost:8080/db ### QUERIES http://localhost:8080/queries/[1...500] + +### FORTUNES + +http://localhost:8080/fortunes diff --git a/frameworks/Rust/warp-rust/src/db.rs b/frameworks/Rust/warp-rust/src/db.rs deleted file mode 100644 index 9adf7caf3eb..00000000000 --- a/frameworks/Rust/warp-rust/src/db.rs +++ /dev/null @@ -1,58 +0,0 @@ -use serde::Serialize; -use tokio_postgres::{Client, Error, NoTls, Statement}; - -const DATABASE_URL: &str = "postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world"; - -pub struct Database { - client: Client, - world: Statement, - fortune: Statement, -} - -#[derive(Serialize)] -pub struct World { - pub id: i32, - pub randomnumber: i32, -} - -pub struct Fortune { - pub id: i32, - pub message: String, -} - -impl Database { - pub async fn connect() -> Result { - let (client, connection) = tokio_postgres::connect(DATABASE_URL, NoTls).await?; - tokio::spawn(async { connection.await.unwrap() }); - let world = client - .prepare("SELECT id, randomnumber FROM world WHERE id=$1") - .await?; - let fortune = client.prepare("SELECT id, message FROM fortune").await?; - Ok(Self { - client, - world, - fortune, - }) - } - - pub async fn get_world_by_id(&self, id: i32) -> World { - let row = self.client.query_one(&self.world, &[&id]).await.unwrap(); - World { - id: row.get(0), - randomnumber: row.get(1), - } - } - - pub async fn query_fortunes(&self) -> Vec { - self.client - .query(&self.fortune, &[]) - .await - .unwrap() - .into_iter() - .map(|row| Fortune { - id: row.get(0), - message: row.get(1), - }) - .collect() - } -} diff --git a/frameworks/Rust/warp-rust/src/main.rs b/frameworks/Rust/warp-rust/src/main.rs index 189ecf602b8..b8e3a6fc109 100644 --- a/frameworks/Rust/warp-rust/src/main.rs +++ b/frameworks/Rust/warp-rust/src/main.rs @@ -1,17 +1,18 @@ -mod db; - -use crate::db::{Database, Fortune}; use futures::stream::futures_unordered::FuturesUnordered; use futures::{FutureExt, StreamExt}; use rand::distributions::{Distribution, Uniform}; use rand::rngs::SmallRng; use rand::SeedableRng; use serde::Serialize; +use sqlx::postgres::PgPool; +use sqlx::FromRow; use std::cell::RefCell; use warp::http::header; use warp::{Filter, Rejection, Reply}; use yarte::Template; +const DATABASE_URL: &str = "postgres://benchmarkdbuser:benchmarkdbpass@tfb-database/hello_world"; + // SmallRng is not a CSPRNG. It's used specifically to match performance of // benchmarks in other programming languages where the default RNG algorithm // is not a CSPRNG. Most Rust programs will likely want to use @@ -39,18 +40,31 @@ fn plaintext() -> impl Filter + Clone { warp::path!("plaintext").map(|| "Hello, World!") } -fn db(database: &'static Database) -> impl Filter + Clone { +#[derive(Serialize, FromRow)] +pub struct World { + pub id: i32, + pub randomnumber: i32, +} + +impl World { + async fn get_by_id(pool: &PgPool, id: i32) -> Self { + sqlx::query_as("SELECT id, randomnumber FROM world WHERE id=$1") + .bind(id) + .fetch_one(pool) + .await + .unwrap() + } +} + +fn db(pool: &'static PgPool) -> impl Filter + Clone { let between = Uniform::from(1..=10_000); warp::path!("db").and_then(move || async move { let id = with_rng(|rng| between.sample(rng)); - let world = database.get_world_by_id(id).await; - Ok::<_, Rejection>(warp::reply::json(&world)) + Ok::<_, Rejection>(warp::reply::json(&World::get_by_id(pool, id).await)) }) } -fn queries( - database: &'static Database, -) -> impl Filter + Clone { +fn queries(pool: &'static PgPool) -> impl Filter + Clone { let between = Uniform::from(1..=10_000); let clamped = warp::path!(u32).map(|queries: u32| queries.max(1).min(500)); warp::path!("queries" / ..) @@ -58,7 +72,7 @@ fn queries( .and_then(move |queries| { with_rng(|rng| { (0..queries) - .map(|_| database.get_world_by_id(between.sample(rng))) + .map(|_| World::get_by_id(pool, between.sample(rng))) .collect::>() .collect::>() .map(|worlds| Ok::<_, Rejection>(warp::reply::json(&worlds))) @@ -72,11 +86,18 @@ struct FortunesYarteTemplate { fortunes: Vec, } -fn fortune( - database: &'static Database, -) -> impl Filter + Clone { +#[derive(FromRow)] +pub struct Fortune { + pub id: i32, + pub message: String, +} + +fn fortune(pool: &'static PgPool) -> impl Filter + Clone { warp::path!("fortunes").and_then(move || async move { - let mut fortunes = database.query_fortunes().await; + let mut fortunes = sqlx::query_as("SELECT id, message FROM fortune") + .fetch_all(pool) + .await + .unwrap(); fortunes.push(Fortune { id: 0, message: "Additional fortune added at request time.".into(), @@ -88,22 +109,18 @@ fn fortune( }) } -fn routes( - database: &'static Database, -) -> impl Filter + Clone { +fn routes(pool: &'static PgPool) -> impl Filter + Clone { json() .or(plaintext()) - .or(db(database)) - .or(queries(database)) - .or(fortune(database)) + .or(db(pool)) + .or(queries(pool)) + .or(fortune(pool)) .map(|reply| warp::reply::with_header(reply, header::SERVER, "warp")) } #[tokio::main] -async fn main() -> Result<(), tokio_postgres::Error> { - let database = Box::leak(Box::new(Database::connect().await?)); - warp::serve(routes(database)) - .run(([0, 0, 0, 0], 8080)) - .await; +async fn main() -> Result<(), sqlx::Error> { + let pool = Box::leak(Box::new(PgPool::connect(DATABASE_URL).await?)); + warp::serve(routes(pool)).run(([0, 0, 0, 0], 8080)).await; Ok(()) } From 98f1fea27ef8c3d6e2250ec299aba03e501a60e8 Mon Sep 17 00:00:00 2001 From: Daniel Kozak Date: Thu, 11 Feb 2021 22:26:31 +0100 Subject: [PATCH 26/31] [dlang/vibed] fix build and solved #6353 (#6357) --- frameworks/D/vibed/benchmark_config.json | 12 +++----- frameworks/D/vibed/dub.json | 12 +++++--- frameworks/D/vibed/dub.selections.json | 28 +++++++++---------- frameworks/D/vibed/vibed-dmd-pgsql.dockerfile | 2 +- frameworks/D/vibed/vibed-ldc-pgsql.dockerfile | 2 +- frameworks/D/vibed/vibed-ldc.dockerfile | 2 +- frameworks/D/vibed/vibed.dockerfile | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/frameworks/D/vibed/benchmark_config.json b/frameworks/D/vibed/benchmark_config.json index 2cc83fc9807..23bfbe0ce73 100644 --- a/frameworks/D/vibed/benchmark_config.json +++ b/frameworks/D/vibed/benchmark_config.json @@ -22,8 +22,7 @@ "database_os": "Linux", "display_name": "vibe.d", "notes": "", - "versus": "vibed", - "tags": ["broken"] + "versus": "vibed" }, "dmd-pgsql": { "json_url": "/json", @@ -46,8 +45,7 @@ "database_os": "Linux", "display_name": "vibe.d-pgsql", "notes": "", - "versus": "vibed", - "tags": ["broken"] + "versus": "vibed" }, "ldc": { "json_url": "/json", @@ -70,8 +68,7 @@ "database_os": "Linux", "display_name": "vibe.d-ldc", "notes": "", - "versus": "vibed", - "tags": ["broken"] + "versus": "vibed" }, "ldc-pgsql": { "json_url": "/json", @@ -94,8 +91,7 @@ "database_os": "Linux", "display_name": "vibe.d-ldc-pgsql", "notes": "", - "versus": "vibed", - "tags": ["broken"] + "versus": "vibed" } }] } diff --git a/frameworks/D/vibed/dub.json b/frameworks/D/vibed/dub.json index cbe6f299d40..637bd9c515c 100644 --- a/frameworks/D/vibed/dub.json +++ b/frameworks/D/vibed/dub.json @@ -7,9 +7,9 @@ "Sönke Ludwig" ], "dependencies": { - "vibe-d": "0.8.5", - "mir-random": "2.2.3", - "vibe-d:tls": "0.8.5" + "vibe-d": "0.9.3", + "mir-random": "2.2.15", + "vibe-d:tls": "0.9.3" }, "targetType": "executable", "sourcePaths": [], @@ -29,7 +29,11 @@ "name": "postgresql", "mainSourceFile": "source/postgresql.d", "dependencies": { - "vibe-d-postgresql": "2.0.2" + "vibe-d-postgresql": "3.1.0-rc.1", + "dpq2": "1.0.17" + }, + "subConfigurations": { + "dpq2": "dynamic" } } ], diff --git a/frameworks/D/vibed/dub.selections.json b/frameworks/D/vibed/dub.selections.json index 0e0d14758d6..51aa5a38a73 100644 --- a/frameworks/D/vibed/dub.selections.json +++ b/frameworks/D/vibed/dub.selections.json @@ -1,26 +1,26 @@ { "fileVersion": 1, "versions": { - "botan": "1.12.10", + "botan": "1.12.19", "botan-math": "1.0.3", "derelict-pq": "4.0.0-alpha.2", "derelict-util": "3.0.0-beta.2", - "diet-ng": "1.5.0", - "dpq2": "1.0.10", - "eventcore": "0.8.42", - "libasync": "0.8.4", + "diet-ng": "1.7.4", + "dpq2": "1.0.17", + "eventcore": "0.9.13", + "libasync": "0.8.6", "libevent": "2.0.2+2.0.16", - "memutils": "0.4.13", - "mir-algorithm": "3.3.11", - "mir-core": "0.2.2", + "memutils": "1.0.4", + "mir-algorithm": "3.10.19", + "mir-core": "1.1.62", "mir-linux-kernel": "1.0.1", - "mir-random": "2.2.3", - "money": "2.3.0", + "mir-random": "2.2.15", + "money": "2.3.1", "openssl": "1.1.6+1.0.1g", "stdx-allocator": "2.77.5", - "taggedalgebraic": "0.11.3", - "vibe-core": "1.6.2", - "vibe-d": "0.8.5", - "vibe-d-postgresql": "2.0.2" + "taggedalgebraic": "0.11.19", + "vibe-core": "1.13.0", + "vibe-d": "0.9.3", + "vibe-d-postgresql": "3.1.0-rc.1" } } diff --git a/frameworks/D/vibed/vibed-dmd-pgsql.dockerfile b/frameworks/D/vibed/vibed-dmd-pgsql.dockerfile index edd076365f3..ff4266fd82c 100644 --- a/frameworks/D/vibed/vibed-dmd-pgsql.dockerfile +++ b/frameworks/D/vibed/vibed-dmd-pgsql.dockerfile @@ -1,4 +1,4 @@ -FROM dlang2/dmd-ubuntu:2.085.1 +FROM dlang2/dmd-ubuntu:2.095.0 WORKDIR /dlang/app COPY . . diff --git a/frameworks/D/vibed/vibed-ldc-pgsql.dockerfile b/frameworks/D/vibed/vibed-ldc-pgsql.dockerfile index bb5b6c43e8b..d3b873a870c 100644 --- a/frameworks/D/vibed/vibed-ldc-pgsql.dockerfile +++ b/frameworks/D/vibed/vibed-ldc-pgsql.dockerfile @@ -1,4 +1,4 @@ -FROM dlang2/ldc-ubuntu:1.15.0 +FROM dlang2/ldc-ubuntu:1.24.0 WORKDIR /dlang/app COPY . . diff --git a/frameworks/D/vibed/vibed-ldc.dockerfile b/frameworks/D/vibed/vibed-ldc.dockerfile index 34d44f70fab..f65c386bd6f 100644 --- a/frameworks/D/vibed/vibed-ldc.dockerfile +++ b/frameworks/D/vibed/vibed-ldc.dockerfile @@ -1,4 +1,4 @@ -FROM dlang2/ldc-ubuntu:1.15.0 +FROM dlang2/ldc-ubuntu:1.24.0 WORKDIR /dlang/app COPY . . diff --git a/frameworks/D/vibed/vibed.dockerfile b/frameworks/D/vibed/vibed.dockerfile index c9f862cf824..c841ae10483 100644 --- a/frameworks/D/vibed/vibed.dockerfile +++ b/frameworks/D/vibed/vibed.dockerfile @@ -1,4 +1,4 @@ -FROM dlang2/dmd-ubuntu:2.085.1 +FROM dlang2/dmd-ubuntu:2.095.0 WORKDIR /dlang/app COPY . . From b8917c6891b22ea27eb4bb591c419c721afe918d Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Fri, 12 Feb 2021 05:31:03 +0800 Subject: [PATCH 27/31] Update 2.3.0 (#6356) --- frameworks/Java/redkale/README.md | 24 ++++--- frameworks/Java/redkale/benchmark_config.json | 31 +++++++-- frameworks/Java/redkale/conf/application.xml | 18 ++--- frameworks/Java/redkale/conf/persistence.xml | 1 - .../Java/redkale/redkale-postgres.dockerfile | 12 ++++ .../java/org/redkalex/benchmark/Service.java | 68 ++++++++++--------- 6 files changed, 99 insertions(+), 55 deletions(-) create mode 100644 frameworks/Java/redkale/redkale-postgres.dockerfile diff --git a/frameworks/Java/redkale/README.md b/frameworks/Java/redkale/README.md index 5f0f7553ee0..bee3bf5ee59 100644 --- a/frameworks/Java/redkale/README.md +++ b/frameworks/Java/redkale/README.md @@ -4,32 +4,36 @@ This is the Redkale portion of a [benchmarking test suite](../) comparing a vari ### Plaintext Test -* [Plaintext test source](src/main/java/org/redkalex/benchmark/Servlet.java) +* [Plaintext test source](src/main/java/org/redkalex/benchmark/Service.java) ### JSON Serialization Test -* [JSON test source](src/main/java/org/redkalex/benchmark/Servlet.java) +* [JSON test source](src/main/java/org/redkalex/benchmark/Service.java) ### Database Query Test -* [Database Query test source](src/main/java/org/redkalex/benchmark/Servlet.java) +* [Database Query test source](src/main/java/org/redkalex/benchmark/Service.java) ### Database Queries Test -* [Database Queries test source](src/main/java/org/redkalex/benchmark/Servlet.java) +* [Database Queries test source](src/main/java/org/redkalex/benchmark/Service.java) + +### Database Caching Test + +* [Database Queries test source](src/main/java/org/redkalex/benchmark/Service.java) ### Database Update Test -* [Database Update test source](src/main/java/org/redkalex/benchmark/Servlet.java) +* [Database Update test source](src/main/java/org/redkalex/benchmark/Service.java) ### Template rendering Test -* [Template rendering test source](src/main/java/org/redkalex/benchmark/Servlet.java) +* [Template rendering test source](src/main/java/org/redkalex/benchmark/Service.java) ## Versions -* [Java OpenJDK 1.8](http://openjdk.java.net/) -* [Redkale 1.9.3](http://redkale.org/) +* [Java OpenJDK 11](http://openjdk.java.net/) +* [Redkale 2.3.0](http://redkale.org/) ## Test URLs @@ -49,6 +53,10 @@ This is the Redkale portion of a [benchmarking test suite](../) comparing a vari http://localhost:8080/queries?queries=5 +### Database Caching Test + + http://localhost:8080/cached-worlds?count=5 + ### Database Update Test http://localhost:8080/updates?queries=5 diff --git a/frameworks/Java/redkale/benchmark_config.json b/frameworks/Java/redkale/benchmark_config.json index 17a1f93db68..557fb6a8bd9 100644 --- a/frameworks/Java/redkale/benchmark_config.json +++ b/frameworks/Java/redkale/benchmark_config.json @@ -3,12 +3,7 @@ "tests": [{ "default": { "json_url": "/json", - "plaintext_url": "/plaintext", - "db_url2": "/db", - "query_url2": "/queries?queries=", - "fortune_url2": "/fortunes", - "update_url2": "/updates?queries=", - "cached_query_url2": "/cached-worlds?count=", + "plaintext_url": "/plaintext", "port": 8080, "approach": "Realistic", "classification": "Fullstack", @@ -18,7 +13,29 @@ "flavor": "None", "orm": "Raw", "platform": "Redkale", - "webserver": "None", + "webserver": "Redkale", + "os": "Linux", + "database_os": "Linux", + "display_name": "redkale", + "notes": "", + "versus": "" + }, + "postgres": { + "db_url": "/db", + "query_url": "/queries?queries=", + "fortune_url": "/fortunes", + "update_url": "/updates?queries=", + "cached_query_url": "/cached-worlds?count=", + "port": 8080, + "approach": "Realistic", + "classification": "Fullstack", + "database": "Postgres", + "framework": "Redkale", + "language": "Java", + "flavor": "None", + "orm": "Raw", + "platform": "Redkale", + "webserver": "Redkale", "os": "Linux", "database_os": "Linux", "display_name": "redkale", diff --git a/frameworks/Java/redkale/conf/application.xml b/frameworks/Java/redkale/conf/application.xml index ca1cc5facc5..88fde8c1662 100644 --- a/frameworks/Java/redkale/conf/application.xml +++ b/frameworks/Java/redkale/conf/application.xml @@ -4,23 +4,25 @@ - - - + + + - + + - - - + + + - + + diff --git a/frameworks/Java/redkale/conf/persistence.xml b/frameworks/Java/redkale/conf/persistence.xml index 16a8260f8ea..0006a666f95 100644 --- a/frameworks/Java/redkale/conf/persistence.xml +++ b/frameworks/Java/redkale/conf/persistence.xml @@ -6,7 +6,6 @@ ALL - diff --git a/frameworks/Java/redkale/redkale-postgres.dockerfile b/frameworks/Java/redkale/redkale-postgres.dockerfile new file mode 100644 index 00000000000..718f6fabdfc --- /dev/null +++ b/frameworks/Java/redkale/redkale-postgres.dockerfile @@ -0,0 +1,12 @@ +FROM maven:3.6.1-jdk-11-slim as maven +WORKDIR /redkale +COPY src src +COPY conf conf +COPY pom.xml pom.xml +RUN mvn package -q + +FROM openjdk:11.0.3-jdk-slim +WORKDIR /redkale +COPY conf conf +COPY --from=maven /redkale/target/redkale-benchmark-1.0.0.jar redkale-benchmark.jar +CMD ["java", "-server", "-XX:+UseNUMA", "-XX:+UseParallelGC", "-XX:+AggressiveOpts", "-DAPP_HOME=./", "-jar", "redkale-benchmark.jar"] diff --git a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java index 3523b7adcd5..14db00e38a7 100644 --- a/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java +++ b/frameworks/Java/redkale/src/main/java/org/redkalex/benchmark/Service.java @@ -7,6 +7,8 @@ import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Function; import javax.annotation.Resource; import org.redkale.net.http.*; import org.redkale.service.AbstractService; @@ -27,10 +29,6 @@ public class Service extends AbstractService { @Resource private DataSource source; - @Override - public void init(AnyValue conf) { - //source.queryList(CachedWorld.class); - } @RestMapping(name = "json") public Message getHelloMessage() { @@ -42,25 +40,8 @@ public byte[] getHelloBytes() { return helloBytes; } - @RestMapping(name = "db") - public CompletableFuture findWorld() { - return source.findAsync(World.class, randomId()); - } - - @RestMapping(name = "queries") - public CompletableFuture queryWorld(@RestParam(name = "queries") int count) { - final int size = Math.min(500, Math.max(1, count)); - final World[] worlds = new World[size]; - final CompletableFuture[] futures = new CompletableFuture[size]; - for (int i = 0; i < size; i++) { - final int index = i; - futures[index] = source.findAsync(World.class, randomId()).thenApply(r -> worlds[index] = r); - } - return CompletableFuture.allOf(futures).thenApply(v -> worlds); - } - @RestMapping(name = "cached-worlds") - public CachedWorld[] cachedWorlds(@RestParam(name = "count") int count) { + public CachedWorld[] cachedWorlds(int count) { final int size = Math.min(500, Math.max(1, count)); final CachedWorld[] worlds = new CachedWorld[size]; for (int i = 0; i < size; i++) { @@ -69,19 +50,44 @@ public CachedWorld[] cachedWorlds(@RestParam(name = "count") int count) { return worlds; } + @RestMapping(name = "db") + public CompletableFuture findWorldAsync() { + return source.findAsync(World.class, randomId()); + } + + @RestMapping(name = "queries") + public CompletableFuture queryWorldAsync(int queries) { + final int size = Math.min(500, Math.max(1, queries)); + final World[] worlds = new World[size]; + final AtomicInteger index = new AtomicInteger(); + final Function func = f -> source.findAsync(World.class, randomId()) + .thenAccept((World v) -> worlds[index.getAndIncrement()] = v); + CompletableFuture future = func.apply(null); + for (int i = 1; i < size; i++) { + future = future.thenCompose(func); + } + return future.thenApply(v -> worlds); + } + @RestMapping(name = "updates") - public CompletableFuture updateWorld(@RestParam(name = "queries") int count) { - final int size = Math.min(500, Math.max(1, count)); + public CompletableFuture updateWorldAsync(int queries) { + final int size = Math.min(500, Math.max(1, queries)); final World[] worlds = new World[size]; - final CompletableFuture[] futures = new CompletableFuture[size]; - for (int i = 0; i < size; i++) { - final int index = i; - futures[index] = source.findAsync(World.class, randomId()).thenAccept((World r) -> { - r.setRandomNumber(randomId()); - worlds[index] = r; + final AtomicInteger index = new AtomicInteger(); + final Function func = f -> source.findAsync(World.class, randomId()) + .thenApply((World v) -> { + worlds[index.getAndIncrement()] = v; + v.setRandomNumber(randomId()); + return v; }); + CompletableFuture future = func.apply(null); + for (int i = 1; i < size; i++) { + future = future.thenCompose(func); } - return CompletableFuture.allOf(futures).thenCompose(v -> source.updateAsync(worlds)).thenApply(v -> worlds); + return future.thenCompose(v -> { + Arrays.sort(worlds); + return source.updateAsync(worlds); + }).thenApply(v -> worlds); } @RestMapping(name = "fortunes") From 55a770cf846bcd29e3f16ee3f47494ec1e5d9744 Mon Sep 17 00:00:00 2001 From: Yufan Gong Date: Fri, 12 Feb 2021 13:18:30 -0800 Subject: [PATCH 28/31] Update Finagle/Finatra library versions in benchmarks (#6358) * Update build.sbt * Update build.sbt --- frameworks/Scala/finagle/build.sbt | 2 +- frameworks/Scala/finatra/build.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/Scala/finagle/build.sbt b/frameworks/Scala/finagle/build.sbt index b281a7dda05..b7a4ed1659e 100644 --- a/frameworks/Scala/finagle/build.sbt +++ b/frameworks/Scala/finagle/build.sbt @@ -1,4 +1,4 @@ -lazy val finagleVersion = "21.1.0" +lazy val finagleVersion = "21.2.0" name := "finagle-benchmark" scalaVersion := "2.12.8" diff --git a/frameworks/Scala/finatra/build.sbt b/frameworks/Scala/finatra/build.sbt index a0c401d2cd3..fa1b0e16c6d 100644 --- a/frameworks/Scala/finatra/build.sbt +++ b/frameworks/Scala/finatra/build.sbt @@ -1,4 +1,4 @@ -lazy val finatraVersion = "21.1.0" +lazy val finatraVersion = "21.2.0" name := "techempower-benchmarks-finatra" organization := "com.twitter" From 13973f99201bb0b75e95653f722d77105caf2bbe Mon Sep 17 00:00:00 2001 From: JaeHyeok Kim Date: Sat, 13 Feb 2021 06:18:56 +0900 Subject: [PATCH 29/31] Update to nodejs 14.15.5 and mongodb, mongoose (#6362) * Update node version for nodejs * Fix nodejs mongodb-raw and postgres * Fix nodejs mongoose * Fix nodejs mongoose * Update nodejs mongodb-raw --- frameworks/JavaScript/nodejs/README.md | 8 ++++---- frameworks/JavaScript/nodejs/handlers/mongodb-raw.js | 10 +++++++--- frameworks/JavaScript/nodejs/handlers/mongoose.js | 5 +---- frameworks/JavaScript/nodejs/nodejs.dockerfile | 2 +- frameworks/JavaScript/nodejs/package.json | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/frameworks/JavaScript/nodejs/README.md b/frameworks/JavaScript/nodejs/README.md index 8a3b7a8d931..acf9bc6ce47 100644 --- a/frameworks/JavaScript/nodejs/README.md +++ b/frameworks/JavaScript/nodejs/README.md @@ -16,12 +16,12 @@ The server is currently in Alpha state, but aims to be a drop-in replacement for ## Infrastructure Software Versions The tests were run with: -* [Node.js v8.1.0](http://nodejs.org/) +* [Node.js v14.15.5](http://nodejs.org/) -* [Node MySQL 2.15.0](https://github.com/felixge/node-mysql/) -* [Sequelize 3.30.0](https://github.com/sequelize/sequelize) +* [Node MySQL 2.16.0](https://github.com/felixge/node-mysql/) +* [Sequelize 5.15.1](https://github.com/sequelize/sequelize) * [Node MongoDB Driver 2.2.33](https://github.com/mongodb/node-mongodb-native) -* [Mongoose 4.12.4](http://mongoosejs.com/) +* [Mongoose 5.7.5](http://mongoosejs.com/) ## Test URLs diff --git a/frameworks/JavaScript/nodejs/handlers/mongodb-raw.js b/frameworks/JavaScript/nodejs/handlers/mongodb-raw.js index f36af9cf15d..e4b0024fe64 100644 --- a/frameworks/JavaScript/nodejs/handlers/mongodb-raw.js +++ b/frameworks/JavaScript/nodejs/handlers/mongodb-raw.js @@ -5,11 +5,15 @@ const collections = { World: null, Fortune: null }; -MongoClient.connect('mongodb://tfb-database/hello_world?maxPoolSize=5', (err, db) => { + +const mongoUrl = 'mongodb://tfb-database:27017'; +const dbName = 'hello_world'; + +MongoClient.connect(mongoUrl, (err, database) => { // do nothing if there is err connecting to db - collections.World = db.collection('world'); - collections.Fortune = db.collection('fortune'); + collections.World = database.db(dbName).collection('world'); + collections.Fortune = database.db(dbName).collection('fortune'); }); diff --git a/frameworks/JavaScript/nodejs/handlers/mongoose.js b/frameworks/JavaScript/nodejs/handlers/mongoose.js index a968e9d2ae0..6eef18d3c4b 100644 --- a/frameworks/JavaScript/nodejs/handlers/mongoose.js +++ b/frameworks/JavaScript/nodejs/handlers/mongoose.js @@ -1,10 +1,7 @@ const h = require('../helper'); const async = require('async'); const Mongoose = require('mongoose'); -const connection = Mongoose.connect( - 'mongodb://tfb-database/hello_world', - { useMongoClient: true } -); +const connection = Mongoose.createConnection('mongodb://tfb-database/hello_world'); // Mongoose Setup const WorldSchema = new Mongoose.Schema({ diff --git a/frameworks/JavaScript/nodejs/nodejs.dockerfile b/frameworks/JavaScript/nodejs/nodejs.dockerfile index f6c856bd1bb..433f5224d31 100644 --- a/frameworks/JavaScript/nodejs/nodejs.dockerfile +++ b/frameworks/JavaScript/nodejs/nodejs.dockerfile @@ -1,4 +1,4 @@ -FROM node:14.15.1-slim +FROM node:14.15.5-slim ARG TFB_TEST_NAME diff --git a/frameworks/JavaScript/nodejs/package.json b/frameworks/JavaScript/nodejs/package.json index 3698519b37f..a3f983504be 100644 --- a/frameworks/JavaScript/nodejs/package.json +++ b/frameworks/JavaScript/nodejs/package.json @@ -5,12 +5,12 @@ "dependencies": { "async": "2.5.0", "handlebars": "4.3.0", - "mongodb": "2.2.33", + "mongodb": "3.6.4", "mongoose": "5.7.5", "mysql": "2.16.0", "mysql2": "1.6.5", "parseurl": "1.3.2", - "pg": "6.1.6", + "pg": "8.5.0", "pg-hstore": "2.3.2", "sequelize": "5.15.1", "node-cache": "4.1.1" From e5562b7e2d0ca26e27aba41e670ef9ff89ad8eb7 Mon Sep 17 00:00:00 2001 From: Joan Miquel Date: Fri, 12 Feb 2021 22:19:14 +0100 Subject: [PATCH 30/31] Fix Phalcon (#6363) --- frameworks/PHP/phalcon/phalcon.dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/PHP/phalcon/phalcon.dockerfile b/frameworks/PHP/phalcon/phalcon.dockerfile index 035c2142d54..7c77691041d 100644 --- a/frameworks/PHP/phalcon/phalcon.dockerfile +++ b/frameworks/PHP/phalcon/phalcon.dockerfile @@ -5,7 +5,8 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php RUN apt-get update -yqq > /dev/null && \ - apt-get install -yqq nginx git unzip php7.4 php7.4-common php7.4-cli php7.4-fpm php7.4-mysql php7.4-mongodb > /dev/null + apt-get install -yqq nginx git unzip \ + php7.4-cli php7.4-fpm php7.4-mysql php7.4-mongodb php7.4-mbstring > /dev/null RUN apt-get install -yqq composer > /dev/null From 1ab60790e85ef57a8407e7bb4d200f29b2d4a1a9 Mon Sep 17 00:00:00 2001 From: JaeHyeok Kim Date: Sun, 14 Feb 2021 01:41:38 +0900 Subject: [PATCH 31/31] Update node version for nestjs (#6364) --- frameworks/TypeScript/nest/nestjs-fastify-mongo.dockerfile | 2 +- frameworks/TypeScript/nest/nestjs-fastify-mysql.dockerfile | 2 +- frameworks/TypeScript/nest/nestjs-fastify.dockerfile | 2 +- frameworks/TypeScript/nest/nestjs-mongo.dockerfile | 2 +- frameworks/TypeScript/nest/nestjs-mysql.dockerfile | 2 +- frameworks/TypeScript/nest/nestjs.dockerfile | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frameworks/TypeScript/nest/nestjs-fastify-mongo.dockerfile b/frameworks/TypeScript/nest/nestjs-fastify-mongo.dockerfile index d4d36453626..4e9aaea9353 100644 --- a/frameworks/TypeScript/nest/nestjs-fastify-mongo.dockerfile +++ b/frameworks/TypeScript/nest/nestjs-fastify-mongo.dockerfile @@ -1,4 +1,4 @@ -FROM node:14.15.1-slim +FROM node:14.15.5-slim COPY ./ ./ diff --git a/frameworks/TypeScript/nest/nestjs-fastify-mysql.dockerfile b/frameworks/TypeScript/nest/nestjs-fastify-mysql.dockerfile index 7ede6ea6fb2..fe45a11450e 100644 --- a/frameworks/TypeScript/nest/nestjs-fastify-mysql.dockerfile +++ b/frameworks/TypeScript/nest/nestjs-fastify-mysql.dockerfile @@ -1,4 +1,4 @@ -FROM node:14.15.1-slim +FROM node:14.15.5-slim COPY ./ ./ diff --git a/frameworks/TypeScript/nest/nestjs-fastify.dockerfile b/frameworks/TypeScript/nest/nestjs-fastify.dockerfile index 3e20f5d6cba..47cb62e3758 100644 --- a/frameworks/TypeScript/nest/nestjs-fastify.dockerfile +++ b/frameworks/TypeScript/nest/nestjs-fastify.dockerfile @@ -1,4 +1,4 @@ -FROM node:14.15.1-slim +FROM node:14.15.5-slim COPY ./ ./ diff --git a/frameworks/TypeScript/nest/nestjs-mongo.dockerfile b/frameworks/TypeScript/nest/nestjs-mongo.dockerfile index 50c5c994bd4..52b4668637e 100644 --- a/frameworks/TypeScript/nest/nestjs-mongo.dockerfile +++ b/frameworks/TypeScript/nest/nestjs-mongo.dockerfile @@ -1,4 +1,4 @@ -FROM node:14.15.1-slim +FROM node:14.15.5-slim COPY ./ ./ diff --git a/frameworks/TypeScript/nest/nestjs-mysql.dockerfile b/frameworks/TypeScript/nest/nestjs-mysql.dockerfile index a7fbf6d6174..cae8394a1da 100644 --- a/frameworks/TypeScript/nest/nestjs-mysql.dockerfile +++ b/frameworks/TypeScript/nest/nestjs-mysql.dockerfile @@ -1,4 +1,4 @@ -FROM node:14.15.1-slim +FROM node:14.15.5-slim COPY ./ ./ diff --git a/frameworks/TypeScript/nest/nestjs.dockerfile b/frameworks/TypeScript/nest/nestjs.dockerfile index 3c7ca92ddba..ed4c8f3e05d 100644 --- a/frameworks/TypeScript/nest/nestjs.dockerfile +++ b/frameworks/TypeScript/nest/nestjs.dockerfile @@ -1,4 +1,4 @@ -FROM node:14.15.1-slim +FROM node:14.15.5-slim COPY ./ ./