Skip to content

JSON logs 5x faster, IIS 2.4x - #8

Merged
FMXExpress merged 1 commit into
mainfrom
json-fast
Oct 31, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
json-fast

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Speed on one core, --test, rules only:

main now
nginx JSON (200k lines) 19–21k lines/s 91–100k
IIS W3C 54–59k 127–150k
Apache text / flood 137–149k / 32–37k unchanged

Every decision line (-v) is identical to main on the JSON, IIS, typical and flood files, and the three formats still agree with each other in bench/formats.py.

Changes

  • A small JSON scanner replaces the fpjson tree. It reads each line in one pass into a flat node list (key, kind, text, parent). The field extraction reads that list, so key aliases, Caddy's nested request and header arrays, and Traefik's ip:port all work as before.
  • fpjson remains the fallback. Lines the scanner doesn't handle exactly as fpjson would go to fpjson: surrogate \u escapes, duplicate keys, nesting deeper than 16, -0 or leading zeros, integers over 18 digits, or trailing text. fpjson's tree is converted into the same node list, so there is still only one extraction path.
  • ApacheEscape (shared with IIS): it returns its input unchanged when there's nothing to escape, which is nearly always, and otherwise writes in place.
  • Line timestamps are formatted once per second instead of once per line.

Checked against fpjson

  • 200,007 JSON lines from the benchmark file plus fixtures: the scanner's node list equals fpjson's on every line. Numbers are compared by value, because their readers use TryStrToFloat or StrToIntDef and get the same result either way.
  • Unit tests cover escapes, nesting, arrays, numbers, and the lines left to fpjson.
  • ApacheEscape is checked against its definition on all 256 byte values.

One deliberate difference: non-ASCII

fpjson turned raw UTF-8 into ? plus stray bytes, and é into a single ANSI byte, which corrupted non-ASCII user agents and paths before the signatures saw them. The scanner keeps the bytes and decodes \u escapes to UTF-8. ApacheEscape then logs them as \xhh, the way Apache does. nginx's escape=json only writes \u00XX for control characters, and there both parsers agree.

Unit tests: 177 checks, 0 failed (24 new). Iteration notes are in bench/results/iter8-json/README.md.


Generated by Claude Code

A JSON line is read by a small scanner into a flat node list instead of an
fpjson tree; lines it does not take exactly as fpjson would go to fpjson,
whose tree becomes the same node list (one extraction path). On 200,007 lines
the node lists equal fpjson's. ApacheEscape returns its input when there is
nothing to escape, and the line time is formatted once per second.
nginx JSON 19-21k -> 91-100k lines/s, IIS 54-59k -> 127-150k.

Non-ASCII is now kept (fpjson turned raw UTF-8 into '?' and \u00e9 into an
ANSI byte); it is logged as \xhh, as Apache does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJFY41846T15QqxmGW2
@FMXExpress
FMXExpress merged commit 313a6ec into main Oct 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants