23 Commits

Author SHA1 Message Date
xzfc
39547e3a67 chore: bench_cache (#10028) 2026-07-30 11:58:06 +00:00
Arnaud Gourlay
c196d2eb1a Benches: use SmallRng instead of ChaCha12-based generators (#9887)
* Benches: use SmallRng instead of ChaCha12-based generators

All benchmarks used StdRng or rand::rng() (ThreadRng), both backed by the
ChaCha12 block cipher in rand 0.10. Benchmarks do not need crypto-strength
randomness, and several draw random values inside the timed closure, so
cipher work was included in the measurement itself.

Switch every bench target to SmallRng (Xoshiro256++), and key the HNSW
graph cache and sparse index cache by RNG algorithm so stale caches built
from the old generator are not reused against newly generated vectors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Benches: replace free-function rand::random with local SmallRng

Addresses review: rand::random draws from the thread RNG (ChaCha12),
including inside the timed loop of the pq score benchmark.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 17:22:27 +02:00
xzfc
bf1aa818c6 Sparse InvertedIndex: bring back generic methods (#9485)
* sparse InvertedIndex: bring back generics

* nits

---------

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
2026-06-16 19:34:42 +00:00
Daniel Boros
4d6fb4e0ab feat: add open for read-only sparse vector index (#9435)
* feat: add open for read-only sparse vector index + enum sparse dispatcher

* fix: universal-IO loads for read-only sparse index open

* refactor: rename load_via/open_via to load_universal/open_universal

* refactor: drop StorageVersion::load in favor of load_universal

The regular-IO `load` duplicated `load_universal` over plain `File` IO.
Remove it and route all callers through `load_universal(&MmapFs, ..)`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(sparse): decouple inverted index from concrete storage; split segment_constructor_base (#9461)

Make the read-only index enum generic over storage `S` (no concrete MmapFile),
and remove construction callbacks from the sparse index open paths.

- InvertedIndex is now a pure read/search trait: `open`/`from_ram_index`/
  `type Fs` moved off the trait to inherent methods on each concrete index
  type, so construction no longer requires `S::Fs: Default`.
- SparseVectorIndex open split into a generic `plan` (load-vs-build decision +
  RAM-index build) and generic `finish` (assembly); callers do the concrete
  per-type construction, so no construction callbacks are needed.
- ReadOnlySparseVectorIndex::open takes the already-constructed inverted index
  and caller-loaded config instead of a `load_inverted_index` callback.
- VectorIndexReadEnum is generic over `S: UniversalRead`; sparse mmap variants
  hold `InvertedIndexCompressedMmap<_, S>` rather than a concrete `MmapFile`.
- Split the 1182-line segment_constructor_base.rs into a module (paths,
  vector_storage, payload_storage, id_tracker, vector_index,
  sparse_vector_index, create_segment, segment, legacy_state); the sparse
  dispatcher's match arms collapse into three per-family helpers.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>

* feat: LiveReload (no-op) dispatch for read-only vector index enum (#9436)

---------

Co-authored-by: generall <andrey@vasnetsov.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 22:31:03 +02:00
xzfc
fff9c1f1c7 Migrate InvertedIndexCompressedMmap to UIO (#9144)
* Migrate InvertedIndexCompressedMmap to UniversalRead

* Rehaul search_scratch.rs (was scores_memory_pool.rs)

- Use `typed_arena::Arena` instead of `bumpalo::Bump`.
  Reason: bump don't drop.
  Drawback: `Arena::new()` is not free, and `Arena::clear()` doesn't
  exist; but this commit has workarounds.
- Use names that make more sense.

* Misc fixes

* InvertedIndexCompressedMmap: explicit S type parameter
2026-05-29 17:49:49 +00:00
xzfc
34f2c82901 Cache sparse benchmark setup (#9141)
* dataset: add features to fs-err

Reason: fix `cargo check --all-targets -p dataset`. Feature unification
pulls `fs-err/debug` + `fs-err/tokio` without `fs-err/debug_tokio`.

* dataset: run `cargo metadata` to get target dir

Reason: avoid re-downloading in separate worktrees. The old
`cargo locate-project` ignores custom target dirs.

* sparse/benches/search: cache vectors/indices
2026-05-23 16:45:42 +00:00
xzfc
905f3250b7 sparse: use zerocopy (#9140)
* sparse: use zerocopy for mmap reads

* loaders::Csr: use zerocopy
2026-05-22 18:43:51 +00:00
xzfc
a5e1cedf68 Error propagation for sparse InvertedIndex (#9076)
* Remove unused InvertedIndexMmap / InvertedIndexImmutableRam

* Error propagation for InvertedIndex trait
2026-05-18 20:40:34 +00:00
xzfc
bb8cdf6e5e Remove unused InvertedIndexMmap / InvertedIndexImmutableRam (#9074) 2026-05-18 19:35:44 +00:00
Jojii
6fc6bcc5b3 Don't insert deferred points into sparse index (#8435)
* Don't insert deferred points into sparse index

# Conflicts:
#	lib/segment/src/segment/tests.rs
#	lib/segment/src/segment_constructor/segment_constructor_base.rs

# Conflicts:
#	lib/segment/src/segment_constructor/segment_constructor_base.rs

* Clippy

* Assert consistency of deferred_internal_id var

* Return before SparseVector conversion in case of deferred point

* Use debug_assert instead
2026-03-25 15:37:32 +01:00
Jojii
e38d3d6662 Filter deferred points sparse search (#8299)
* Implement filtering deferred: Sparse search

* Add tests for deferred sparse vectors

* Clippy

* Review remark
2026-03-11 10:09:13 +01:00
xzfc
a0d62330c7 Use fs-err (#7319) 2025-09-29 12:47:10 +00:00
Andrey Vasnetsov
82af7aa481 vector-io-read measurement on query (#6197)
* remove mut getters from HardwareCounterCell, as mutability is not useful

* introduce vector-io multiplier

* remove RealCpuMeasurement structure

* set vector-io reads multipliers

* account vector reads in dense scorers

* fmt

* fix tests

* propagate hw_counter into posting list iterator

* fmt

* fix test

* wip: measure of sparse iterator

* fmt

* optimize skip_to

* minor refactoring

* keep current PointOffset in iterator to prevent unnecessary reads from memory

* adjust sparse search cpu cost - account for datatype

* fix test

* refactor search_context tests

* move tests into a module

* introduce more tests

* grammar

* review fixes

* fix clippy

* fix clippy again

* change disposable -> new
2025-03-24 13:15:04 +01:00
Tim Visée
3e536347e1 Bump Rust edition to 2024 (#6042)
* Bump Rust edition to 2024

* gen is a reserved keyword now

* Remove ref mut on references

* Mark extern C as unsafe

* Wrap unsafe function bodies in unsafe block

* Geo hash implements Copy, don't reference but pass by value instead

* Replace secluded self import with parent

* Update execute_cluster_read_operation with new match semantics

* Fix lifetime issue

* Replace map_or with is_none_or

* set_var is unsafe now

* Reformat
2025-02-25 11:21:25 +01:00
Roman Titov
6260eb7d74 Cleanup #[allow(dead_code)] annotations (#5818) 2025-01-17 15:37:13 +01:00
Jojii
e0d0e233d8 Timeout aware hardware counter (#5555)
* Make hardware counting timeout aware

* improve test

* rebuild everything

* fmt

* post-rebase fixes

* upd tests

* fix tests

---------

Co-authored-by: generall <andrey@vasnetsov.com>
2024-12-10 12:12:36 +01:00
Arnaud Gourlay
b6caf4e55b Clippy 1.83 (#5513)
* Clippy 1.83

* there is more
2024-11-27 11:24:58 +01:00
xzfc
dd3102baeb U8 quantization for sparse vector index (#4514)
* U8 quantization for sparse index

* Spelling
2024-06-24 14:12:29 +00:00
xzfc
05ff867ff3 Integrate compressed posting list (attempt 2) (#4453)
* Rename InvertedIndex* -> InvertedIndexCompressed*

* Extract method VectorIndexEnum::fill_idf_statistics

* Extend VectorIndexEnum with new variants

* Introduce sparse::InvertedIndex::Version

* Replace SparseVectorIndexVersion -> InvertedIndex::Version

* Introduce sparse_vector_index::OpenArgs

* SparseVectorIndex::open: do not build index if directory is empty

Otherwise it would build the index twice since `SegmentBuilder::build()`
calls `::open()`, then `::build_index()`. This restores the old (<=v1.9)
behavior.

* Renames
2024-06-17 14:41:38 +02:00
xzfc
d2ef556237 Make sparse vectors generic (#4364)
* Make sparse vector generic

* Generic search_context tests
2024-06-10 15:04:32 +00:00
xzfc
f4c7ba15af Sparse: misc fixes (#4361)
* Borrow cows
* Hide sparse_vector_fixture under feature="testing"
2024-05-30 20:58:00 +00:00
xzfc
93a42b4e2d Compressed posting lists (#4253) 2024-05-22 18:18:20 +00:00
xzfc
6f738ca95f Update sparse vector benchmarks (#4163) 2024-05-07 20:34:37 +00:00