mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
## Summary Apply the same optimization technique from PR #25717 (Response.json) to other APIs that use JSON.stringify internally: - **IPC message serialization** (`ipc.zig`) - used for inter-process communication - **console.log with %j format** (`ConsoleObject.zig`) - commonly used for debugging - **PostgreSQL JSON/JSONB types** (`PostgresRequest.zig`) - database operations - **MySQL JSON type** (`MySQLTypes.zig`) - database operations - **Jest %j/%o format specifiers** (`jest.zig`) - test output formatting - **Transpiler tsconfig/macros** (`JSTranspiler.zig`) - build configuration ### Root Cause When calling `JSONStringify(globalObject, value, 0)`, the space parameter `0` becomes `jsNumber(0)`, which is NOT `undefined`. This causes JSC's FastStringifier (SIMD-optimized) to bail out: ```cpp // In WebKit's JSONObject.cpp FastStringifier::stringify() if (!space.isUndefined()) { logOutcome("space"_s); return { }; // Bail out to slow path } ``` Using `jsonStringifyFast` which passes `jsUndefined()` triggers the fast path. ### Expected Performance Improvement Based on PR #25717 results, these changes should provide ~3x speedup for JSON serialization in the affected APIs. ## Test plan - [x] Debug build compiles successfully - [x] Basic functionality verified (IPC, console.log %j, Response.json) - [x] Existing tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>