Commit 684a25a
Perf: SIMD + FFI speedups across hex/bytes APIs (#41)
* Wave 2a: PyO3 FFI performance refactor
§1 Wire SIMD into check_hexstrings_within_dist for len >= 64
§5 Zero-copy PyBuffer for all byte-input functions
§9 set_algo delegates to api::set_algorithm
§10 Direct typed params in pyfunction signatures
§12 Vec::with_capacity in check_bytes_arrays_all_within_dist
§14 Consolidate python.rs thin wrappers over api dispatch
17 new tests for buffer-protocol, SIMD-path, set_algo.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add SIMD early-exit for check_hexstrings_within_dist
Add _with_max variants to all SIMD hex string distance functions
(NEON, SSE4.1, AVX2, AVX-512) that check accumulated distance
against max_dist after each iteration and return u64::MAX sentinel
when exceeded. This restores early-exit performance for the
random+tight workload without regressing the similar-strings case.
New functions:
- neon_simd::hamming_distance_string_neon_pack_with_max
- x86_simd::hamming_distance_string_sse_with_max
- x86_simd::hamming_distance_string_avx2_with_max
- x86_simd::hamming_distance_string_avx512_with_max
- lib::hamming_distance_string_dispatch_with_max
Performance (1024 hex chars):
- random, max=100: 0.192 us -> 0.072 us (2.7x faster, beats baseline)
- similar, max=10: 0.193 us -> 0.183 us (no regression)
- similar, max=100: 0.195 us -> 0.183 us (no regression)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 4d2e7e6 commit 684a25a
13 files changed
Lines changed: 2624 additions & 589 deletions
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 | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
92 | 91 | | |
93 | 92 | | |
94 | 93 | | |
95 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
| 99 | + | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | | - | |
| 103 | + | |
| 104 | + | |
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
| |||
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
111 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
112 | 117 | | |
113 | 118 | | |
114 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
115 | 122 | | |
116 | 123 | | |
117 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
118 | 127 | | |
119 | 128 | | |
120 | 129 | | |
| |||
128 | 137 | | |
129 | 138 | | |
130 | 139 | | |
131 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
132 | 143 | | |
133 | 144 | | |
134 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
135 | 148 | | |
136 | 149 | | |
137 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
138 | 182 | | |
139 | 183 | | |
140 | 184 | | |
| |||
153 | 197 | | |
154 | 198 | | |
155 | 199 | | |
156 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
157 | 208 | | |
158 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
159 | 216 | | |
0 commit comments