Skip to content

Commit d92b549

Browse files
authored
Merge: Node Lookups, Stats, & CI Upgrades
Several older failure modes have been validated to be stable now. Closes #355, #454, #494, #514, #562, #700, #702, #767, #770
2 parents 9fd6b01 + 017fad3 commit d92b549

18 files changed

Lines changed: 424 additions & 147 deletions

File tree

.github/workflows/prerelease.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ env:
1111
PYTHONUTF8: 1
1212
PYTHONFAULTHANDLER: 1
1313
PYTHON_VERSION: 3.11
14-
DOTNET_VERSION: 8.0.x
15-
NODE_VERSION: 20
14+
DOTNET_VERSION: 10.0.x
15+
NODE_VERSION: 24
1616
JAVA_VERSION: 21
17-
GO_VERSION: "^1.22.0"
18-
ANDROID_NDK_VERSION: 26.3.11579264
17+
GO_VERSION: "^1.25.0"
18+
ANDROID_NDK_VERSION: 27.2.12479018
1919
ANDROID_SDK_VERSION: 21
2020

2121
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
@@ -137,6 +137,7 @@ jobs:
137137
run: |
138138
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
139139
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
140+
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
140141
dotnet test -c Debug --logger "console;verbosity=detailed"
141142
shell: bash
142143
working-directory: ${{ github.workspace }}/csharp
@@ -218,6 +219,7 @@ jobs:
218219
run: |
219220
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
220221
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
222+
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
221223
dotnet test -c Debug --logger "console;verbosity=detailed"
222224
shell: bash
223225
working-directory: ${{ github.workspace }}/csharp
@@ -307,8 +309,8 @@ jobs:
307309
# C/C++
308310
- name: Build C/C++
309311
run: |
310-
choco install cmake
311-
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=0
312+
choco install cmake -y
313+
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=0 -D USEARCH_USE_NUMKONG=1
312314
cmake --build build_artifacts --config RelWithDebInfo
313315
- name: Test C++
314316
run: .\build_artifacts\test_cpp.exe
@@ -353,11 +355,13 @@ jobs:
353355
with:
354356
dotnet-version: ${{ env.DOTNET_VERSION }}
355357
- name: Test .NET
358+
shell: pwsh
356359
run: |
357-
mkdir -p "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
358-
cp "${{ github.workspace }}\build_artifacts\libusearch_c.dll" "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
360+
$nativeDir = "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
361+
New-Item -ItemType Directory -Force -Path $nativeDir | Out-Null
362+
Copy-Item "${{ github.workspace }}\build_artifacts\libusearch_c.dll" -Destination $nativeDir
363+
Copy-Item "${{ github.workspace }}\build_artifacts\numkong.dll" -Destination $nativeDir
359364
dotnet test -c Debug --logger "console;verbosity=detailed"
360-
shell: bash
361365
working-directory: ${{ github.workspace }}/csharp
362366

363367
test_windows_arm:
@@ -404,7 +408,7 @@ jobs:
404408
needs: [test_ubuntu_gcc, test_ubuntu_clang]
405409
strategy:
406410
matrix:
407-
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
411+
python-version: ["310", "311", "312", "313", "314", "314t"]
408412
steps:
409413
- name: Checkout
410414
uses: actions/checkout@v6
@@ -420,7 +424,7 @@ jobs:
420424
max_attempts: 3
421425
retry_wait_seconds: 10
422426
timeout_minutes: 180
423-
command: python -m pip install cibuildwheel
427+
command: python -m pip install "cibuildwheel~=4.1"
424428
- name: Build wheels
425429
uses: nick-fields/retry@v4
426430
with:
@@ -430,7 +434,6 @@ jobs:
430434
command: cibuildwheel --output-dir wheelhouse
431435
env:
432436
CIBW_BUILD: cp${{ matrix.python-version }}-*
433-
CIBW_ENABLE: cpython-freethreading
434437
CIBW_PLATFORM: linux
435438

