usearch 2.9.2 → 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +39 -38
  2. package/javascript/{types → dist/cjs}/usearch.d.ts +90 -115
  3. package/javascript/dist/cjs/usearch.js +531 -0
  4. package/javascript/dist/esm/usearch.d.ts +212 -0
  5. package/javascript/{usearch.js → dist/esm/usearch.js} +199 -153
  6. package/package.json +25 -23
  7. package/prebuilds/darwin-arm64+x64/usearch.node +0 -0
  8. package/prebuilds/linux-arm64/usearch.node +0 -0
  9. package/prebuilds/linux-x64/usearch.node +0 -0
  10. package/prebuilds/win32-ia32/usearch.node +0 -0
  11. package/prebuilds/win32-x64/usearch.node +0 -0
  12. package/.clang-format +0 -10
  13. package/.clang-tidy +0 -60
  14. package/.cmake-format.py +0 -19
  15. package/.dockerignore +0 -93
  16. package/.gitattributes +0 -9
  17. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -90
  18. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  19. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -64
  20. package/.github/workflows/Dockerfile.libs +0 -36
  21. package/.github/workflows/prerelease.yml +0 -331
  22. package/.github/workflows/release.yml +0 -722
  23. package/.github/workflows/update_version.sh +0 -15
  24. package/.gitmodules +0 -9
  25. package/.releaserc +0 -90
  26. package/CITATION.cff +0 -11
  27. package/CMakeLists.txt +0 -324
  28. package/CODE_OF_CONDUCT.md +0 -128
  29. package/CONTRIBUTING.md +0 -361
  30. package/Cargo.toml +0 -19
  31. package/Dockerfile +0 -16
  32. package/VERSION +0 -1
  33. package/assets/unum.png +0 -0
  34. package/assets/usearch-approaches-transparent.png +0 -0
  35. package/assets/usearch-approaches-white.png +0 -0
  36. package/assets/usearch-neighbor-types.png +0 -0
  37. package/binding.gyp +0 -87
  38. package/build.gradle +0 -204
  39. package/build.rs +0 -18
  40. package/c/CMakeLists.txt +0 -25
  41. package/c/README.md +0 -34
  42. package/c/lib.cpp +0 -358
  43. package/c/test.c +0 -382
  44. package/c/usearch.h +0 -311
  45. package/cmake/clipp.cmake +0 -7
  46. package/cmake/config.cmake.in +0 -15
  47. package/cmake/emscripten.cmake +0 -8
  48. package/cmake/jemalloc.cmake +0 -62
  49. package/cmake/pkg-config.pc.in +0 -4
  50. package/cmake/usearchConfigVersion.cmake.in +0 -20
  51. package/conanfile.py +0 -26
  52. package/cpp/CMakeLists.txt +0 -14
  53. package/cpp/README.md +0 -161
  54. package/cpp/bench.cpp +0 -618
  55. package/cpp/test.cpp +0 -323
  56. package/fp16/CMakeLists.txt +0 -176
  57. package/fp16/LICENSE +0 -11
  58. package/fp16/README.md +0 -20
  59. package/fp16/bench/alt-element.cc +0 -89
  60. package/fp16/bench/from-alt-array.cc +0 -175
  61. package/fp16/bench/from-ieee-array.cc +0 -399
  62. package/fp16/bench/ieee-element.cc +0 -272
  63. package/fp16/bench/to-alt-array.cc +0 -91
  64. package/fp16/bench/to-ieee-array.cc +0 -303
  65. package/fp16/cmake/DownloadGoogleBenchmark.cmake +0 -15
  66. package/fp16/cmake/DownloadGoogleTest.cmake +0 -15
  67. package/fp16/cmake/DownloadPSimd.cmake +0 -15
  68. package/fp16/configure.py +0 -65
  69. package/fp16/confu.yaml +0 -8
  70. package/fp16/include/fp16/__init__.py +0 -0
  71. package/fp16/include/fp16/avx.py +0 -50
  72. package/fp16/include/fp16/avx2.py +0 -53
  73. package/fp16/include/fp16/bitcasts.h +0 -92
  74. package/fp16/include/fp16/fp16.h +0 -451
  75. package/fp16/include/fp16/psimd.h +0 -131
  76. package/fp16/include/fp16.h +0 -11
  77. package/fp16/jni/Android.mk +0 -6
  78. package/fp16/jni/Application.mk +0 -4
  79. package/fp16/test/alt-from-fp32-value.cc +0 -498
  80. package/fp16/test/alt-to-fp32-bits.cc +0 -263
  81. package/fp16/test/alt-to-fp32-psimd.cc +0 -145
  82. package/fp16/test/alt-to-fp32-value.cc +0 -348
  83. package/fp16/test/alt-to-fp32x2-psimd.cc +0 -245
  84. package/fp16/test/bitcasts.cc +0 -56
  85. package/fp16/test/ieee-from-fp32-value.cc +0 -523
  86. package/fp16/test/ieee-to-fp32-bits.cc +0 -333
  87. package/fp16/test/ieee-to-fp32-psimd.cc +0 -312
  88. package/fp16/test/ieee-to-fp32-value.cc +0 -420
  89. package/fp16/test/ieee-to-fp32x2-psimd.cc +0 -541
  90. package/fp16/test/peachpy/alt-xmm-to-fp32-xmm-avx.cc +0 -96
  91. package/fp16/test/peachpy/alt-xmm-to-fp32-ymm-avx2.cc +0 -96
  92. package/fp16/test/peachpy/stubs.py +0 -38
  93. package/fp16/test/tables.cc +0 -530
  94. package/fp16/test/tables.h +0 -13
  95. package/fp16/third-party/THHalf.h +0 -92
  96. package/fp16/third-party/eigen-half.h +0 -170
  97. package/fp16/third-party/float16-compressor.h +0 -80
  98. package/fp16/third-party/half.hpp +0 -2916
  99. package/fp16/third-party/npy-halffloat.h +0 -328
  100. package/include/usearch/index.hpp +0 -3836
  101. package/include/usearch/index_dense.hpp +0 -2004
  102. package/include/usearch/index_plugins.hpp +0 -2213
  103. package/javascript/lib.cpp +0 -341
  104. package/javascript/types/usearch.d.ts.map +0 -1
  105. package/javascript/usearch.test.js +0 -74
  106. package/package-ci.json +0 -10
  107. package/pyproject.toml +0 -51
  108. package/setup.py +0 -201
  109. package/simsimd/.releaserc +0 -86
  110. package/simsimd/CONTRIBUTING.md +0 -88
  111. package/simsimd/Cargo.lock +0 -709
  112. package/simsimd/Cargo.toml +0 -44
  113. package/simsimd/LICENSE +0 -201
  114. package/simsimd/README.md +0 -317
  115. package/simsimd/binding.gyp +0 -36
  116. package/simsimd/build.rs +0 -20
  117. package/simsimd/include/simsimd/binary.h +0 -245
  118. package/simsimd/include/simsimd/complex.h +0 -174
  119. package/simsimd/include/simsimd/probability.h +0 -548
  120. package/simsimd/include/simsimd/simsimd.h +0 -465
  121. package/simsimd/include/simsimd/spatial.h +0 -1267
  122. package/simsimd/include/simsimd/types.h +0 -208
  123. package/simsimd/javascript/bench.js +0 -127
  124. package/simsimd/javascript/fallback.ts +0 -193
  125. package/simsimd/javascript/lib.c +0 -102
  126. package/simsimd/javascript/node-gyp-build.d.ts +0 -1
  127. package/simsimd/javascript/simsimd.ts +0 -124
  128. package/simsimd/javascript/test.mjs +0 -153
  129. package/simsimd/javascript/tsconfig-base.json +0 -25
  130. package/simsimd/javascript/tsconfig-cjs.json +0 -8
  131. package/simsimd/javascript/tsconfig-esm.json +0 -8
  132. package/simsimd/package-lock.json +0 -1688
  133. package/simsimd/package.json +0 -61
  134. package/simsimd/rust/benches/cosine.rs +0 -27
  135. package/simsimd/rust/benches/native.rs +0 -30
  136. package/simsimd/rust/benches/sqeuclidean.rs +0 -27
  137. package/simsimd/rust/lib.c +0 -45
  138. package/simsimd/rust/lib.rs +0 -550
  139. package/sqlite/README.md +0 -178
  140. package/sqlite/lib.cpp +0 -325
  141. package/stringzilla/CONTRIBUTING.md +0 -446
  142. package/stringzilla/Cargo.lock +0 -25
  143. package/stringzilla/Cargo.toml +0 -26
  144. package/stringzilla/LICENSE +0 -201
  145. package/stringzilla/README.md +0 -1422
  146. package/stringzilla/VERSION +0 -1
  147. package/stringzilla/assets/cover-strinzilla.jpeg +0 -0
  148. package/stringzilla/assets/meme-stringzilla-v2.jpeg +0 -0
  149. package/stringzilla/assets/meme-stringzilla-v3.jpeg +0 -0
  150. package/stringzilla/binding.gyp +0 -16
  151. package/stringzilla/build.rs +0 -87
  152. package/stringzilla/c/lib.c +0 -337
  153. package/stringzilla/cli/README.md +0 -65
  154. package/stringzilla/cli/__init__.py +0 -0
  155. package/stringzilla/cli/split.py +0 -105
  156. package/stringzilla/cli/wc.py +0 -117
  157. package/stringzilla/include/stringzilla/experimental.h +0 -845
  158. package/stringzilla/include/stringzilla/module.modulemap +0 -9
  159. package/stringzilla/include/stringzilla/stringzilla.h +0 -5370
  160. package/stringzilla/include/stringzilla/stringzilla.hpp +0 -3838
  161. package/stringzilla/javascript/lib.c +0 -125
  162. package/stringzilla/javascript/stringzilla.js +0 -22
  163. package/stringzilla/package-ci.json +0 -10
  164. package/stringzilla/package.json +0 -32
  165. package/stringzilla/rust/lib.rs +0 -873
  166. package/stringzilla/swift/StringProtocol+StringZilla.swift +0 -280
  167. package/stringzilla/swift/Test.swift +0 -60
  168. package/tsconfig.json +0 -21
  169. package/wasmer.toml +0 -12
  170. package/winlibinstaller.bat +0 -42
  171. /package/{simsimd/javascript/dist-package-cjs.json → javascript/dist/cjs/package.json} +0 -0
  172. /package/{simsimd/javascript/dist-package-esm.json → javascript/dist/esm/package.json} +0 -0
