agentleFS
zilliztechzilliztech/knowhere/.agents/skills/index-optimization/SKILL.md

index-optimization

Skill390 starsChanged 10 days agoApache-2.0View on GitHub

Use when developing or evaluating Knowhere index performance optimizations, including construction cost, memory use, insertion, recall, and search workload coverage.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before changing an index, identify the affected build, insertion, storage, and search paths and define a baseline and representative …

    line 8
  2. Distinctive:

    Use a construction-phase RSS sampler or a build-only process high-water measurement.

    line 27
  3. Distinctive:

    Check meaningful interactions, such as large top-k with high filtering, or high-NNZ sparse queries with high filtering.

    line 48
  4. Distinctive:

    Use exact ground truth with the same metric, queries, and filters.

    line 68
  5. Distinctive:

    Use identical query IDs and filter masks for paired comparisons.

    line 77
  6. Distinctive:

    Avoid overlapping benchmark runs that compete for CPU, memory bandwidth, or I/O.

    line 79
  7. Very specific:

    Keep raw results and commands.

    line 81
  8. Distinctive:

    Look for reusable benchmarks in benchmark/.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Index Optimization

Before changing an index, identify the affected build, insertion, storage, and search paths and define a baseline and representative workloads. Consider construction time, construction memory, query performance, and recall together. For queries, account for top-k and filtering; for sparse queries, also account for query NNZ. Use these dimensions during design, not only when writing the final benchmark report.

Respect the user's requested scope and resource budget. Choose representative combinations first, then expand where a regression, dispatch boundary, or interaction needs investigation. A full Cartesian product is not required for every change. State which dimensions were measured and which remain unvalidated.

Construction and memory

DimensionWhat to examine and measure
Build timeEnd-to-end wall time, including validation, training, counting, allocation, packing, and finalization. Separate data loading from index construction. Use phase timings to identify serial work and parallel scaling when relevant.
Build memoryPeak process RSS during construction, alongside input-data residency and final index memory. Track overlapping raw, typed, and packed buffers, worker scratch space, temporary metadata, and allocation capacity.
Final storageIn-memory index size and serialized size, reported separately from construction peak memory.
Growing indexesIf supported and affected, measure single-row and batched Add at multiple existing index sizes. Check throughput, latency distribution, reallocations, whole-index rescans/repacking, and write-lock duration when relevant.

Measure baseline and candidate memory in separate fresh processes with equivalent input loading. Use a construction-phase RSS sampler or a build-only process high-water measurement; state the method, units, and whether input vectors and shared/mapped data are included. A process-lifetime high-water mark collected after search or serialization cannot be attributed to construction alone.

Index::Size() and serialized bytes do not measure peak RSS. Label buffer-lifetime calculations as estimates rather than measurements, and include old/new buffer overlap during conversion or reallocation. A smaller final index can still require more memory to build.

Query workload coverage

Choose supported values that span the production workload and the implementation's branch thresholds. The following are starting points, not fixed requirements:

AxisRepresentative coverage
Top-kSmall, typical, and large requests, for example 1, 10, 100, and 1000 where meaningful.
Filter ratioNo filtering, light/moderate filtering, and highly selective filtering, for example 0%, 10%, 50%, 90%, and 99% excluded. Define the ratio as excluded documents divided by total documents and report eligible counts.
Filter distributionFor changes to filter/window/block handling, compare random masks with clustered or contiguous masks; equal global ratios can produce different local workloads. Include all-filtered and fewer-than-k eligible matches as correctness cases.
Sparse query NNZBucket real queries into low, medium, and high NNZ groups using observed ranges or quantiles. Record bucket boundaries and query counts. If pruning or refinement changes the query, report original and effective NNZ.
Execution settingsFix batch size, concurrency, thread pools, CPU affinity, and SIMD dispatch for comparisons. Vary them when the optimization specifically targets those dimensions.

Check meaningful interactions, such as large top-k with high filtering, or high-NNZ sparse queries with high filtering. For threshold-based dispatch, include inputs on both sides of the threshold. Report results by workload group so an overall mean cannot hide a regression in one group.

Bucket existing sparse queries without changing their contents. If synthetic generation, truncation, or other transformations alter a query, regenerate its ground truth. NNZ alone does not describe posting work: consider term frequency or posting-list length when it explains differences between query groups.

Recall and search performance

Report recall@k alongside QPS and latency for each top-k, filter, and sparse query NNZ workload group. Measure latency at the stated load, including tail latency when the sample count supports it. Define recall targets and acceptable regression tolerances for the workload before evaluating an optimization.

Compare speed and recall at the same search settings. For approximate search, also compare QPS/latency at matched recall targets, sweeping relevant search parameters to show the speed/recall tradeoff. Record the settings and achieved recall for each result; if a target cannot be reached, report that explicitly. Treat speedups accompanied by recall loss as a tradeoff requiring evaluation against the workload's quality target, especially for quantization, pruning, and refinement changes.

Use exact ground truth with the same metric, queries, and filters. Compute recall against the valid neighbors available up to k, and document empty-truth and tied-score conventions. For quantized indexes, measure recall against the original vectors and distinguish it from correctness of scores computed from stored values.

Reproducible comparisons

  • Record baseline/candidate revisions, compiler and build flags, hardware, actual SIMD path, dataset identity and size, index/search configuration, seeds, and workload buckets.
  • Use identical query IDs and filter masks for paired comparisons. Warm up and repeat timed runs; keep correctness/oracle work outside the timed search region and report variation.
  • Avoid overlapping benchmark runs that compete for CPU, memory bandwidth, or I/O. State whether cache conditions represent warm or cold operation.
  • Keep raw results and commands. Report build time, build peak memory, final size, and query latency/QPS/recall together with workload-specific regressions and untested configurations.
  • Choose relevant correctness checks through the testing skill; consult the building skill when compiling or changing build options.

Existing benchmarks

Look for reusable benchmarks in benchmark/. Inspect current code and options before reuse, and extend coverage for the chosen workload matrix where needed. Do not assume every parameter or platform is supported.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.