diff --git a/frameworks/sober/Dockerfile b/frameworks/sober/Dockerfile index 2570f3a978..b135d52c42 100644 --- a/frameworks/sober/Dockerfile +++ b/frameworks/sober/Dockerfile @@ -1,7 +1,7 @@ # The sober toolchain is pulled as an image (built by the release CI from the release tarball, # sha256-checked - alpine with the single static ELF compiler on PATH). A registry pull only: # nothing is downloaded from github.com at docker-build time. -FROM ghcr.io/sober-lang/sober:0.7.4 AS build +FROM ghcr.io/sober-lang/sober:0.7.5 AS build WORKDIR /app COPY main.sober ./ RUN sober build main.sober -o server diff --git a/frameworks/sober/README.md b/frameworks/sober/README.md index 5be8d12ac0..c13663801e 100644 --- a/frameworks/sober/README.md +++ b/frameworks/sober/README.md @@ -4,7 +4,7 @@ ## Stack -- Language: Sober 0.7.4 +- Language: Sober 0.7.5 - Framework: none beyond the standard library: `std/http/server` (server, router, middleware, gzip), `std/json`, `std/tls`, `std/pg` - Build: the release tarball of the compiler (one static ELF, standard library built in) on `alpine`, static binary on `scratch` diff --git a/frameworks/sober/main.sober b/frameworks/sober/main.sober index 20fc4192c9..3a28e35a1c 100644 --- a/frameworks/sober/main.sober +++ b/frameworks/sober/main.sober @@ -10,6 +10,7 @@ package main import "std/builder" import "std/compress/flate" +import "std/compress/gzip" import "std/convert" import "std/http" import "std/http/server" @@ -126,6 +127,70 @@ func specHeaders(r http.server.Request) http.server.Response { return http.server.Text(strings.Join(freeze(lines), "")) } +// /parse, the resilience suite's parser endpoint: the body goes through the standard parser its Content-Type names +// (JSON → json.Parse, a form → url.ParseQuery, multipart → http.server.Multipart). A body in a Content-Encoding (gzip / +// deflate) is decoded first, its output capped at maxBody like a plain body (the zlib checksum of deflate is not checked). 200 when it parses, 400 when it does not, 413 +// when the decoded body is over the cap, 415 for an encoding the server does not decode +func parse(r http.server.Request) http.server.Response { + enc := field(r, "content-encoding") + if enc != "" && enc != "identity" { + if enc != "gzip" && enc != "x-gzip" && enc != "deflate" { + return http.server.Status(http.StatusCode(415)) + } + if enc == "deflate" { + // the deflate coding is the zlib format (RFC 9110 8.4.1.2): a 2-byte header, the DEFLATE data, a 4-byte Adler-32 + z := r.body + if len(z) < 6 || int(z[0]) % 16 != 8 || (int(z[0]) * 256 + int(z[1])) % 31 != 0 || int(z[1]) / 32 % 2 != 0 { + return http.server.Status(http.BadRequest) + } + b, e := compress.flate.Decode(z[2:len(z) - 4], maxSize: maxBody) + return decoded(mediaType(r), b, e) + } + b, e := compress.gzip.Decode(r.body, maxSize: maxBody) + return decoded(mediaType(r), b, e) + } + mt := mediaType(r) + if mt == "multipart/form-data" { + _ := http.server.Multipart(r) catch return http.server.Status(http.BadRequest) + return http.server.Text("ok") + } + return parsed(mt, r.body) +} + +func decoded(mt string, b []byte, e error?) http.server.Response { + return switch e { + case nil: parsed(mt, b) + case compress.flate.TooLarge{}: http.server.Status(http.ContentTooLarge) + default: http.server.Status(http.BadRequest) + } +} + +// A request header's value, lower case and trimmed ("" when absent) +func field(r http.server.Request, name string) string { + v := http.server.Header(r, name) + if v == nil { + return "" + } + return strings.ToLower(strings.TrimSpace(v)) +} + +// The media type of the request, lower case, without its parameters +func mediaType(r http.server.Request) string { + mt, _, _ := strings.Cut(field(r, "content-type"), ";") + return strings.TrimSpace(mt) +} + +// JSON and form bodies are parsed; any other type is only buffered (a multipart body that came in a Content-Encoding too) +func parsed(mt string, b []byte) http.server.Response { + if mt == "application/json" { + _ := json.Parse(b) catch return http.server.Status(http.BadRequest) + } else if mt == "application/x-www-form-urlencoded" { + q := string(b) catch return http.server.Status(http.BadRequest) + _ := url.ParseQuery(q) catch return http.server.Status(http.BadRequest) + } + return http.server.Text("ok") +} + func routes(ds []Item) []http.server.Route { none := []http.server.Middleware{} return []http.server.Route{ @@ -135,6 +200,7 @@ func routes(ds []Item) []http.server.Route { http.server.Route{method: "GET", path: "/delay/:ms", handler: delay, middleware: none}, http.server.Route{method: "GET", path: "/json/:count", handler: (r) => items(ds, r), middleware: none, cache: http.server.Unstated{}}, http.server.Route{method: "POST", path: "/echo", handler: echo, middleware: none}, + http.server.Route{method: "POST", path: "/parse", handler: parse, middleware: none}, http.server.Route{method: "GET", path: "/spec", handler: specText, middleware: none}, http.server.Route{method: "OPTIONS", path: "/spec", handler: specOptions, middleware: none}, http.server.Route{method: "POST", path: "/spec", handler: echo, middleware: none}, diff --git a/frameworks/sober/meta.json b/frameworks/sober/meta.json index c6dea671eb..ac323c1af7 100644 --- a/frameworks/sober/meta.json +++ b/frameworks/sober/meta.json @@ -13,6 +13,7 @@ "description": "Sober's standard library HTTP/1.1 server (std/http on std/net, TLS 1.3 from std/tls), default configuration. One task per connection; one io_uring and one SO_REUSEPORT listener per worker — each worker accepts on its own ring and runs the connection itself (epoll fallback), with workers pinned one per CPU. Routes are a plain table ([]http.Route with method, :param / *rest patterns, Mount / Merge, before / after middleware), JSON through std/json, gzip through the built-in compression: option of the server. /async-db through std/pg, the standard library's own PostgreSQL client (wire protocol 3.0, extended query, SCRAM-SHA-256) and its connection pool (pg.OpenPool / pg.With) sized from DATABASE_MAX_CONN. Static ELF with no libc, FROM scratch.", "repo": "https://github.com/sober-lang/sober", "enabled": true, + "resilience": true, "tests": [ "baseline", "pipelined", diff --git a/site/data/frameworks.json b/site/data/frameworks.json index 74fef4a2ab..16d35c1789 100644 --- a/site/data/frameworks.json +++ b/site/data/frameworks.json @@ -53,7 +53,7 @@ }, "aegon": { "dir": "aegon", - "description": "Linux-native C++26 asynchronous web framework powered by io_uring multishot primitives, coroutines, stepped SIMD vectorization, Glaze JSON serialization, and native zero-overhead gRPC over HTTP/2 with kTLS TX offload.", + "description": "Linux-native C++26 asynchronous web framework on io_uring: one event loop per core with multishot accept and recv over provided buffer rings, requests parsed in place from the receive buffer, coroutine handlers with userspace timers, Glaze JSON serialization, and gzip/deflate (libdeflate) and brotli compression middleware. Static files are served from a per-worker cache that follows the disk through inotify, with precompressed .br/.gz variants. TLS 1.3 through OpenSSL with a zero-copy connection BIO and ALPN; HTTP/2 and HTTP/3 (QUIC) with pooled streams; WebSocket; native gRPC over HTTP/2.", "repo": "https://github.com/UdayKhare09/Aegon", "type": "experimental", "engine": "io_uring", diff --git a/site/data/results/sober.json b/site/data/results/sober.json index 593dfc1dd6..610157bc01 100644 --- a/site/data/results/sober.json +++ b/site/data/results/sober.json @@ -4,44 +4,44 @@ "8gbit-512": { "framework": "sober", "language": "Sober", - "rps": 49379, - "avg_latency": "85.0us", - "p99_latency": "112.0us", - "cpu": "226.5%", - "memory": "144MiB", + "rps": 49353, + "avg_latency": "93.6us", + "p99_latency": "119.0us", + "cpu": "235.9%", + "memory": "153MiB", "connections": 512, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "510.88MB/s", - "input_bw": "482.22MB/s", + "bandwidth": "512.43MB/s", + "input_bw": "481.96MB/s", "reconnects": 0, - "status_2xx": 246968, + "status_2xx": 246837, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0, - "cpu_usec": 10931736, - "cpu_per_req_us": 44.2638, + "cpu_usec": 11224680, + "cpu_per_req_us": 45.4741, "target_rate": 50000, - "rate_ratio": 0.9876, - "p99_9_latency": "3127.0us" + "rate_ratio": 0.9871, + "p99_9_latency": "6622.0us" }, "async-32000": { "framework": "sober", "language": "Sober", - "rps": 2881130, - "avg_latency": "11.02ms", + "rps": 2858726, + "avg_latency": "11.20ms", "p99_latency": "12.50ms", - "cpu": "6299.3%", - "memory": "586MiB", + "cpu": "6317.9%", + "memory": "669MiB", "connections": 32000, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "247.22MB/s", - "input_bw": "131.89MB/s", + "bandwidth": "346.16MB/s", + "input_bw": "130.86MB/s", "reconnects": 0, - "status_2xx": 28811302, + "status_2xx": 28587269, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 @@ -49,19 +49,19 @@ "async-db-1024": { "framework": "sober", "language": "Sober", - "rps": 53730, - "avg_latency": "18.71ms", - "p99_latency": "154.60ms", - "cpu": "6127.3%", - "memory": "308MiB", + "rps": 241749, + "avg_latency": "4.23ms", + "p99_latency": "55.50ms", + "cpu": "5233.7%", + "memory": "328MiB", "connections": 1024, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "207.34MB/s", - "input_bw": "3.59MB/s", - "reconnects": 21090, - "status_2xx": 537304, + "bandwidth": "940.81MB/s", + "input_bw": "16.14MB/s", + "reconnects": 96400, + "status_2xx": 2417490, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 @@ -69,19 +69,19 @@ "baseline-4096": { "framework": "sober", "language": "Sober", - "rps": 3814271, - "avg_latency": "1.07ms", - "p99_latency": "1.58ms", - "cpu": "6256.2%", + "rps": 3694601, + "avg_latency": "1.11ms", + "p99_latency": "1.62ms", + "cpu": "6506.6%", "memory": "151MiB", "connections": 4096, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "327.29MB/s", - "input_bw": "294.64MB/s", + "bandwidth": "447.35MB/s", + "input_bw": "285.40MB/s", "reconnects": 0, - "status_2xx": 19071358, + "status_2xx": 18473005, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 @@ -89,19 +89,19 @@ "json-comp-16384": { "framework": "sober", "language": "Sober", - "rps": 736040, - "avg_latency": "22.05ms", - "p99_latency": "58.90ms", - "cpu": "6712.1%", - "memory": "514MiB", + "rps": 708974, + "avg_latency": "23.11ms", + "p99_latency": "61.60ms", + "cpu": "6345.0%", + "memory": "519MiB", "connections": 16384, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "979.94MB/s", - "input_bw": "54.75MB/s", - "reconnects": 139906, - "status_2xx": 3680201, + "bandwidth": "968.88MB/s", + "input_bw": "52.74MB/s", + "reconnects": 134639, + "status_2xx": 3544874, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 @@ -109,19 +109,19 @@ "json-comp-4096": { "framework": "sober", "language": "Sober", - "rps": 759089, - "avg_latency": "5.37ms", - "p99_latency": "19.20ms", - "cpu": "6619.6%", - "memory": "216MiB", + "rps": 718761, + "avg_latency": "5.69ms", + "p99_latency": "20.50ms", + "cpu": "6581.3%", + "memory": "220MiB", "connections": 4096, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "1010.61MB/s", - "input_bw": "56.47MB/s", - "reconnects": 150695, - "status_2xx": 3795446, + "bandwidth": "982.23MB/s", + "input_bw": "53.47MB/s", + "reconnects": 142402, + "status_2xx": 3593805, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 @@ -129,18 +129,18 @@ "json-tls-4096": { "framework": "sober", "language": "Sober", - "rps": 1825031, - "avg_latency": "1.38ms", - "p99_latency": "39.88ms", - "cpu": "6169.9%", - "memory": "328MiB", + "rps": 1831341, + "avg_latency": "2.05ms", + "p99_latency": "54.01ms", + "cpu": "6285.0%", + "memory": "324MiB", "connections": 4096, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "6.11GB", + "bandwidth": "6.19GB", "reconnects": 0, - "status_2xx": 9307056, + "status_2xx": 9341475, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 @@ -148,91 +148,91 @@ "latency-10k-1024": { "framework": "sober", "language": "Sober", - "rps": 9980, - "avg_latency": "95.9us", - "p99_latency": "107.0us", - "cpu": "26.4%", - "memory": "94MiB", + "rps": 9982, + "avg_latency": "83.3us", + "p99_latency": "111.0us", + "cpu": "26.8%", + "memory": "96MiB", "connections": 1024, "threads": 64, "duration": "20s", "pipeline": 1, - "bandwidth": "0.89MB/s", + "bandwidth": "1.26MB/s", "reconnects": 0, - "status_2xx": 199626, + "status_2xx": 199657, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0, - "cpu_usec": 5370047, - "cpu_per_req_us": 26.9005, + "cpu_usec": 5442451, + "cpu_per_req_us": 27.259, "target_rate": 10000, - "rate_ratio": 0.998, - "p99_9_latency": "13084.0us" + "rate_ratio": 0.9982, + "p99_9_latency": "4234.0us" }, "latency-1m-1024": { "framework": "sober", "language": "Sober", - "rps": 997489, - "avg_latency": "95.5us", + "rps": 997801, + "avg_latency": "94.8us", "p99_latency": "165.0us", - "cpu": "2332.8%", - "memory": "118MiB", + "cpu": "2333.6%", + "memory": "119MiB", "connections": 1024, "threads": 64, "duration": "20s", "pipeline": 1, - "bandwidth": "88.78MB/s", + "bandwidth": "125.72MB/s", "reconnects": 0, - "status_2xx": 19953111, + "status_2xx": 19959332, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0, - "cpu_usec": 423619937, - "cpu_per_req_us": 21.2308, + "cpu_usec": 422885029, + "cpu_per_req_us": 21.1873, "target_rate": 1000000, - "rate_ratio": 0.9975, - "p99_9_latency": "2883.0us" + "rate_ratio": 0.9978, + "p99_9_latency": "3431.0us" }, "latency-500k-8cpu-1024": { "framework": "sober", "language": "Sober", - "rps": 478220, - "avg_latency": "408492.0us", - "p99_latency": "2313216.0us", - "cpu": "807.8%", - "memory": "40MiB", + "rps": 475790, + "avg_latency": "442858.6us", + "p99_latency": "2378752.0us", + "cpu": "813.8%", + "memory": "43MiB", "connections": 1024, "threads": 64, "duration": "20s", "pipeline": 1, - "bandwidth": "42.56MB/s", + "bandwidth": "59.95MB/s", "reconnects": 0, - "status_2xx": 9566166, + "status_2xx": 9518392, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0, - "cpu_usec": 158124517, - "cpu_per_req_us": 16.5296, + "cpu_usec": 158854588, + "cpu_per_req_us": 16.6892, "target_rate": 500000, - "rate_ratio": 0.9564, - "p99_9_latency": "2495488.0us" + "rate_ratio": 0.9516, + "p99_9_latency": "2569216.0us" }, "limited-conn-4096": { "framework": "sober", "language": "Sober", - "rps": 2695755, - "avg_latency": "1.39ms", - "p99_latency": "2.25ms", - "cpu": "6067.4%", - "memory": "211MiB", + "rps": 2636808, + "avg_latency": "1.42ms", + "p99_latency": "2.28ms", + "cpu": "5884.0%", + "memory": "212MiB", "connections": 4096, "threads": 64, "duration": "5s", "pipeline": 1, - "bandwidth": "231.28MB/s", - "input_bw": "208.24MB/s", - "reconnects": 1346875, - "status_2xx": 13478779, + "bandwidth": "319.27MB/s", + "input_bw": "203.69MB/s", + "reconnects": 1318473, + "status_2xx": 13184044, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 @@ -240,18 +240,18 @@ "pipelined-4096": { "framework": "sober", "language": "Sober", - "rps": 34639029, - "avg_latency": "1.89ms", - "p99_latency": "2.43ms", - "cpu": "6459.6%", - "memory": "149MiB", + "rps": 28017753, + "avg_latency": "2.34ms", + "p99_latency": "3.03ms", + "cpu": "6485.6%", + "memory": "147MiB", "connections": 4096, "threads": 64, "duration": "5s", "pipeline": 16, - "bandwidth": "2.90GB/s", + "bandwidth": "3.31GB/s", "reconnects": 0, - "status_2xx": 173195149, + "status_2xx": 140088768, "status_3xx": 0, "status_4xx": 0, "status_5xx": 0 diff --git a/site/data/spec/sober.json b/site/data/spec/sober.json index 7403bd4dbe..17dd697ada 100644 --- a/site/data/spec/sober.json +++ b/site/data/spec/sober.json @@ -5,41 +5,10 @@ "h1": { "tool": "http11probe", "version": "d50d818", - "passed": 155, + "passed": 159, "total": 159, "warnings": 20, - "failed": [ - { - "id": "COMP-OPTIONS-STAR", - "test": "OPTIONS * is the only valid asterisk-form request", - "expected": "2xx or 405; close/timeout = warn", - "got": "404, connection left open", - "rfc": "RFC 9112 \u00a73.2.4", - "level": "Must" - }, - { - "id": "COMP-DATE-HEADER", - "test": "Origin server must include Date header in responses", - "expected": "2xx with Date header", - "got": "200, connection left open", - "rfc": "RFC 9110 \u00a76.6.1", - "level": "Must" - }, - { - "id": "MAL-NON-ASCII-URL", - "test": "Non-ASCII bytes (UTF-8 \u00e9) in URL must be rejected", - "expected": "400 or close", - "got": "404, connection left open", - "level": "Must" - }, - { - "id": "MAL-CHUNK-SIZE-OVERFLOW", - "test": "Chunk size with integer overflow must be rejected", - "expected": "400 or close", - "got": "413, connection closed", - "level": "Must" - } - ] + "failed": [] } } } diff --git a/site/static/logs/8gbit/512/sober.log b/site/static/logs/8gbit/512/sober.log index 1bc9ba41c6..02dd2bd98e 100644 --- a/site/static/logs/8gbit/512/sober.log +++ b/site/static/logs/8gbit/512/sober.log @@ -1,2 +1,2 @@ -tls-ready 8081 ready 8080 +tls-ready 8081 diff --git a/site/static/logs/async-db/1024/sober.log b/site/static/logs/async-db/1024/sober.log index 1bc9ba41c6..02dd2bd98e 100644 --- a/site/static/logs/async-db/1024/sober.log +++ b/site/static/logs/async-db/1024/sober.log @@ -1,2 +1,2 @@ -tls-ready 8081 ready 8080 +tls-ready 8081 diff --git a/site/static/logs/async/32000/sober.log b/site/static/logs/async/32000/sober.log index 02dd2bd98e..1bc9ba41c6 100644 --- a/site/static/logs/async/32000/sober.log +++ b/site/static/logs/async/32000/sober.log @@ -1,2 +1,2 @@ -ready 8080 tls-ready 8081 +ready 8080 diff --git a/site/static/logs/baseline/4096/sober.log b/site/static/logs/baseline/4096/sober.log index 1bc9ba41c6..02dd2bd98e 100644 --- a/site/static/logs/baseline/4096/sober.log +++ b/site/static/logs/baseline/4096/sober.log @@ -1,2 +1,2 @@ -tls-ready 8081 ready 8080 +tls-ready 8081 diff --git a/site/static/logs/json-tls/4096/sober.log b/site/static/logs/json-tls/4096/sober.log index 1bc9ba41c6..02dd2bd98e 100644 --- a/site/static/logs/json-tls/4096/sober.log +++ b/site/static/logs/json-tls/4096/sober.log @@ -1,2 +1,2 @@ -tls-ready 8081 ready 8080 +tls-ready 8081 diff --git a/site/static/logs/limited-conn/4096/sober.log b/site/static/logs/limited-conn/4096/sober.log index 1bc9ba41c6..02dd2bd98e 100644 --- a/site/static/logs/limited-conn/4096/sober.log +++ b/site/static/logs/limited-conn/4096/sober.log @@ -1,2 +1,2 @@ -tls-ready 8081 ready 8080 +tls-ready 8081 diff --git a/site/static/logs/pipelined/4096/sober.log b/site/static/logs/pipelined/4096/sober.log index 1bc9ba41c6..02dd2bd98e 100644 --- a/site/static/logs/pipelined/4096/sober.log +++ b/site/static/logs/pipelined/4096/sober.log @@ -1,2 +1,2 @@ -tls-ready 8081 ready 8080 +tls-ready 8081