436439
build_wheels_macos:
@@ -439,7 +442,7 @@ jobs:
439442
needs: [test_macos]
440443
strategy:
441444
matrix:
442-
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
445+
python-version: ["310", "311", "312", "313", "314", "314t"]
443446
steps:
444447
- name: Checkout
445448
uses: actions/checkout@v6
@@ -453,7 +456,7 @@ jobs:
453456
max_attempts: 3
454457
retry_wait_seconds: 10
455458
timeout_minutes: 180
456-
command: python -m pip install cibuildwheel
459+
command: python -m pip install "cibuildwheel~=4.1"
457460
- name: Build wheels
458461
uses: nick-fields/retry@v4
459462
with:
@@ -463,7 +466,6 @@ jobs:
463466
command: cibuildwheel --output-dir wheelhouse
464467
env:
465468
CIBW_BUILD: cp${{ matrix.python-version }}-*
466-
CIBW_ENABLE: cpython-freethreading
467469
CIBW_PLATFORM: macos
468470

469471
build_wheels_windows:
@@ -472,7 +474,7 @@ jobs:
472474
needs: [test_windows_x86]
473475
strategy:
474476
matrix:
475-
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
477+
python-version: ["310", "311", "312", "313", "314", "314t"]
476478
steps:
477479
- name: Checkout
478480
uses: actions/checkout@v6
@@ -486,7 +488,7 @@ jobs:
486488
max_attempts: 3
487489
retry_wait_seconds: 10
488490
timeout_minutes: 180
489-
command: python -m pip install cibuildwheel
491+
command: python -m pip install "cibuildwheel~=4.1"
490492
- name: Build wheels
491493
uses: nick-fields/retry@v4
492494
with:
@@ -496,7 +498,6 @@ jobs:
496498
command: cibuildwheel --output-dir wheelhouse
497499
env:
498500
CIBW_BUILD: cp${{ matrix.python-version }}-*
499-
CIBW_ENABLE: cpython-freethreading
500501
CIBW_PLATFORM: windows
501502

502503
test_ubuntu_cross_compilation:

.github/workflows/release.yml

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ env:
88
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
99
PYTHONUTF8: 1
1010
PYTHON_VERSION: 3.11
11-
DOTNET_VERSION: 8.0.x
12-
NODE_VERSION: 20
11+
DOTNET_VERSION: 10.0.x
12+
NODE_VERSION: 24
1313
JAVA_VERSION: 21
14-
GO_VERSION: "^1.22.0"
15-
ANDROID_NDK_VERSION: 26.3.11579264
14+
GO_VERSION: "^1.25.0"
15+
ANDROID_NDK_VERSION: 27.2.12479018
1616
ANDROID_SDK_VERSION: 21
17-
EMSCRIPTEN_VERSION: 3.1.47
18-
MINGW_VERSION: 12.2.0
17+
EMSCRIPTEN_VERSION: 6.0.2
1918

2019
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
2120
permissions:
@@ -195,10 +194,9 @@ jobs:
195194

196195
- name: Setup MinGW
197196
if: matrix.arch != 'arm64'
198-
uses: egor-tensin/setup-mingw@v2
197+
uses: egor-tensin/setup-mingw@v3
199198
with:
200199
platform: ${{ matrix.arch }}
201-
version: ${{ env.MINGW_VERSION }}
202200

203201
- name: Setup MSVC for ARM64
204202
if: matrix.arch == 'arm64'
@@ -750,7 +748,7 @@ jobs:
750748
strategy:
751749
matrix:
752750
os: [ubuntu-24.04, macos-14, windows-2022]
753-
python-version: ["310", "311", "312", "313", "313t", "314", "314t"]
751+
python-version: ["310", "311", "312", "313", "314", "314t"]
754752
steps:
755753
- name: Check out refreshed version
756754
uses: actions/checkout@v6
@@ -767,12 +765,11 @@ jobs:
767765
if: matrix.os == 'ubuntu-24.04' # We only need QEMU for Linux builds
768766
uses: docker/setup-qemu-action@v3
769767
- name: Install cibuildwheel
770-
run: python -m pip install cibuildwheel
768+
run: python -m pip install "cibuildwheel~=4.1"
771769
- name: Build wheels
772770
run: cibuildwheel --output-dir wheelhouse
773771
env:
774772
CIBW_BUILD: cp${{ matrix.python-version }}-*
775-
CIBW_ENABLE: cpython-freethreading # No-GIL 3.13t builds
776773
CIBW_TEST_SKIP: "*-win_arm64" # Too complex to emulate Windows ARM
777774
- name: Upload wheels
778775
uses: actions/upload-artifact@v5
@@ -813,19 +810,9 @@ jobs:
813810
strategy:
814811
fail-fast: false
815812
matrix:
816-
arch: [x64, x86]
817-
# Windows pre-build is not working
818-
# - windows-latest
819-
os: [macos-14, ubuntu-24.04]
820-
exclude:
821-
- arch: x86
822-
os: macos-14
823-
- arch: x86
824-
os: ubuntu-24.04
813+
arch: [x64]
814+
os: [macos-14, ubuntu-24.04, windows-2022]
825815
runs-on: ${{ matrix.os }}
826-
env:
827-
CC: gcc
828-
CXX: g++
829816