@@ -1,446 +0,0 @@
1
- # Contributing to StringZilla
2
-
3
- Thank you for coming here! It's always nice to have third-party contributors 🤗
4
- Depending on the type of contribution, you may need to follow different steps.
5
-
6
- ---
7
-
8
- ## Project Structure
9
-
10
- The project is split into the following parts:
11
-
12
- - `include/stringzilla/stringzilla.h` - single-header C implementation.
13
- - `include/stringzilla/stringzilla.hpp` - single-header C++ wrapper.
14
- - `python/*` - Python bindings.
15
- - `javascript/*` - JavaScript bindings.
16
- - `scripts/*` - Scripts for benchmarking and testing.
17
-
18
- For minimal test coverage, check the following scripts:
19
-
20
- - `test.cpp` - tests C++ API (not underlying C) against STL.
21
- - `test.py` - tests Python API against native strings.
22
- - `test.js`.
23
-
24
- At the C++ level all benchmarks also validate the results against the STL baseline, serving as tests on real-world data.
25
- They have the broadest coverage of the library, and are the most important to keep up-to-date:
26
-
27
- - `bench_token.cpp` - token-level ops, like hashing, ordering, equality checks.
28
- - `bench_search.cpp` - bidirectional substring search, both exact and fuzzy.
29
- - `bench_similarity.cpp` - benchmark all edit distance backends.
30
- - `bench_sort.cpp` - sorting, partitioning, merging.
31
- - `bench_container.cpp` - STL containers with different string keys.
32
-
33
- The role of Python benchmarks is less to provide absolute number, but to compare against popular tools in the Python ecosystem.
34
-
35
- - `bench_search.(py|ipynb)` - compares against native Python `str`.
36
- - `bench_sort.(py|ipynb)` - compares against `pandas`.
37
- - `bench_similarity.(ipynb)` - compares against `jellyfish`, `editdistance`, etc.
38
-
39
- ## Benchmarking Datasets
40
-
41
- It's not always easy to find good datasets for benchmarking strings workloads.
42
- I use several ASCII and UTF8 international datasets.
43
- You can download them using the following commands:
44
-
45
- ```sh
46
- # English Leipzig Corpora Collection
47
- # 124 MB, 1'000'000 lines of ASCII, 8'388'608 tokens of mean length 5
48
- wget --no-clobber -O leipzig1M.txt https://introcs.cs.princeton.edu/python/42sort/leipzig1m.txt
49
-
50
- # Hutter Prize "enwik9" dataset for compression
51
- # 1 GB (0.3 GB compressed), 13'147'025 lines of ASCII, 67'108'864 tokens of mean length 6
52
- wget --no-clobber -O enwik9.zip http://mattmahoney.net/dc/enwik9.zip
53
- unzip enwik9.zip && rm enwik9.zip && mv enwik9 enwik9.txt
54
-
55
- # XL Sum dataset for multilingual extractive summarization
56
- # 4.7 GB (1.7 GB compressed), 1'004'598 lines of UTF8, 268'435'456 tokens of mean length 8
57
- wget --no-clobber -O xlsum.csv.gz https://github.com/ashvardanian/xl-sum/releases/download/v1.0.0/xlsum.csv.gz
58
- gzip -d xlsum.csv.gz
59
- ```
60
-
61
- ## IDE Integrations
62
-
63
- The project was originally developed in VS Code, and contains a set of configuration files for that IDE under `.vscode/`.
64
-
65
- - `tasks.json` - build tasks for CMake.
66
- - `launch.json` - debugger launchers for CMake.
67
- - `extensions.json` - recommended extensions for VS Code, including:
68
- - `ms-vscode.cpptools-themes` - C++ language support.
69
- - `ms-vscode.cmake-tools`, `cheshirekow.cmake-format` - CMake integration.
70
- - `ms-python.python`, `ms-python.black-formatter` - Python language support.
71
- - `yzhang.markdown-all-in-one` - formatting Markdown.
72
- - `aaron-bond.better-comments` - color-coded comments.
73
-
74
- ## Code Styling
75
-
76
- The project uses `.clang-format` to enforce a consistent code style.
77
- Modern IDEs, like VS Code, can be configured to automatically format the code on save.
78
-
79
- - East const over const West. Write `char const*` instead of `const char*`.
80
- - For color-coded comments start the line with `!` for warnings or `?` for questions.
81
- - Sort the includes: standard libraries, third-party libraries, and only then internal project headers.
82
-
83
- For C++ code:
84
-
85
- - Explicitly use `std::` or `sz::` namespaces over global `memcpy`, `uint64_t`, etc.
86
- - Explicitly mark `noexcept` or `noexcept(false)` for all library interfaces.
87
- - Document all possible exceptions of an interface using `@throw` in Doxygen.
88
- - Avoid C-style variadic arguments in favor of templates.
89
- - Avoid C-style casts in favor of `static_cast`, `reinterpret_cast`, and `const_cast`, except for places where a C function is called.
90
- - Use lower-case names for everything, except settings/conditions macros. Function-like macros, that take arguments, should be lowercase as well.
91
- - In templates prefer `typename` over `class`.
92
- - Prepend "private" symbols with `_` underscore.
93
-
94
- For Python code:
95
-
96
- - Use lower-case names for functions and variables.
97
-
98
- ## Contributing in C++ and C
99
-
100
- The primary C implementation and the C++ wrapper are built with CMake.
101
- Assuming the extensive use of new SIMD intrinsics and recent C++ language features, using a recent compiler is recommended.
102
- We prefer GCC 12, which is available from default Ubuntu repositories with Ubuntu 22.04 LTS onwards.
103
- If this is your first experience with CMake, use the following commands to get started:
104
-
105
- ```bash
106
- sudo apt-get update && sudo apt-get install cmake build-essential libjemalloc-dev g++-12 gcc-12 # Ubuntu
107
- brew install libomp llvm # MacOS
108
- ```
109
-
110
- ### Testing
111
-
112
- Using modern syntax, this is how you build and run the test suite:
113
-
114
- ```bash
115
- cmake -DSTRINGZILLA_BUILD_TEST=1 -B build_debug
116
- cmake --build ./build_debug --config Debug # Which will produce the following targets:
117
- ./build_debug/stringzilla_test_cpp20 # Unit test for the entire library compiled for current hardware
118
- ./build_debug/stringzilla_test_cpp20_x86_serial # x86 variant compiled for IvyBridge - last arch. before AVX2
119
- ./build_debug/stringzilla_test_cpp20_arm_serial # Arm variant compiled without Neon
120
- ```
121
-
122
- To use CppCheck for static analysis make sure to export the compilation commands.
123
- Overall, CppCheck and Clang-Tidy are extremely noisy and not suitable for CI, but may be useful for local development.
124
-
125
- ```bash
126
- sudo apt install cppcheck clang-tidy-11
127
-
128
- cmake -B build_artifacts \
129
- -DCMAKE_BUILD_TYPE=RelWithDebInfo \
130
- -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
131
- -DSTRINGZILLA_BUILD_BENCHMARK=1 \
132
- -DSTRINGZILLA_BUILD_TEST=1
133
-
134
- cppcheck --project=build_artifacts/compile_commands.json --enable=all
135
-
136
- clang-tidy-11 -p build_artifacts
137
- ```
138
-
139
- I'd recommend putting the following breakpoints:
140
-
141
- - `__asan::ReportGenericError` - to detect illegal memory accesses.
142
- - `__GI_exit` - to stop at exit points - the end of running any executable.
143
- - `__builtin_unreachable` - to catch all the places where the code is expected to be unreachable.
144
-
145
- ### Benchmarking
146
-
147
- For benchmarks, you can use the following commands:
148
-
149
- ```bash
150
- cmake -DSTRINGZILLA_BUILD_BENCHMARK=1 -B build_release
151
- cmake --build ./build_release --config Release # Which will produce the following targets:
152
- ./build_release/stringzilla_bench_search <path> # for substring search
153
- ./build_release/stringzilla_bench_token <path> # for hashing, equality comparisons, etc.
154
- ./build_release/stringzilla_bench_similarity <path> # for edit distances and alignment scores
155
- ./build_release/stringzilla_bench_sort <path> # for sorting arrays of strings
156
- ./build_release/stringzilla_bench_container <path> # for STL containers with string keys
157
- ```
158
-
159
- ### Benchmarking Hardware-Specific Optimizations
160
-
161
- Running on modern hardware, you may want to compile the code for older generations to compare the relative performance.
162
- The assumption would be that newer ISA extensions would provide better performance.
163
- On x86_64, you can use the following commands to compile for Sandy Bridge, Haswell, and Sapphire Rapids:
164
-
165
- ```bash
166
- cmake -DCMAKE_BUILD_TYPE=Release -DSTRINGZILLA_BUILD_BENCHMARK=1 \
167
- -DSTRINGZILLA_TARGET_ARCH="ivybridge" -B build_release/ivybridge && \
168
- cmake --build build_release/ivybridge --config Release
169
- cmake -DCMAKE_BUILD_TYPE=Release -DSTRINGZILLA_BUILD_BENCHMARK=1 \
170
- -DSTRINGZILLA_TARGET_ARCH="haswell" -B build_release/haswell && \
171
- cmake --build build_release/haswell --config Release
172
- cmake -DCMAKE_BUILD_TYPE=Release -DSTRINGZILLA_BUILD_BENCHMARK=1 \
173
- -DSTRINGZILLA_TARGET_ARCH="sapphirerapids" -B build_release/sapphirerapids && \
174
- cmake --build build_release/sapphirerapids --config Release
175
- ```
176
-
177
- ### Benchmarking Compiler-Specific Optimizations
178
-
179
- Alternatively, you may want to compare the performance of the code compiled with different compilers.
180
- On x86_64, you may want to compare GCC, Clang, and ICX.
181
-
182
- ```bash
183
- cmake -DCMAKE_BUILD_TYPE=Release -DSTRINGZILLA_BUILD_BENCHMARK=1 -DSTRINGZILLA_BUILD_SHARED=1 \
184
- -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_C_COMPILER=gcc-12 \
185
- -B build_release/gcc && cmake --build build_release/gcc --config Release
186
- cmake -DCMAKE_BUILD_TYPE=Release -DSTRINGZILLA_BUILD_BENCHMARK=1 -DSTRINGZILLA_BUILD_SHARED=1 \
187
- -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_C_COMPILER=clang-14 \
188
- -B build_release/clang && cmake --build build_release/clang --config Release
189
- ```
190
-
191
- ### Profiling
192
-
193
- To simplify tracing and profiling, build with symbols using the `RelWithDebInfo` configuration.
194
- Here is an example for profiling one target - `stringzilla_bench_token`.
195
-
196
- ```bash
197
- cmake -DSTRINGZILLA_BUILD_BENCHMARK=1 \
198
- -DSTRINGZILLA_BUILD_TEST=1 \
199
- -DSTRINGZILLA_BUILD_SHARED=1 \
200
- -DCMAKE_BUILD_TYPE=RelWithDebInfo \
201
- -B build_profile
202
- cmake --build ./build_profile --config Release --target stringzilla_bench_token
203
-
204
- # Check that the debugging symbols are there with your favorite tool
205
- readelf --sections ./build_profile/stringzilla_bench_token | grep debug
206
- objdump -h ./build_profile/stringzilla_bench_token | grep debug
207
-
208
- # Profile
209
- sudo perf record -g ./build_profile/stringzilla_bench_token ./leipzig1M.txt
210
- sudo perf report
211
- ```
212
-
213
- ### Testing in Docker
214
-
215
- It might be a good idea to check the compatibility against the most popular Linux distributions.
216
- Docker is the goto-choice for that.
217
-
218
- #### Alpine
219
-
220
- Alpine is one of the most popular Linux distributions for containers, due to it's size.
221
- The base image is only ~3 MB, and it's based on musl libc, which is different from glibc.
222
-
223
- ```bash
224
- sudo docker run -it --rm -v "$(pwd)":/workspace/StringZilla alpine:latest /bin/ash
225
- cd /workspace/StringZilla
226
- apk add --update make cmake g++ gcc
227
- cmake -DSTRINGZILLA_BUILD_TEST=1 -B build_debug
228
- cmake --build ./build_debug --config Debug
229
- ./build_debug/stringzilla_test_cpp20
230
- ```
231
-
232
- #### Intel Clear Linux
233
-
234
- Clear Linux is a distribution optimized for Intel hardware, and is known for its performance.
235
- It has rolling releases, and is based on glibc.
236
- It might be a good choice for compiling with Intel oneAPI compilers.
237
-
238
- ```bash
239
- sudo docker run -it --rm -v "$(pwd)":/workspace/StringZilla clearlinux:latest /bin/bash
240
- cd /workspace/StringZilla
241
- swupd update
242
- swupd bundle-add c-basic dev-utils
243
- cmake -DSTRINGZILLA_BUILD_TEST=1 -B build_debug
244
- cmake --build ./build_debug --config Debug
245
- ./build_debug/stringzilla_test_cpp20
246
- ```
247
-
248
- For benchmarks:
249
-
250
- ```bash
251
- cmake -DSTRINGZILLA_BUILD_TEST=1 -DSTRINGZILLA_BUILD_BENCHMARK=1 -B build_release
252
- cmake --build ./build_release --config Release
253
- ```
254
-
255
- #### Amazon Linux
256
-
257
- For CentOS-based __Amazon Linux 2023__:
258
-
259
- ```bash
260
- sudo docker run -it --rm -v "$(pwd)":/workspace/StringZilla amazonlinux:2023 bash
261
- cd /workspace/StringZilla
262
- yum install -y make cmake3 gcc g++
263
- cmake3 -DSTRINGZILLA_BUILD_TEST=1 -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DSTRINGZILLA_TARGET_ARCH="ivybridge" -B build_debug
264
- cmake3 --build ./build_debug --config Debug --target stringzilla_test_cpp11
265
- build_debug/stringzilla_test_cpp11
266
- ```
267
-
268
- The CentOS-based __Amazon Linux 2__ is still used in older AWS Lambda functions.
269
- Sadly, the newest GCC version it supports is 10, and it can't handle AVX-512 instructions.
270
-
271
- ```bash
272
- sudo docker run -it --rm -v "$(pwd)":/workspace/StringZilla amazonlinux:2 bash
273
- cd /workspace/StringZilla
274
- yum install -y make cmake3 gcc10 gcc10-c++
275
- cmake3 -DSTRINGZILLA_BUILD_TEST=1 -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DSTRINGZILLA_TARGET_ARCH="ivybridge" -B build_debug
276
- cmake3 --build ./build_debug --config Debug --target stringzilla_test_cpp11
277
- build_debug/stringzilla_test_cpp11
278
- ```
279
-
280
- > [!CAUTION]
281
- >
282
- > Even with GCC 10 the tests compilation will fail, as the STL implementation of the `insert` function doesn't conform to standard.
283
- > The `s.insert(s.begin() + 1, {'a', 'b', 'c'}) == (s.begin() + 1)` expression is illformed, as the `std::string::insert` return `void`.
284
-
285
- ---
286
-
287
- Don't forget to clean up Docker afterwards.
288
-
289
- ```bash
290
- docker system prune -a --volumes
291
- ```
292
-
293
- ## Contributing in Python
294
-
295
- Python bindings are implemented using pure CPython, so you wouldn't need to install SWIG, PyBind11, or any other third-party library.
296
-
297
- ```bash
298
- pip install -e . # To build locally from source
299
- ```
300
-
301
- ### Testing
302
-
303
- For testing we use PyTest, which may not be installed on your system.
304
-
305
- ```bash
306
- pip install pytest # To install PyTest
307
- pytest scripts/test.py -s -x # Runs tests printing logs and stops on the first failure
308
- ```
309
-
310
- On a related note, StringZilla for Python seems to cover more OS and hardware combinations, than NumPy.
311
- That's why NumPy isn't a required dependency.
312
- Still, many tests may use NumPy, so consider installing it on mainstream platforms.
313
-
314
- ```bash
315
- pip install numpy
316
- ```
317
-
318
- Before you ship, please make sure the `cibuilwheel` packaging works and tests pass on other platforms.
319
- Don't forget to use the right [CLI arguments][cibuildwheel-cli] to avoid overloading your Docker runtime.
320
-
321
- ```bash
322
- cibuildwheel
323
- cibuildwheel --platform linux # works on any OS and builds all Linux backends
324
- cibuildwheel --platform linux --archs x86_64 # 64-bit x86, the most common on desktop and servers
325
- cibuildwheel --platform linux --archs aarch64 # 64-bit Arm for mobile devices, Apple M-series, and AWS Graviton
326
- cibuildwheel --platform linux --archs i686 # 32-bit Linux
327
- cibuildwheel --platform linux --archs s390x # emulating big-endian IBM Z
328
- cibuildwheel --platform macos # works only on MacOS
329
- cibuildwheel --platform windows # works only on Windows
330
- ```
331
-
332
- You may need root previligies for multi-architecture builds:
333
-
334
- ```bash
335
- sudo $(which cibuildwheel) --platform linux
336
- ```
337
-
338
- On Windows and MacOS, to avoid frequent path resolution issues, you may want to use:
339
-
340
- ```bash
341
- python -m cibuildwheel --platform windows
342
- ```
343
-
344
- [cibuildwheel-cli]: https://cibuildwheel.readthedocs.io/en/stable/options/#command-line
345
-
346
- ### Benchmarking
347
-
348
- For high-performance low-latency benchmarking, stick to C/C++ native benchmarks, as the CPython is likely to cause bottlenecks.
349
- For benchmarking, the following scripts are provided.
350
-
351
- ```sh
352
- python scripts/bench_search.py --haystack_path "your file" --needle "your pattern" # real data
353
- python scripts/bench_search.py --haystack_pattern "abcd" --haystack_length 1e9 --needle "abce" # synthetic data
354
- python scripts/similarity_bench.py --text_path "your file" # edit ditance computations
355
- ```
356
-
357
- Alternatively, you can explore the Jupyter notebooks in `scripts/` directory.
358
-
359
- ## Contributing in JavaScript
360
-
361
- ```bash
362
- npm ci && npm test
363
- ```
364
-
365
- ## Contributing in Swift
366
-
367
- ```bash
368
- swift build && swift test
369
- ```
370
-
371
- Running Swift on Linux requires a couple of extra steps, as the Swift compiler is not available in the default repositories.
372
- Please get the most recent Swift tarball from the [official website](https://www.swift.org/install/).
373
- At the time of writing, for 64-bit Arm CPU running Ubuntu 22.04, the following commands would work:
374
-
375
- ```bash
376
- wget https://download.swift.org/swift-5.9.2-release/ubuntu2204-aarch64/swift-5.9.2-RELEASE/swift-5.9.2-RELEASE-ubuntu22.04-aarch64.tar.gz
377
- tar xzf swift-5.9.2-RELEASE-ubuntu22.04-aarch64.tar.gz
378
- sudo mv swift-5.9.2-RELEASE-ubuntu22.04-aarch64 /usr/share/swift
379
- echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc
380
- source ~/.bashrc
381
- ```
382
-
383
- You can check the available images on [`swift.org/download` page](https://www.swift.org/download/#releases).
384
- For x86 CPUs, the following commands would work:
385
-
386
- ```bash
387
- wget https://download.swift.org/swift-5.9.2-release/ubuntu2204/swift-5.9.2-RELEASE/swift-5.9.2-RELEASE-ubuntu22.04.tar.gz
388
- tar xzf swift-5.9.2-RELEASE-ubuntu22.04.tar.gz
389
- sudo mv swift-5.9.2-RELEASE-ubuntu22.04 /usr/share/swift
390
- echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc
391
- source ~/.bashrc
392
- ```
393
-
394
- Alternatively, on Linux, the official Swift Docker image can be used for builds and tests:
395
-
396
- ```bash
397
- sudo docker run --rm -v "$PWD:/workspace" -w /workspace swift:5.9 /bin/bash -cl "swift build -c release --static-swift-stdlib && swift test -c release --enable-test-discovery"
398
- ```
399
-
400
- ## Contributing in Rust
401
-
402
- ```bash
403
- cargo test
404
- ```
405
-
406
- ## General Performance Observations
407
-
408
- ### Unaligned Loads
409
-
410
- One common surface of attack for performance optimizations is minimizing unaligned loads.
411
- Such solutions are beautiful from the algorithmic perspective, but often lead to worse performance.
412
- It's often cheaper to issue two interleaving wide-register loads, than try minimizing those loads at the cost of juggling registers.
413
-
414
- ### Register Pressure
415
-
416
- Byte-level comparisons are simpler and often faster, than n-gram comparisons with subsequent interleaving.
417
- In the following example we search for 4-byte needles in a haystack, loading at different offsets, and comparing then as arrays of 32-bit integers.
418
-
419
- ```c
420
- h0_vec.zmm = _mm512_loadu_epi8(h);
421
- h1_vec.zmm = _mm512_loadu_epi8(h + 1);
422
- h2_vec.zmm = _mm512_loadu_epi8(h + 2);
423
- h3_vec.zmm = _mm512_loadu_epi8(h + 3);
424
- matches0 = _mm512_cmpeq_epi32_mask(h0_vec.zmm, n_vec.zmm);
425
- matches1 = _mm512_cmpeq_epi32_mask(h1_vec.zmm, n_vec.zmm);
426
- matches2 = _mm512_cmpeq_epi32_mask(h2_vec.zmm, n_vec.zmm);
427
- matches3 = _mm512_cmpeq_epi32_mask(h3_vec.zmm, n_vec.zmm);
428
- if (matches0 | matches1 | matches2 | matches3)
429
- return h + sz_u64_ctz(_pdep_u64(matches0, 0x1111111111111111) | //
430
- _pdep_u64(matches1, 0x2222222222222222) | //
431
- _pdep_u64(matches2, 0x4444444444444444) | //
432
- _pdep_u64(matches3, 0x8888888888888888));
433
- ```
434
-
435
- A simpler solution would be to compare byte-by-byte, but in that case we would need to populate multiple registers, broadcasting different letters of the needle into them.
436
- That may not be noticeable on a micro-benchmark, but it would be noticeable on real-world workloads, where the CPU will speculatively interleave those search operations with something else happening in that context.
437
-
438
- ## Working on Alternative Hardware Backends
439
-
440
- ## Working on Faster Edit Distances
441
-
442
- ## Working on Random String Generators
443
-
444
- ## Working on Sequence Processing and Sorting
445
-
446
-
@@ -1,25 +0,0 @@
1
- # This file is automatically @generated by Cargo.
2
- # It is not intended for manual editing.
3
- version = 3
4
-
5
- [[package]]
6
- name = "cc"
7
- version = "1.0.83"
8
- source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
10
- dependencies = [
11
- "libc",
12
- ]
13
-
14
- [[package]]
15
- name = "libc"
16
- version = "0.2.152"
17
- source = "registry+https://github.com/rust-lang/crates.io-index"
18
- checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
19
-
20
- [[package]]
21
- name = "stringzilla"
22
- version = "3.3.1"
23
- dependencies = [
24
- "cc",
25
- ]
@@ -1,26 +0,0 @@
1
- [package]
2
- name = "stringzilla"
3
- version = "3.5.0"
4
- authors = ["Ash Vardanian <1983160+ashvardanian@users.noreply.github.com>"]
5
- description = "Faster SIMD-accelerated string search, sorting, fingerprints, and edit distances"
6
- edition = "2021"
7
- license = "Apache-2.0"
8
- publish = true
9
- repository = "https://github.com/ashvardanian/stringzilla"
10
- documentation = "https://docs.rs/stringzilla"
11
- homepage = "https://ashvardanian.com/posts/stringzilla/"
12
- keywords = ["simd", "search", "retrieval", "hash", "sort"]
13
- categories = [
14
- "text-processing",
15
- "hardware-support",
16
- "no-std",
17
- "wasm",
18
- "external-ffi-bindings",
19
- ]
20
-
21
- [lib]
22
- name = "stringzilla"
23
- path = "rust/lib.rs"
24
-
25
- [build-dependencies]
26
- cc = "1.0"