Commit Graph
89 Commits
Author SHA1 Message Date
陈志谦 f24b7a5910 [AI] docs: update coverage instructions for the renamed coverage script (#10483)
tools/coverage.sh was split into tools/unit-test-coverage.sh and
tools/integration-test-coverage.sh in #6414, but DEVELOPMENT.md still
pointed at the old path and the new script's own usage header kept the
old name. Updated both to the unit-test script.
2026-09-10 11:48:27 +02:00
Tim Visée 52d8e39451 Remove RocksDB references (#10561)
* Remove RocksDB specifics from shell.nix

* Re-enable sparse benches, replace RocksDB structures

* Rewrite congruence test, in-memory ID tracker vs mutable ID tracker

* Remove RocksDB flag from test

* Remove RocksDB tool

* Remove RocksDB comments

* Bump OpenAPI spec
2026-09-09 17:40:46 +02:00
Andrey VasnetsovandClaude Fable 5.1 29e21bea96 callgraph: accept struct/trait/enum/type/const roots (#10543)
rust-analyzer's call hierarchy is function-only, so a type root is walked
via find-references instead: each mention is attributed to its enclosing
document symbol (function, type definition, or impl block's self type),
and a type's callees are its methods. Type nodes are square; new edge
kinds `ref` and `member` get their own labels and legend entries.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-08 20:52:56 +02:00
Andrey VasnetsovandClaude Fable 5 afa9ecec1f Add tools/callgraph: interactive call-graph reports via rust-analyzer (#10422)
* Add tools/callgraph: interactive call-graph reports via rust-analyzer

Generates a self-contained HTML report for one function: pan/zoom graphviz
graph of callers and callees, per-node docs and source snippets, exact call
sites with context, GitHub/editor links.

- rust-analyzer call hierarchy over LSP gives resolved (not textual) edges;
  trait declarations and impls are bridged via goto-declaration /
  goto-implementation so dispatch through a trait doesn't dead-end the walk
- test code excluded by running rust-analyzer with cfg(test) disabled, plus
  path filters for tests/, benches/, examples/ targets
- no dependencies beyond rust-analyzer and graphviz on PATH

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RgxVoa6hfvgB7r6FVbcGmg

* Add screenshot to tools/callgraph README

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RgxVoa6hfvgB7r6FVbcGmg

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-01 11:32:24 +02:00
Sebastiaan van Steenis ab6e40989e tests: ast-grep rule for requests without headers (#10224)
* tests: ast-grep rule for requests without headers

* review comments
2026-08-14 11:41:25 +02:00
Andrey VasnetsovandClaude Opus 5 aa6c5d8403 Global quota API (#10035)
* feat: global quota API

Memory and disk are node-wide resources, so configuring their thresholds
per collection through strict mode makes little sense. Move them behind a
single cluster-wide `QuotaManager`.

The quota config is seeded from `storage.quotas` in the settings (and so
from env vars), overridden by `quota.json` in the storage directory, and
updated cluster-wide through a new `SetQuotaConfig` consensus operation
which rewrites that file on every peer. Raft snapshots carry it too, so a
peer that joins by snapshot picks it up.

Quotas are enforced wherever the strict mode memory and disk checks used
to run, but no longer gated behind `strict_mode.enabled`: a value set in
an enabled strict mode config still wins per resource, the quota is the
default. Rejections name both the condition that tripped and the config
that governs it.

`GET /quotas` reports the config plus current utilization to global read
users; `PUT /quotas` replaces it for global manage users.

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

* fix: cover the quota endpoints in the API consistency checks

`test_all_rest_endpoints_are_covered` and the OpenAPI endpoint count both
break on any new REST endpoint. Add `GET`/`PUT /quotas` to `ACTION_ACCESS`
with their JWT access tests, and bump the expected API count. The quota
endpoints stay out of `REST_ENDPOINT_WHITELIST`: that list is for
data-plane endpoints reported per-endpoint in metrics.

Also add a Raft snapshot CBOR compatibility test — snapshots are exchanged
between peers of different versions during a rolling upgrade, so
`quota_config` must be absent-tolerant in both directions.

Review feedback: persist through `SaveOnDisk`, which already implements the
write-before-swap protocol this was doing by hand; validate the config at
both persistence boundaries, since a hand-edited quota file or a config
arriving through consensus does not pass the REST handler's validation, and
a `0%` limit would reject every update forever.

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

* test: assert seeding a quota from invalid settings persists nothing

Follow-up to review feedback claiming `SaveOnDisk::load_or_init` writes the
init value before it is validated. It does not — only `SaveOnDisk::new`
persists — but the property matters: were seeding to persist first, invalid
settings would leave a `quota.json` that fails validation on every
subsequent start, and the node could only be recovered by deleting it by
hand. Pin it down with a test.

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

* refactor: make QuotaManager the single reader of memory and disk

The quota checks measured memory and disk themselves, while the optimizer
and the WAL disk watcher each called `fs4::available_space` behind their
own ad-hoc caches. Fold all of it into QuotaManager: it owns the readings,
the freshness policy, and the limits they are compared against.

Moves the module to `lib/shard`, since the optimizer sits below `storage`
and has to reach it; `storage::quota` re-exports it, so consensus, the
`/quotas` API and StorageConfig are unchanged. The manager is installed as
a process singleton by TableOfContent, ahead of loading any collection.

- Callers hand in QuotaLimits overrides instead of a StrictModeConfig, and
  an override can now only tighten. A collection-level admin could raise
  `max_disk_usage_percent` past a cluster-wide limit that needed global
  manage rights to set; ties resolve to the quota so the rejection names
  the knob that actually has to change.
- Measurements are cached for 5s, but a reading at or above its limit is
  never reused: a rejected client retries, and freeing the resource has to
  take effect on the next request rather than a TTL later.
- `fits_on_disk` sizes an optimization against physical free space only,
  never the configured limits. Optimizations are what free a full disk, so
  the quota must not be what stops one.
- `percent_of` widens to u128 instead of saturating the multiply, which
  under-reported utilization (failing open) above ~184 PB.
- StorageConfig::quotas is optional; absent means no quota is enforced.

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

* feat: don't recover dead replicas onto a node at a resource limit

Recovering a dead replica pulls a whole copy of its shard onto this node.
If it is already at its memory or disk quota that transfer cannot finish,
and starting it only pushes the node further past the limit. Skip it and
reconsider on a later sync, once the resource frees up.

Adds QuotaManager::check_capacity for work that lands bytes here without
being an update. Unlike fits_on_disk the configured limits do apply:
taking on a replica is not what frees a full node, so there is no deadlock
to avoid by letting it through.

The check is hoisted out of the per-shard loop because a node over its
limit re-measures on every call, so checking per dead shard would cost a
statvfs each. It is free when no quota is configured.

Also trims the comments across the quota module, which had grown well past
what the code needs.

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

* test: drop trivial and duplicated quota tests

Six tests removed, ~140 lines, with no loss of coverage:

- a_rejection_names_the_knob_that_has_to_change asserted that a format!
  contains its own literals; the message is covered end-to-end by the
  override test and by test_global_quota.py.
- a_node_over_its_quota_has_no_capacity_to_take_on_a_replica was 30 lines
  for check_capacity, a one-line delegation to check_update the test above
  it already calls.
- a_rejecting_measurement_is_never_served_from_the_cache duplicated the
  meter test, which proves the same rule with an injected reader instead
  of inferring it from the real filesystem.
- free_space_is_reported_without_enforcing_anything covered a one-line
  accessor, and its point is what the fits_on_disk test is for.
- The two resolve tests and the three meter tests each collapse into one.

DiskFit::Unknown keeps its coverage as two lines inside the fits_on_disk
test rather than its own fixture. The snapshot compat pair becomes one
test: the second only asserted cluster_metadata.is_empty(), which says
nothing about quotas — the real check was the deserialize, now an expect
that states it.

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

* fix: re-measure free space as the disk fills, and drop a Windows-only assert

Two CI failures, both from this branch.

e2e test_low_disk: the DiskUsageWatcher I replaced escalated to checking
on every call once free space fell below 512 MB. Folding it into the quota
manager lost that — available_bytes passed no limit, so a reading was
reused for the full 5s however little space was left. On a disk filling as
fast as that test fills it, 5s blind is enough to actually run out and the
WAL write dies instead of returning "No space left on device".

available_bytes now takes a watch_below level and never reuses a reading
under it, which is what the old ladder was expressing. The watcher passes
max(min_free, 512 MB), so the escalation point is back; above it the 5s
cache still costs fewer syscalls than the old 128-call ladder. fits_on_disk
gets the same rule by passing required_bytes, so a merge that does not fit
re-checks rather than sitting on a stale sample.

Windows: fits_on_disk on a missing path was asserted to be Unknown, but
GetDiskFreeSpaceEx resolves up to the containing drive and succeeds — as
common::disk_usage's own test documents. Dropped; the branch is a two-line
else and is not portably reachable.

Also renames an_optimization_is_sized_against_the_disk_not_the_quota, which
needed explaining to be understood.

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

* feat: report the quota config in telemetry

Reads it from the quota manager rather than the settings, so it is the
config the node is actually enforcing: a peer that missed a consensus
update reports what it is applying, not what the cluster agreed on.

Gated on global access, the same access `GET /quotas` requires, and left
out of `PeerTelemetry` — a quota is per-node state, so each peer reports
its own.

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

* fix: regenerate OpenAPI, and cover the quota in the telemetry key sets

Two CI failures from the previous commit.

Referencing QuotaConfig from TelemetryData moves its definition earlier
in `components/schemas`, because TelemetryData is generated ahead of
QuotaStatus. Regenerated rather than hand-patched, so the schema is a
pure move.

test_telemetry_detail asserts the exact set of top-level telemetry keys.
The quota is reported at every level, including 0 — it is three scalars,
it is the default the endpoint serves, and it is what explains an update
being rejected — so both key sets gain it.

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

* feat: remove `max_disk_usage_percent` from strict mode

Disk is a node-wide resource, so a per-collection percentage of it never
meant anything a caller could act on: the limit describes how full the
*node* is, and which collection the write happens to target has nothing
to do with it. The global quota is where it belongs.

It shipped in 1.18.2 without documentation, so this drops it outright
rather than deprecating. Removal is soft in every direction: StrictModeConfig
has no `deny_unknown_fields`, so a client still sending it gets it ignored
rather than a 400, and the same struct deserializes the persisted collection
config, so collections created on 1.18.2+ keep loading. Proto field 22 is
reserved so the number is never reused.

The e2e test becomes a quota test — the fixture and the timing are the
interesting parts and they carry over unchanged; only how the threshold is
configured differs.

`max_resident_memory_percent` was documented and stays for now.

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

* refactor: enforce the strict mode memory limit outside the quota

`max_resident_memory_percent` was folded into the quota as an override,
which meant the quota check had to know about strict mode, and retiring
the setting would mean unpicking `EffectiveLimit` and `LimitSource` from
the resolution logic.

It is now a check of its own in `verification/mod.rs`, next to the strict
mode checks it belongs with, borrowing only the measurement from the quota
manager — which stays the node's single reader of process memory, so both
checks still share one reading. Deleting the setting later is deleting one
function and its one caller.

`QuotaManager::check_update` takes no arguments and consults the quota
alone. A collection can still only tighten the limit for itself, because
its own check runs in addition rather than in place of the quota's, and
each rejection now names the config that has to change without having to
carry a `LimitSource` to say so.

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

* refactor: enforce the quota on the update path, not in strict mode

The quota check sat inside `check_strict_mode_toc_batch` only because that
was the one place holding the collection's strict mode config. It doesn't
need one any more, and the placement had a real cost: coverage depended on
each handler remembering to ask for a strict mode check, and four of the
internal update RPCs do — `sync_internal`, which moves the most bytes onto
a node, does not.

It now runs in `Collection::update_from_client` and `update_from_peer`,
which every update passes through. `update_from_client` checks ahead of the
shard split, so an operation is accepted or refused whole rather than
landing on some shards and being refused by others.

Classification moves with it, from ~10 `consumes_memory` impls on request
DTOs to one exhaustive `CollectionUpdateOperations::consumes_quota`. The
internal enum has variants — raw upserts, conditional upserts, the syncs —
that have no client-facing request type, so per-DTO impls structurally
could not classify them.

Shard-transfer syncs stay excluded, as they are today: a transfer is sized
up once before it starts, and refusing its batches partway abandons work
that is nearly done only for it to restart from the beginning.

Index and named-vector creation reach shards through consensus, past this
check — a peer must not refuse what the cluster agreed to — so they keep
their pre-consensus check, now against the quota manager directly.

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

* feat: deprecate `max_resident_memory_percent` in strict mode

Same reason the disk threshold went: memory is node-wide, so a
per-collection percentage of it caps how full the *node* is, which has
nothing to do with which collection is being written to. The node-wide
quota caps it once for everything.

Unlike the disk threshold this one shipped documented, in 1.18.0, so it
keeps working — as a limit a collection can tighten for itself, never lift
— and gets the usual markers: `#[deprecated]` on both Rust structs,
`[deprecated = true]` on proto field 21, and `deprecated: true` in the
OpenAPI schema, which schemars derives from the attribute.

The note names 1.21 as the removal. Recording a version matters here: the
audit in docs/plans/overdue-deprecations.md found that this repo has never
written a removal deadline down, and members of the 1.15.0 deprecation
batch are still in tree.

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

* fix: reconcile the quota readers with #9891

#9891 landed effective (cgroup) figures in telemetry while this branch was
making QuotaManager the single reader of memory and disk. Two collisions,
neither of which git sees.

`segment::utils::mem::total_memory_bytes` is now a shared accessor with a
5s TTL, so a cgroup resize is picked up. The quota module had its own
`OnceLock` copy that froze the value at startup — exactly what #9891 set
out to fix — so it delegates to the shared one instead.

Telemetry's new `disk_size` called `common::disk_usage::disk_usage`
directly. That reader lost its TTL cache on this branch when the caching
moved into the quota manager's meter, so it would have taken an uncached
`statvfs` on every telemetry request, and it put a second disk reader back
in the tree. It goes through `QuotaManager::disk_capacity_bytes` now,
sharing the reading the quota check already takes. Verified it still
reports the storage filesystem, matching `df`.

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

* refactor: split the quota manager by what each half does

`manager.rs` had grown to 450 lines holding three separate jobs: owning
the config and its file, taking the readings, and comparing one against
the other.

- `manager/store.rs` — the `Store` enum, `QUOTA_CONFIG_FILE`, and config
  validation, which is now the store's own business rather than something
  every caller has to remember to do first.
- `manager/measure.rs` — every reading, and `DiskFit`. The "nothing else
  calls `statvfs` or reads process RSS" claim is now checkable by looking
  at one file.
- `manager/enforce.rs` — `check_update` / `check_capacity` and the
  threshold comparison.
- `manager/mod.rs` — the struct, its construction, and the config
  accessors: what a reader needs to see first.

Tests move with their subject. No behaviour change: `set_config` used to
validate before delegating to the store, and now the store validates on
write, which is the same order of operations from the outside.

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

* fix: count copy-on-write deletes toward the quota

Dropping a vector or a payload key does not free anything on its own:
copy-on-write rewrites the point to produce the version without that
field, so storage grows first and is only reclaimed once the optimizer
gets to it. Gating those as if they were reclaiming space let a full node
keep taking writes that make it fuller.

Deleting whole points stays exempt. That is the one operation that has to
work on a node at its limit, or there is no way back under it.

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

* docs: say that the quota's reported usage is per node

`GET /quotas` returns one cluster-wide config and one set of utilization
figures, which reads as though both describe the cluster. They do not:
memory and disk are node-local, so `usage` is whatever the peer that
served the request is seeing, and a peer under its limit says nothing
about the others.

Also corrects `resident_memory_percent`, which claimed to be a share of
total system memory. It is a share of the memory available to the
process, which under a cgroup is the limit rather than the host's RAM.

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

* feat: treat a node over its quota as a failed replica, not a bad request

A quota rejection described the request as invalid (400) and was classified
non-transient, which is how the replica set recognises errors that every
replica would produce alike. A quota is the opposite: the input is fine and
the answer depends on which machine you ask. On the default `wait=false`
path that combination silently dropped the write — `update.rs` only
deactivates transient failures when nothing completed — leaving the replica
Active and permanently missing data its co-replicas had.

It is now `InsufficientStorage`, transient, HTTP 507 / gRPC
`ResourceExhausted`. So a node that is out of room is handled like one that
is offline:

- last active replica, or every replica over quota: nothing could take the
  write, and the client is told the cluster is out of room.
- more than one replica: the full node is deactivated through the same path
  a dead peer takes, and the update stands if enough replicas accepted it.
  `check_capacity` already keeps recovery off that node until it has room.

The check also moves off `update_from_client`, which applied the
coordinator's own limit to the whole operation even when it held no replica
of the shards being written. Each replica set now gates its own local write
and records the refusal as a failure of this peer, so a node only ever
answers for itself.

`ResourceExhausted` is shared with rate limiting, and the reverse conversion
mapped it straight to `RateLimitExceeded` — a forwarded rejection came back
as 429. Statuses now carry a marker so the two stay distinguishable across
the wire.

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

* feat: report quota pressure per node, and across the cluster

A quota is node-local, so finding out which node has hit one meant asking
each of them in turn — and nothing at all showed up in monitoring.

`/metrics` gains a `quota_exceeded` gauge for the local node. It is emitted
only while the quota is enabled: with it off the value would be a constant
0 that says nothing about the node, and an alert built on it would go quiet
rather than fire if someone disabled the quota. Telemetry's `quota` field
carries the same verdict alongside the config, since that is where the
metric is derived from.

`GET /quotas` now answers for the whole cluster. A new `GetQuotaUsage` RPC
on the internal `QdrantInternal` service returns what one peer is using,
and the handler fans it out to every known peer in parallel. Peers that do
not answer are left out rather than failing the request — the nodes that
are out of room are exactly the ones most likely to time out, and a partial
answer still names them. Outside distributed mode the field is absent
rather than a map of one.

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

* feat: report the quota metric per resource

`quota_exceeded` was one flag for the whole node, which does not say what
to go and fix — disk is freed by deleting or optimizing, memory by
unloading. It now carries a `resource` label:

    quota_exceeded{resource="memory"} 0
    quota_exceeded{resource="disk"} 1

A resource with no limit gets no series at all, for the same reason the
metric is absent while the quota is disabled: a series that can never reach
1 reads as healthy and would quietly carry an alert that cannot fire.

`QuotaManager::exceeded` returns the per-resource verdict, with `None` for
a resource this node does not cap. Telemetry reports the same breakdown,
since the metric is derived from it. The peer usage RPC keeps a single
flag — it sits next to both percentages, so it only has to answer "is this
peer refusing writes".

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

* fix: drop a no-op error conversion the linter caught

`check_global_access` already returns a `StorageError`, so mapping it
through `StorageError::from` converted the type to itself and tripped
`clippy::useless_conversion`.

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

* feat: hold a tripped quota until usage clears a release margin

A resource resting on its limit crosses it in both directions on the noise
between two readings, and each crossing is expensive: the node refuses a
write, its replica is deactivated, usage dips, recovery starts sending a
whole shard copy back, and the arriving data pushes it over again. The loop
sustains itself, and every lap costs a shard transfer.

A limit now trips at its configured value but only clears once usage has
fallen 5 percentage points below it, so the crossing has to be real. The
margin is floored at 1%, since a limit smaller than the margin would
otherwise be impossible to fall back under and would strand the node.

The verdict is carried on the manager rather than recomputed, which makes
it the thing reporting shows: expect `exceeded` to be set while the
utilization next to it is already back under the limit. Rejections say so
too, rather than claiming a limit that is no longer exceeded:

    Disk usage is at 87% of total capacity. It reached the configured limit
    of 90% and has to fall below 85% before this node takes writes again.

Changing the config clears the verdicts. New limits are a deliberate act,
and should not be held back by the margin of a limit that no longer exists.

Both resources are now evaluated on every check instead of stopping at the
first failure, so a verdict is never left behind reporting a reading that
has since been superseded.

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

* feat: make the quota release margin configurable

5 points is a guess about how noisy a deployment's usage is, which is not
something one number can be right about: a node whose disk moves in
gigabyte steps needs a wider margin than one that creeps, and an operator
who wants the old flip-on-every-reading behaviour should be able to ask
for it.

`release_margin_percent` joins the rest of the quota config, so it seeds
from `QDRANT__STORAGE__QUOTAS__RELEASE_MARGIN_PERCENT`, replicates through
consensus, and changes with `PUT /quotas`. Defaults to 5 and is filled in
when a request omits it, so it always answers with the margin actually in
force rather than leaving the caller to assume one. `0` releases as soon as
usage is back under the limit.

`QuotaConfig` grows a hand-written `Default` for it, since deriving one
would have quietly defaulted the margin to 0 and disabled the hysteresis
for anyone constructing a config in code.

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

* refactor: leave the release margin unset by default, and hold verdicts in atomics

`release_margin_percent` is `null` unless someone sets it, rather than
materialising 5 into every config. A quota written today then does not pin a
number a later release may want to revise, and `{"enabled": false}` still
round-trips as itself. `QuotaConfig::limits` resolves it, next to `enabled`,
so enforcement never sees the unset case.

The verdicts move from a `Mutex<QuotaExceeded>` to one `AtomicBool` per
resource. They are judged independently and nothing reads them as a pair, so
the lock only added contention to the path every update takes; a verdict
that races a concurrent check is re-decided by the next one from a fresh
reading.

That also drops the tri-state. Only "was this over its limit" has to survive
between checks — whether a resource is enforced at all follows from the
config and the reading, so it is derived when reporting rather than stored.

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

* docs: drop a comment arguing with a design that was never here

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

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 11:20:34 +02:00
xzfc 75385df69f Remove dead code (#10030)
* Remove dead code

* Remove unused dependencies

* `allow(dead_code)` -> `expect(dead_code)`

* ast-grep: rule-tests/*-test.yml => tests/*-test.yml

For brevity.

* ast-grep: forbid allow(dead_code)
2026-07-30 20:59:31 +00:00
Luis Cossío d32f738c1f [CI] Enforce no default impl for batch methods (#9939)
* [AI] Add ast-grep rule to avoid default batch trait methods

* reword

* fix `FullTextIndexRead::check_match_batch`

* move to `tools/ast-grep/`

* Add tests

* pin ast-grep version

* fix spelling
2026-07-23 14:18:19 -04:00
Ivan Pleshkov 48e4e1ed54 TQ SIMD (#8749)
* TQ 4 bit SIMD

* more optimizations

* unroll test

* remove tries

* revert avx 512

* final simd

* use precomputed codebooks

* close to finish

* split to files

* are you happy fmt

* score internal

* 1bit

* 1bit tails

* score_1bit_internal_avx2 tail

* 1bit simd

* 2bit case

* fix 2bit

* fix features

* tails

* fix tests

* less benches

* 1bit tails

* 4bit tails simd

* 64k overflow test

* reuse packing and constants from dev after rebase

* are yoy happy fmt

* fix x64 build

* integration

* symmetric score SIMD

* fix codespell

* better docs

* are you happy clippy

* review remarks

* review remarks
2026-04-28 10:02:28 +02:00
xzfc ef2b47a345 shell.nix: update pinned dependencies (#8623)
Problems:
- The pinned `uv` version sometimes pulls broken python interpreter.
- The pinned `just` is too old to read `lib/edge/Justfile`.

Solution: update everything.

    nix-shell --run 'cd tools/nix && npins update' # for default.nix
    nix-shell --run 'cd tools/nix && npins upgrade' # for sources.json

Also, in this nixpkgs version, renames `nixfmt-rfc-style` into `nixfmt`.
2026-04-08 03:51:23 +00:00
xzfc 0b0df145b3 Drop RocksDB (#8529)
* Skip broken tests

* Add rocksdb dropper

This is a temporary tool. It will be removed later in this PR.

* [automated] Drop rocksdb

This commit is made by running tools/rocksdb/drop.sh

* Touch-up after ast-grep

The previous automated commit removed items, but not their comments.
Also, some blocks are left with only one item.
Also, ast-grep can't handle macros like `vec![]`.

This commit completes the job.

* Remove RocksDB dropper

* Remove mentions of rocksdb feature in CI

* Fix clippy warnings

These `FIXME` comments added previously in this PR by ast-grep by
"peeling" cfg_attr like this:

    -#[cfg_attr(not(feature = "rocksdb"), expect(...))]
    +#[expect(...)] // FIXME(rocksdb): ...

This commit removes these allow/expect attributes and fixes clippy
lints.

* Remove leftover rocksdb-related code

Removed:
- Cargo.toml: rocksdb cargo feature flag and dependencies.
- code: rocksdb-related items that was not under feature flag.
- flags.rs: rocksdb-related qdrant feature flags.

Disabled:
- Some benchmarks because these do not compile now.

* Print warning if rocksdb leftovers found in snapshots

* Remove Clone from tokenizer

* Regenerate openapi.json
2026-03-31 18:08:39 +00:00
ad8334928d Use UniversalIo for MmapBitSlice (#8339)
* feat(universal_io): add storage-agnostic BitSliceStorage with read/write support`

Add BitSliceStorage<S> generic over
UniversalRead<u64>/UniversalWrite<u64>,
providing bit-level read and write operations over u64-element storage.

Read operations (S: UniversalRead<u64>):
- read_all: returns Cow<BitSlice> (zero-copy for mmap, owned for others)
- get_bit: single bit read via u64 element fetch
- read_bit_range: arbitrary bit range read

Write operations (S: UniversalWrite<u64>):
- set_bit / replace_bit: single bit write (skips write if unchanged)
- write_bit_range: arbitrary bit range write from BitSlice source
- fill_bit_range: fill range with a value
- set_bits_batch: batch individual bit updates coalesced by element
- flusher: flush underlying storage

* refactor: replace MmapBitSlice with BitSliceStorage in MmapBitSliceBufferedUpdateWrapper

Migrate all deleted-flag bitslice storage from the legacy MmapBitSlice
(Deref-based mmap wrapper) to BitSliceStorage<MmapUniversal<u64>>
(storage-agnostic universal IO backend).

Updated consumers:
- MmapMapIndex
- MmapNumericIndex
- MmapGeoMapIndex
- MmapInvertedIndex (fulltext)
- ImmutableIdTracker
- Benchmark

Additionally:
- Add BitSliceStorage::create(path, num_bits) to encapsulate
  file creation + sizing + open (eliminates duplicated size math
  across 5 call sites)
- Add MmapBitSliceStorage type alias for
BitSliceStorage<MmapUniversal<u64>>
- Add count_ones() convenience method
- Use set_bits_batch() in wrapper flusher and all build paths
  instead of per-bit set_bit() loops (coalesces u64 read-modify-writes)
- Fix silent error swallowing in wrapper get(): log + debug_assert
  on I/O errors instead of .ok().flatten()
- Remove dead bitmap_mmap_size function from immutable_id_tracker

* use bitvec's approach for offset

* less api

* misc improvements

* refactor write method

* move to segment crate

* handle creation of file outside of StoredBitSlice logic

* fix codespell

* document bitwise calculations

* coalesce more updates into a single write, batch all writes

* use native `extend_from_bitslice` instead of iterating.

* clarity refactor

* clippyyy

* use `u64` as BitStore everywhere

* assume iterator is sorted

* only use chunk_by for generating runs

* fix update wrapper flusher

* review fixes

* larger set bits batch test

* remove reintroduced file

* oops, fix new test

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: generall <andrey@vasnetsov.com>
2026-03-19 12:26:47 -03:00
Tim Viséeanddependabot[bot] 8ecd7aa1f1 build(deps): bump lodash in /tools/schema2openapi (#7968)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-22 10:40:02 +01:00
tellet-q 2ae05890c5 Move test dependencies to tests (#7793)
* Move pyproject and uv.lock to tests folder

* Make tests working-dir agnostic

* Fix test

* Address review
2025-12-17 15:50:28 +01:00
b0bb7ef604 Migrate Python to uv (#7790)
* Move pyproject.toml to root

* Migrate pyproject.toml from Poetry to uv

* Update GH workflows

* Update test script, doc and nix to use uv

* Use latest uv

* Fix uv.lock

* Cleanup shell.nix

* Cleanup

- Explicit `uv sync` is not required, `uv run` will install deps
  automatically.
- We don't provide a python package, so the `[build-system]` section
  is not needed.

* Fix UV_VERSION inconsistency

---------

Co-authored-by: tellet-q <elena.dubrovina@qdrant.com>
Co-authored-by: xzfc <xzfcpw@gmail.com>
2025-12-16 16:45:13 +01:00
Tim Visée 57ad76db98 Disable RocksDB features in local development builds (#7552)
* Disable rocksdb compile time feature by default

* Also disable RocksDB feature in segment crate

* Enable RocksDB feature in all CI builds

* Remove extra job for testing non-RocksDB build, it's the default now

* Keep RocksDB structures in generated OpenAPI schema

* Fix obsolete --workspace flag breaking builds with explicit features

* Also build including RocksDB in e2e tests on CI
2025-11-25 17:29:50 +01:00
xzfc 962c036b49 Drop docs/grpc/docs.md (#7453) 2025-10-27 11:23:26 +00:00
aa0f49798e Full-Text Index ASCII Folding (Normalization) (#7408)
* Add ASCII folding to tokenization process

Introduced an optional ASCII folding feature within the `TokensProcessor` to normalize non-ASCII characters to their ASCII equivalents. Updated tests and documentation to reflect the changes.

* Refactor tokenization code for improved readability and maintainability

Reorganized and reformatted the tokenization module, including `TokensProcessor` initialization and ASCII folding mappings for better clarity. Updated tests to align with the changes.

* Update test cases to reflect optional tokenizer settings changes

Adjusted `ascii_folding`, `lowercase`, and `phrase_matching` settings in tests to `None` where applicable, aligning with updates in tokenizer configuration defaults.

* address review remarks

* fix codespell

* thx coderabbit

* Don't copy tokens that are already ASCII

* Shrink folded string to fit

---------

Co-authored-by: Luis Cossío <luis.cossio@outlook.com>
Co-authored-by: timvisee <tim@visee.me>
2025-10-16 13:53:01 +02:00
e86d60e6b0 slow requests log (#7188)
* wip: generalization trait for queries

* implement generalization for point operations

* fmt

* log priority queue

* wip: SlowRequestsListener

* fmt

* fix clippy

* simplify generalization

* fmt

* implement collection of requests profiles for update API

* implement API for viewing slow requests log

* add collection name to update worker

* add datetime to log

* fmt

* probabilistic counter of unique requests

* rename

* compute hash before converting into json value

* move logable out of generalizable

* fmt

* log query request

* fmt

* some fixes

* move measurement into local shard

* fmt

* upd openapi (not important)

* For enum variants, has discriminant

* Make SearchParams Copy

* Hash 0.0 and -0.0 the same

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Correctly hash enum variants and float values

* Hash through ordered float instead

* Fix priority queue not keeping longest request for hash

* SearchParams implements Copy

* Fix clippy warning

* Add unordered_hash_unique

* skip serialization if none

* Use OrderedFloat for hashing a float

* Use OrderedFloat for hashing a float

* only log updates if they are performed

---------

Co-authored-by: timvisee <tim@visee.me>
Co-authored-by: Tim Visée <tim+github@visee.me>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: xzfc <xzfcpw@gmail.com>
2025-09-19 19:59:25 +02:00
xzfc 23dd2bbbfb shell.nix: switch to rustup (#7049)
* shell.nix: npins upgrade

* shell.nix: bump to rust 1.89

* shell.nix: use rustup instead of fenix
2025-08-13 12:09:12 +00:00
tellet-q f0612d6680 Refactor bash tests: tls (#6995)
* Refactor tls bash test

* Update codespell

* Address review
2025-08-11 10:05:47 +02:00
Andrey Vasnetsov b58fd263d2 add example of multi-node docker-compose file for easier experiemnting (#6953)
* add example of multi-node docker-compose file for easier experiemnting

* rename peers and add healthcheck
2025-08-07 00:49:21 +02:00
tellet-q 9597a8bee1 Hardcode the link (#6985)
* Hardcode the link

* Fix image build
2025-08-06 11:24:16 +02:00
Kumar Shivendu edd3f12899 Fix coverage failure after recent changes (#6948) 2025-07-29 21:28:58 +05:30
Andrey Vasnetsov 9102c888a1 add retries to curl (#6820) 2025-07-08 09:54:23 +02:00
xzfc ff0df47714 Move codespell config to tools/codespell.toml (#6707) 2025-06-16 22:06:06 +00:00
xzfc 5169bf26a3 shell.nix: bump to rust 1.87 (#6547)
* shell.nix: bump to rust 1.87

* shell.nix: workaround for jemalloc
2025-05-16 10:16:58 +00:00
n0x29aandjojii 73e7b17ee8 Refactor: move HardwareUsage to the Usage map (#6532)
---------

Co-authored-by: jojii <jojii@gmx.net>
2025-05-14 21:01:49 +02:00
Kumar Shivendu c8a960604a Introduce coverage reports for integration tests (#6414)
* Introduce coverage reports for integration tests

* Install cargo-llvm-cov

* Use multiline script

* Explicityl setup COVERAGE env var

* fix integration tests and log generated data

* fix ls path

* upload lcov file to GH artifacts

* integration profraw dynamic filename

* Fix llvm profile filename template

* Use interrupt instead of kill and merge consensus test results into same file

* Drop upload artifact stage

* install llvm-cov

* upload as artifact and export coverage files

* try simplifying workflow

* Migrate coverage generation to existing dedicated gh workflow

* trigger on coverage related branches

* Build only if qdrant binary with cov doesnt exist

* Use valid yaml

* include mode in profraw filename

* split coverage workflow into parallel jobs

* add poetry version to env

* log poetry version to install

* clean up integration test workflow

* Simplify comments
2025-04-25 16:42:41 +05:30
Andrey Vasnetsov 75e5635d23 Add a tool to view percentage of mmaps cache (#6310)
* Add a tool to view percentage of mmaps cache

* review fixes
2025-04-03 10:50:16 +02:00
xzfc 8f2b5822a6 shell.nix: bump to rust 1.85 (#6060) 2025-02-25 14:00:04 +00:00
Kumar Shivendu b09ae8dd7c Fix coverage test OOD on CI (#5927)
* Fix coverage test OOD on CI

* Temporarily run coverage CI on PR

* Clean artifacts per package and store in tmp dir

* fix typo in gh workflow

* Add monitoring script again for debugging

* trigger script

* Fix monitor script path

* dont checkout dev branch

* Merge .info file only if test passed

* Try merging .info file only if it exists

* trigger ci

* fix workflow

* trigger ci

* Customize branch to check out

* Remove monitor.sh script

* remove unused env var
2025-02-05 21:45:47 +05:30
Kumar Shivendu b2ba0f966f Setup code coverage reports (#5751)
* Setup code coverage for Rust tests

* Add API key env var for codecov

* Save code coverage report for upload

* Trigger CI

* Try without explicit build step

* Run coverage job on self hosted runner

* Fix mistake because of which is was running fewer tests

* Run coverage on ubuntu latest

* Trigger CI

* fix name

* run coverage on all os

* Adjust after rebase to dev

* Avoid running coverage in other jobs

* fix test job

* reset test workflow

* Trigger CI

* run coverage after tests

* Add script to monitor resources

* fix indentation

* remove coverage dependency on test job

* fix needs field

* add monitoring script

* Run tail -f to monitor resources concurrently with tests

* Split commands

* Use --jobs=1 to possibly minimize RAM

* Try generating coverage one by one

* Dont clean coverage artifacts

* Merge .lcov files with lcov command

* Upload merged lcov.info file

* Run coverage for fewer packages

* Improve coverage script

* Move coverage.sh to tools dir

* Prepare for review

* Improve CI output and failure handling

* Generate HTML report if running locally

* Cleanup

* Run coverage on schedule and only for dev branch
2025-01-29 23:51:22 +05:30
xzfc 876ddd9944 shell.nix: bump to rust 1.83 (#5578)
* shell.nix: bump to rust 1.83

* shell.nix: add cmake (required by gpu deps)
2024-12-03 17:08:01 +00:00
Arnaud Gourlay ae857340ed Do not build schema_generator by default (#5482) 2024-11-19 16:46:02 +01:00
xzfc 10ce515ecf shell.nix: bump to rust 1.81, misc changes (#5185)
* shell.nix: add a comment

* tools/nix/update.py: let it run outside of the nix-shell

* shell.nix: bump to rust 1.81
2024-10-07 10:30:20 +00:00
xzfc 35dad67771 Add shell.nix (#4821) 2024-08-08 16:57:14 +00:00
Luis Merinoandtimvisee 36d7e11624 Fix web UI index path http security headers (#4517)
* Draft: web-ui root endpoint x-frame-options: deny header

* Switch to async

* Simplify setting frame options header by using DefaultHeaders

---------

Co-authored-by: timvisee <tim@visee.me>
2024-06-25 13:44:25 +02:00
xzfc b87e6d2bdd Improve tools/*.sh (#4365)
* Speedup tools/generate_openapi_models.sh

* Improve tools/generate_grpc_docs.sh
2024-05-31 09:51:37 +00:00
xzfc 3ad1528ebe Use /usr/bin/env bash in shebangs (#3570) 2024-02-09 11:42:29 +01:00
Kaan C. Fidanandtimvisee c7402a45d7 Manhattan distance (#3079)
* implemented Manhattan distance

* updated quantization dependency

* fixed negative distances and doc consistency

* fixed neon implementation

* updated quantization dependency

* updated quantization dependency

* removed redundant copy operation

* updated quantization dependency

* Change back to upstream quantization dependency

---------

Co-authored-by: timvisee <tim@visee.me>
2023-12-02 21:28:38 +01:00
Tim Visée d321b64b97 Add tool script to clean old RocksDB log files from disk (#3071) 2023-11-22 09:58:53 +01:00
Andrey Vasnetsov 74de1483be Shard key create confirmation (#3027)
* create dedicated API for creating shards with explicit avait on the consensus

* fmt

* update api definitions
2023-11-16 15:58:32 +01:00
Roman Titov cab234c391 Add shard snapshot gRPC API (#2825)
* Fix paste-bugs in `snapshot_service.proto`

* Add shard snapshot gRCP API definition

* Add validation to shard snapshot gRPC API definition

* Implement conversions between gRPC and `collection` types

* Extract shard snapshot API implementation into common sub-module

* Implement shard snapshot gRPC API

* Generate gRPC docs

* Refactor `ShardSnapshots` gRPC service to be internal API only

* fixup! Refactor `ShardSnapshots` gRPC service to be internal API only

Move `ShardSnapshotRecoverResponse` to `shard_snapshots_service.proto`

* fixup! fixup! Refactor `ShardSnapshots` gRPC service to be internal API only

Update `api/src/grpc/qdrant.rs`

* fixup! fixup! Refactor `ShardSnapshots` gRPC service to be internal API only

Update gRPC docs

* Switch `ShardSnapshots` gRPC service to use `validate_and_log` instead of `validate`
2023-10-18 14:34:58 +02:00
Andrey Vasnetsov 326ef54664 openapi definitions for shard shashots API (#2571)
* openapi definitions for shard shashots API

* review fixes
2023-09-04 14:54:08 +02:00
Luis Cossío 0caeb3a5e3 remove dist zip after unzipping it (#2487) 2023-08-22 18:02:02 +02:00
Andrey Vasnetsovandtimvisee 0ccca76949 allow to configure qdrant init file with env variable (#2316)
* allow to configure qdrant init file with env variable

* Return path type from get_init_file_path

---------

Co-authored-by: timvisee <tim@visee.me>
2023-07-24 16:37:36 +02:00
Tim Visée e1a69099fc Add script to list commits that have yet to be picked into master (#2108)
* Add script to list commits that have yet to be picked into master

This allows us to easily detect cherry-picks we missed from dev to
master on our release branch.

* Update missed cherry picks ignore hash
2023-06-28 14:57:49 +02:00
Andrey Vasnetsov aef9e0833d use bash in the entrypoint.sh for good traps 2023-06-19 14:34:16 +02:00
Andrey Vasnetsov 967d387a37 Web UI integration (#2009)
* wip: integrate UI web interface

* fmt

* Api key exclusion rule + fixes

* upd welcome url

* rollback api key in config
2023-06-06 21:42:24 +02:00