You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: V8_OPTIMIZATIONS.md
+51-60Lines changed: 51 additions & 60 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,87 +4,78 @@ This document describes the V8-inspired optimizations implemented in the aarch64
4
4
5
5
## Overview
6
6
7
-
The optimizations are based on techniques used in V8's high-performance JSON.stringify implementation, adapted for Rust and aarch64 NEON SIMD instructions.
7
+
The optimizations are based on the core V8 insight: **optimize for the common case where most data needs NO escaping**. Rather than trying to vectorize escape processing, we use SIMD for fast detection and bulk copy operations for clean data.
8
8
9
9
## Key Optimizations Implemented
10
10
11
-
### 1. Bit-based Character Classification
12
-
-**Before**: Used table lookup (`vqtbl4q_u8`) with a 256-byte escape table
13
-
-**After**: Uses bit operations to classify characters needing escape:
11
+
### 1. Fast Clean Detection with SIMD
12
+
-**Approach**: Use NEON SIMD to rapidly check 64-byte chunks for escape characters
13
+
-**Implementation**: Single SIMD operation checks for:
14
14
- Control characters: `< 0x20`
15
15
- Quote character: `== 0x22`
16
16
- Backslash character: `== 0x5C`
17
-
-**Benefit**: Reduced memory footprint and better cache efficiency
18
-
19
-
### 2. ASCII Fast Path Detection
20
-
-**New**: `is_ascii_clean_chunk()` function to quickly identify chunks that need no escaping
21
-
-**Implementation**: Single SIMD pass to check if entire 64-byte chunk is clean
22
-
-**Benefit**: Bulk copy for clean text, avoiding character-by-character processing
23
-
24
-
### 3. Advanced Memory Prefetching
25
-
-**Before**: Single prefetch instruction `PREFETCH_DISTANCE` ahead
26
-
-**After**: Dual prefetch instructions covering more cache lines
0 commit comments