`json_encode` can use SIMD
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The current json_encode implementation [1] iterates on every string character.
I belive there is a potential to utilize SIMD to copy multiple characters to the output string as long as they are not to-be-escaped.
Benchmark: https://3v4l.org/XeJTn/rfc#vgit.master
This can improve performace on applications that do a lot of JSON encoding.
[1] https://github.com/php/php-src/blob/php-8.4.3/ext/json/json_encoder.c#L411
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ext/json/json_encoder.c around line 411 and compare the current character-by-character encoding with the benchmark at https://3v4l.org/XeJTn/rfc#vgit.master. Review open pull request #17734 before starting, since it is already addressing this issue. Done means a SIMD-based implementation is evaluated against the existing benchmark without changing escaping behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100