[!INFO] This is a fork of helix-editor/nucleo designed to implement some minor API changes, bug fixes, and many performance improvements.
This is a fork of nucleo with minor API changes, bug fixes, scoring improvements, and many performance improvements.
This crate is primarily used to better support the requirements in nucleo-picker but other crates which depend on nucleo may find this useful as well.
This fork branched at commit hash 5b74652e482f7c07d827f18c6d21e7540c242c69.
The current differences are:
- Updated dependencies and migrated to 2024 edition
- Reverted commit
61f2a4e48270174dd3789485b2991fbc0a32fbc8, so we do not sort results on the empty pattern Injector::extendnow accepts any iterator. The new implementation usessize_hintinternally.Injector::getandInjector::get_uncheckedwere renamed toInjector::get_itemandInjector::get_item_unchecked.ncp_matcher::chars::normalizewas renamed tonormalize_latin.- Added
DetachedItem, an owned, cheaply cloneable item handle. - Added conversion from
Utf32StrtoUtf32String. - Removed the
Send + Sync + 'staticbounds from theNucleoandSnapshottype declarations. (Unsurprisingly, the bounds are still required to actually callNucleoandSnapshotmethods.) - Added support for targets with 32-bit atomics but no 64-bit atomics.
- Use Rayon
reduefor worker matching instead of a shared atomic rejection counter to reduce contention between threads. - Unified
prefer_prefixscoring across matching paths using a bounded bonus based on the first selected index.
Benchmarks
Comparison with Nucleo.
Bencharks run on Apple M4 Pro, macOS 15.7.7 (arm64); rustc 1.99.0 using Criterion (20 samples, 0.5s warm-up and 2s measurement target per case).
Benchmarks are run against data loaded by the script benches/prepare_data.py.
| Workload | Workers | Nucleo | ncp-engine | Speedup |
|---|---|---|---|---|
Score Chromium paths: linux |
1 | 8.329 ms | 8.300 ms | 1.00× |
Search Chromium paths: src |
1 | 30.895 ms | 29.786 ms | 1.04× |
Search Chromium paths: src |
8 | 5.491 ms | 4.757 ms | 1.15× |
| Search Chromium paths: no match | 8 | 6.455 ms | 0.699 ms | 9.24× |
Append to Chromium query: li → linux |
8 | 4.740 ms | 1.729 ms | 2.74× |
Search German titles: munchen |
8 | 6.556 ms | 0.778 ms | 8.43× |
Search Japanese titles: 東京 |
8 | 6.615 ms | 0.871 ms | 7.60× |
To reproduce the above comparison table on your own device, run
benches/compare.py accepts a few options:
--current <revision>to select another commit--size 10000for a smaller corpus--threads 4to set the parallel worker count (default: up to 8).
Full benchmark suite
To run benchmarks, run:
Matching benchmarks cover corpus scoring, complete engine searches, append/backspace edits, and newly injected items.
By default, benchmarks run with 100,000 items and worker counts of 1 and up to 8.
This can be overridden with NCP_BENCH_SIZE=10000|100000|full and NCP_BENCH_THREADS=1,4.