home / skills / redisearch / redisearch / run-rust-benchmarks

run-rust-benchmarks skill

/.skills/run-rust-benchmarks

This skill runs Rust benchmarks and compares performance against the C implementation to help optimize the Redisearch Rust integration.

npx playbooks add skill redisearch/redisearch --skill run-rust-benchmarks

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.3 KB
---
name: run-rust-benchmarks
description: Run Rust benchmarks and compare performance with the C implementation
---

# Rust Benchmarks Skill

Run Rust benchmarks and compare performance with the C implementation.

## Arguments
- `<crate>`: Run the given benchmark crate (e.g., `/run-rust-benchmarks rqe_iterators_bencher`)
- `<crate> <bench>`: Run specific bench in a benchmakr crate (e.g., `/run-rust-benchmarks rqe_iterators_bencher "Iterator - InvertedIndex - Numeric - Read Dense"`)

Arguments provided: `$ARGUMENTS`

## Instructions

1. Check the arguments provided above:
   - If a crate name is provided, run benchmarks for that crate:
     ```bash
     cd src/redisearch_rs && cargo bench -p <crate_name>
     ```
   - If both crate and bench name are provided, run the specific bench:
     ```bash
     cd src/redisearch_rs && cargo bench -p <crate_name> <bench_name>
     ```
2. Once the benchmarks are complete, generate a summary comparing the average run times between the Rust and C implementations.

## Common Benchmark Commands

```bash
# Bench given crate
cd src/redisearch_rs && cargo bench -p rqe_iterators_bencher
cd src/redisearch_rs && cargo bench -p inverted_index_bencher

# Run a specific benchmark
cd src/redisearch_rs && cargo bench -p rqe_iterators_bencher "Iterator - InvertedIndex - Numeric - Read Dense"
```

Overview

This skill runs Rust benchmark crates for the query and indexing engine and produces a concise comparison against the C implementation. It automates executing cargo benchmarks for a chosen crate or a specific bench and summarizes average run-time differences. The output focuses on clear performance deltas useful for optimization decisions.

How this skill works

The skill changes to the Rust workspace and invokes cargo bench for the specified crate or for a single benchmark within that crate. After the bench completes, it extracts average run times and compares them to the recorded C implementation results, producing a side-by-side summary of performance differences. The summary highlights regressions, improvements, and percent change.

When to use it

  • When validating performance parity after porting C logic to Rust
  • Before merging Rust performance-sensitive changes into mainline
  • To profile specific iterator or inverted-index operations
  • When benchmarking vector search or full-text query components
  • During release verification to ensure no unexpected regressions

Best practices

  • Provide the crate name and, when needed, the exact bench string to avoid running long suites
  • Run benchmarks on a quiet, consistent machine to reduce variance
  • Repeat runs and use the average or median to reduce noise
  • Record C baseline numbers beforehand for reliable comparisons
  • Focus on benches relevant to the changed code to save time

Example use cases

  • Run all benches for the iterator bencher to verify Rust optimizations: run crate rqe_iterators_bencher
  • Benchmark a specific operation: run crate rqe_iterators_bencher and bench "Iterator - InvertedIndex - Numeric - Read Dense"
  • Compare inverted-index latencies between Rust and C after refactoring
  • Validate vector similarity search performance after SIMD optimizations

FAQ

What command runs a crate benchmark?

Change into the Rust workspace and run: cd src/redisearch_rs && cargo bench -p <crate_name>.

How do I run a single benchmark within a crate?

Run the crate with the bench name quoted: cd src/redisearch_rs && cargo bench -p <crate_name> "<bench_name>".