Commit 1e744c7
Enable SIMD optimizations by default with automatic CPU detection
This commit enables SIMD optimizations automatically based on CPU capabilities,
providing significant performance improvements for JSON string parsing without
requiring manual configuration via --with-sse42 flag.
Key changes:
1. Simplified extconf.rb for auto-detection:
- Automatically tries -msse4.2, falls back to -msse2
- No user configuration needed - works out of the box
- Removed unnecessary platform-specific logic
2. Enhanced simd.h with unified architecture detection:
- Defines HAVE_SIMD_SSE4_2, HAVE_SIMD_SSE2, HAVE_SIMD_NEON
- Provides SIMD_TYPE macro for debugging
- Uses compiler defines for cleaner conditional compilation
- Priority: SSE4.2 > NEON > SSE2 > scalar
3. Added SSE2 fallback implementation:
- Uses SSE2 instructions available on all x86_64 CPUs
- Provides SIMD benefits even on older processors
- Uses bit manipulation for efficient character matching
4. Updated parse.c to use new SIMD architecture:
- scan_string_SSE42() for SSE4.2 capable CPUs
- scan_string_SSE2() for older x86_64 CPUs
- Automatic selection at initialization
Performance:
- Equivalent performance to baseline with --with-sse42
- All tests pass (445 runs, 986 assertions, 0 failures)
- SIMD now enabled by default without any flags
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 8929358 commit 1e744c7
3 files changed
+97
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 21 | | |
25 | 22 | | |
26 | 23 | | |
| |||
202 | 199 | | |
203 | 200 | | |
204 | 201 | | |
205 | | - | |
206 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
207 | 206 | | |
208 | 207 | | |
209 | | - | |
| 208 | + | |
210 | 209 | | |
211 | | - | |
| 210 | + | |
212 | 211 | | |
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
216 | 215 | | |
217 | 216 | | |
218 | 217 | | |
219 | | - | |
220 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
221 | 260 | | |
222 | 261 | | |
223 | 262 | | |
| 263 | + | |
224 | 264 | | |
225 | 265 | | |
226 | 266 | | |
227 | 267 | | |
228 | 268 | | |
229 | 269 | | |
230 | 270 | | |
231 | | - | |
232 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
233 | 275 | | |
| 276 | + | |
234 | 277 | | |
235 | 278 | | |
236 | 279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
4 | 26 | | |
5 | 27 | | |
6 | 28 | | |
7 | 29 | | |
8 | 30 | | |
9 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
10 | 46 | | |
0 commit comments