From eb37aad3ae7f9df1d6c0b09108e3a2d69d0d4d82 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sun, 27 Sep 2026 07:30:51 +0100 Subject: Read JSON bodies in place, groups included (082) pure-serve no longer copies a JSON body's strings into the message's payload. The ingress is the prefix, a table of each field's start and size, and the body as it came; the connection thread scans the body once, puts numbers into the prefix and records where each string is. Only a string with escapes is unescaped, over itself (it never grows). A group of fields comes as an object inside the body and, for a fixed field, as its path in the query (?to.zip=7). A group where a field belongs, a value where a group does, an array or true/false/null is json_type; an unknown member, inside a group too, json_field. The string scan and UTF-8 checks now pass over eight bytes at a time while none needs a look (pure_utf8_step, so every text check gains). On the Pi, posting {"name":"k","text":"x..."} to a stateless app went from 652-655 to 3,737-3,953 requests/s with 256 KiB of text (server CPU 1.52 to 0.25 ms a request, peak RSS 5.2 to 3.2-3.4 MiB) and from 29.1k to 76.3-76.7k/s with 4 KiB; the load generator gains a json method and benchmarks/http/echo.aup is the app. --- benchmarks/http/echo.aup | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 benchmarks/http/echo.aup (limited to 'benchmarks/http/echo.aup') diff --git a/benchmarks/http/echo.aup b/benchmarks/http/echo.aup new file mode 100644 index 0000000..cac3e04 --- /dev/null +++ b/benchmarks/http/echo.aup @@ -0,0 +1,5 @@ +input echo = message { + name: text + text: text +} +on echo { reply echo.name } -- cgit v1.2.3