From 799db82be811a1fe503aafeec8c6102a6f499d12 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 3 Dec 2026 13:21:32 +0100 Subject: [PATCH] Describe what keeps the parser fast, add contributor notes --- CLAUDE.md | 4 ++++ README.md | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..f10b16a --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,4 @@ +# php-parser-in-rust + +- When a change moves the performance numbers, update the benchmark table in `README.md` in the same PR. Take the numbers from the **Summary** of the Benchmark workflow run on that PR, not from a local run. +- The dump must stay byte-identical to the Go parser. Check with `tools/diff-corpus.sh ` and `cargo test`. diff --git a/README.md b/README.md index 64f34ff..cfcbcb8 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ CI reruns this on every push and every 12 hours, see the **Summary** of the Benc bench/compare.sh ./laravel ``` +What keeps it fast: + +- the whole tree lives in one arena, so there is no allocation per node and nothing to free node by node +- the lexer allocates each token once; nodes hold a reference to it +- comments and strings are scanned with SIMD search (`memchr`) + ## Usage ```rust