830817
steps:
831818
- name: Checkout the latest code
@@ -852,7 +839,16 @@ jobs:
852839
run: |
853840
npm install --ignore-scripts
854841
- run: npm run prebuild-single
855-
if: matrix.os != 'macos-14'
842+
env:
843+
CC: gcc
844+
CXX: g++
845+
if: matrix.os == 'ubuntu-24.04'
846+
# Leave CC/CXX unset on Windows. node-gyp builds with MSVC regardless,
847+
# but NumKong's ISA probe takes the compiler from $CC while still
848+
# passing MSVC flag syntax, so a `gcc` here fails every probe and
849+
# silently yields a scalar-only binary with no SIMD kernels.
850+
- run: npm run prebuild-single
851+
if: matrix.os == 'windows-2022'
856852
- run: npm run prebuild-darwin-x64+arm64
857853
env:
858854
CC: clang
@@ -1136,6 +1132,7 @@ jobs:
11361132
cmake --build build_artifacts --config Release
11371133
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
11381134
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
1135+
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
11391136
11401137
- name: Build C library for MacOS
11411138
if: matrix.os == 'macos-15'
@@ -1146,15 +1143,19 @@ jobs:
11461143
cmake --build build_artifacts --config Release
11471144
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
11481145
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
1146+
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
11491147
11501148
- name: Build C library for Windows
11511149
if: matrix.os == 'windows-2022'
1150+
shell: pwsh
11521151
run: |
1153-
choco install cmake
1154-
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_TEST_C=0 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_NUMKONG=0 -DUSEARCH_USE_JEMALLOC=0
1152+
choco install cmake -y
1153+
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_TEST_C=0 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_NUMKONG=1 -DUSEARCH_USE_JEMALLOC=0
11551154
cmake --build build_artifacts --config Release
1156-
mkdir -p "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
1157-
cp "${{ github.workspace }}\build_artifacts\libusearch_c.dll" "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
1155+
$nativeDir = "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
1156+
New-Item -ItemType Directory -Force -Path $nativeDir | Out-Null
1157+
Copy-Item "${{ github.workspace }}\build_artifacts\libusearch_c.dll" -Destination $nativeDir
1158+
Copy-Item "${{ github.workspace }}\build_artifacts\numkong.dll" -Destination $nativeDir
11581159
11591160
- name: Upload Artifacts
11601161
uses: actions/upload-artifact@v5
@@ -1188,6 +1189,15 @@ jobs:
11881189
merge-multiple: true
11891190
path: ${{ env.USEARCH_LIBS }}
11901191

1192+
- name: Verify native package inputs
1193+
run: |
1194+
test -f "${{ env.USEARCH_LIBS }}/runtimes/linux-x64/native/libusearch_c.so"
1195+
test -f "${{ env.USEARCH_LIBS }}/runtimes/linux-x64/native/libnumkong.so"
1196+
test -f "${{ env.USEARCH_LIBS }}/runtimes/osx-arm64/native/libusearch_c.dylib"
1197+
test -f "${{ env.USEARCH_LIBS }}/runtimes/osx-arm64/native/libnumkong.dylib"
1198+
test -f "${{ env.USEARCH_LIBS }}/runtimes/win-x64/native/libusearch_c.dll"
1199+
test -f "${{ env.USEARCH_LIBS }}/runtimes/win-x64/native/numkong.dll"
1200+
11911201
- name: Setup .NET
11921202
uses: actions/setup-dotnet@v5
11931203
with:

CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,21 @@ function (setup_target TARGET_NAME)
379379
if (USEARCH_USE_NUMKONG AND TARGET nk_shared)
380380
target_compile_definitions(${TARGET_NAME} PRIVATE "NK_DYNAMIC_DISPATCH=1")
381381
target_link_libraries(${TARGET_NAME} PRIVATE nk_shared)
382+
383+
# Keep NumKong discoverable both in the build tree (`build/numkong`) and
384+
# after packaging it next to `libusearch_c` in language bindings.
385+
if (APPLE)
386+
set(_USEARCH_NUMKONG_RPATH "@loader_path;@loader_path/numkong")
387+
elseif (UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
388+
set(_USEARCH_NUMKONG_RPATH "$ORIGIN;$ORIGIN/numkong")
389+
endif ()
390+
391+
if (DEFINED _USEARCH_NUMKONG_RPATH)
392+
set_target_properties(
393+
${TARGET_NAME} PROPERTIES BUILD_RPATH "${_USEARCH_NUMKONG_RPATH}"
394+
INSTALL_RPATH "${_USEARCH_NUMKONG_RPATH}"
395+
)
396+
endif ()
382397
endif ()
383398

384399
endfunction ()
@@ -394,6 +409,19 @@ if (USEARCH_USE_NUMKONG)
394409

395410
if (TARGET nk_shared)
396411
set_target_properties(nk_shared PROPERTIES ENABLE_EXPORTS ON)
412+
413+
# Windows has no RPATH equivalent, so the dynamic loader only finds
414+
# NumKong reliably when it sits next to the binaries that link it.
415+
if (WIN32)
416+
set_target_properties(
417+
nk_shared
418+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
419+
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}"
420+
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}"
421+
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}"
422+
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}"
423+
)
424+
endif ()
397425
endif ()
398426
endif ()
399427

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ Then, on Windows, copy the library to the CSharp project and run the tests:
484484
```sh
485485
mkdir -p ".\csharp\lib\runtimes\win-x64\native"
486486
cp ".\build_artifacts\libusearch_c.dll" ".\csharp\lib\runtimes\win-x64\native"
487+
cp ".\build_artifacts\numkong.dll" ".\csharp\lib\runtimes\win-x64\native"
487488
cd csharp
488489
dotnet test -c Debug --logger "console;verbosity=detailed"
489490
dotnet test -c Release
@@ -494,8 +495,10 @@ On Linux, the process is similar:
494495
```sh
495496
mkdir -p "csharp/lib/runtimes/linux-x64/native" # for x86
496497
cp "build_artifacts/libusearch_c.so" "csharp/lib/runtimes/linux-x64/native" # for x86
498+
cp "build_artifacts/numkong/libnumkong.so" "csharp/lib/runtimes/linux-x64/native" # for x86
497499
mkdir -p "csharp/lib/runtimes/linux-arm64/native" # for ARM
498500
cp "build_artifacts/libusearch_c.so" "csharp/lib/runtimes/linux-arm64/native" # for ARM
501+
cp "build_artifacts/numkong/libnumkong.so" "csharp/lib/runtimes/linux-arm64/native" # for ARM
499502
cd csharp
500503
dotnet test -c Debug --logger "console;verbosity=detailed"
501504
dotnet test -c Release

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = ["Ash Vardanian <1983160+ashvardanian@users.noreply.github.com>"]
33
description = "Smaller & Faster Single-File Vector Search Engine from Unum"
44
documentation = "https://unum-cloud.github.io/USearch"
5-
edition = "2021"
5+
edition = "2024"
66
include = [
77
"/rust/**",
88
"/include/**",

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
id 'cpp'
77
id 'maven-publish'
88
id 'signing'
9-
id 'com.diffplug.spotless' version '6.25.0'
9+
id 'com.diffplug.spotless' version '8.8.0'
1010
}
1111

1212
group = "cloud.unum"
@@ -57,14 +57,15 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
5757
}
5858

5959
dependencies {
60-
testImplementation('junit:junit:4.13.2')
60+
testImplementation('org.junit.jupiter:junit-jupiter:5.12.2')
61+
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
6162
}
6263

6364
spotless {
6465
format 'gradle', {
6566
target '*.gradle'
6667
trimTrailingWhitespace()
67-
indentWithSpaces(4)
68+
leadingTabsToSpaces(4)
6869
endWithNewline()
6970
}
7071

@@ -196,6 +197,7 @@ model {
196197
}
197198

198199
test {
200+
useJUnitPlatform()
199201
forkEvery = 1
200202

201203
dependsOn jar

0 commit comments

Comments
 (0)