Skip to content

Add performance benchmarks for core Rust operations #137

Closed

Description

@malibio

Overview

Set up Criterion.rs benchmarks for the core Rust package to ensure performance standards are maintained across business logic layer implementations.

Context

NodeSpace already has performance tests for the frontend (event bus, node manager). We need equivalent performance testing for the Rust backend to ensure:

  • Fast node CRUD operations
  • Efficient vector search with embeddings
  • Optimized JSON path queries
  • Database operation benchmarks

Implementation Tasks

  • Create packages/core/benches/ directory structure
  • Add Criterion.rs to dev-dependencies
  • Implement node CRUD operation benchmarks (insert, query, update, delete)
  • Implement vector search benchmarks with varying dataset sizes (1k, 10k, 100k nodes)
  • Implement JSON path query benchmarks (indexed vs non-indexed properties)
  • Add database transaction benchmarks
  • Set up baseline performance metrics
  • Document performance expectations in README

Performance Targets (Initial)

Based on desktop app requirements:

  • Single node insert: < 1ms
  • Batch insert (1000 nodes): < 100ms
  • Vector search (10k nodes): < 50ms
  • JSON path query with index: < 5ms
  • JSON path query without index: < 20ms

Dependencies

Blocked by: Issues implementing actual functionality

  • Node CRUD operations (future)
  • Vector search implementation (NLP engine integration)
  • Schema service with JSON queries

Can start when: Core models and database layer are implemented

Technical Specifications

Criterion.rs Configuration:

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }

[[bench]]
name = "node_operations"
harness = false

Example Benchmark Structure:

// benches/node_operations.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use nodespace_core::services::NodeService;

fn bench_create_nodes(c: &mut Criterion) {
    c.bench_function("create 1000 nodes", |b| {
        b.iter(|| {
            // Benchmark implementation
        });
    });
}

criterion_group!(benches, bench_create_nodes);
criterion_main!(benches);

Reference

Existing frontend performance tests:

  • packages/desktop-app/src/tests/performance/event-bus-performance.test.ts
  • packages/desktop-app/src/tests/performance/node-manager-performance.test.ts

Use similar patterns and thresholds for Rust backend benchmarks.

Acceptance Criteria

  • Benchmark directory structure created
  • Criterion.rs configured and running
  • At least 5 core operation benchmarks implemented
  • Baseline metrics documented
  • CI integration (optional: track performance over time)
  • README updated with how to run benchmarks

Activity

  1. self-assigned this
    on Jul 31, 2026
  2. mstomar125 commented on Jul 31, 2026

    @mstomar125
    Contributor

    Picking this up now (remote/mini session). Folding the query-benchmark follow-up #157 into this benches effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementperformancetesting

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions