Commit e709ec7
authored
Refactor JSON string writing and escaping logic (#638)
This PR significantly improves JSON response serialization (response
projection) performance (50% faster) by replacing the existing
character-by-character string escaping logic with a SIMD-accelerated
implementation adapted from
[sonic-rs](https://github.com/cloudwego/sonic-rs).
I also improved `estimate_final_response_size()` with 20% buffer for
JSON overhead, that according to the tests I did and responses in the
federation audit, is a good estimate.
This code is complex and challenging to maintain, due to the low-level
SIMD operations, unsafe pointer manipulation, and platform-specific
optimizations. However, the previous implementation was also difficult
to maintain in its own way.
The key advantage here is that we're leveraging battle-tested code from
`sonic-rs`, a library we already depend on indirectly.1 parent 3f78260 commit e709ec7
File tree
5 files changed
+535
-68
lines changed- .changeset
- lib/executor
- src
- response
5 files changed
+535
-68
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
0 commit comments