Skip to content

Conversation

@dylanbstorey
Copy link
Contributor

@dylanbstorey dylanbstorey commented Jan 10, 2026

Summary

  • Add in-memory CSR graph caching to accelerate graph algorithms by eliminating repeated SQLite I/O
  • Refactor all 17 graph algorithms to use cached graph when available
  • Add cache management functions for SQL, Python, and Rust bindings
  • Finalize GPU investigation ADRs (GPU not pursued; CPU caching provides sufficient benefit)

Performance

Benchmarks on Apple M1 Max show 2x speedup with caching enabled:

Graph Size Algorithm Uncached Cached Speedup
10K nodes PageRank 13ms 6ms 2.1x
100K nodes PageRank 154ms 73ms 2.1x
500K nodes PageRank 890ms 396ms 2.2x

API

-- Load graph into memory cache
SELECT gql_load_graph();

-- Run algorithms (automatically use cache)
SELECT cypher('RETURN pageRank()');

-- Reload after modifications
SELECT gql_reload_graph();

-- Free cache memory
SELECT gql_unload_graph();

Python/Rust bindings expose equivalent methods: load_graph(), unload_graph(), reload_graph(), graph_loaded().

Dylan Storey added 2 commits January 9, 2026 20:08
Add in-memory CSR (Compressed Sparse Row) graph caching to accelerate
graph algorithms by eliminating repeated SQLite I/O.

Cache management:
- gql_load_graph() - load graph into memory cache
- gql_unload_graph() - free cache memory
- gql_reload_graph() - refresh cache after modifications
- gql_graph_loaded() - check cache status

Algorithm changes:
- Refactored all 17 graph algorithms to accept optional cached graph
- When cache is loaded, algorithms use it automatically
- Fallback to SQLite when cache not available

Bindings:
- Python: graph.load_graph(), unload_graph(), reload_graph(), graph_loaded()
- Rust: Graph::load_graph(), unload_graph(), reload_graph(), graph_loaded()

Performance (Apple M1 Max):
- PageRank: 2.1-2.2x speedup with cache
- Label Propagation: 2.0-2.1x speedup
- Degree Centrality: 1.7-2.0x speedup

Build improvements:
- Added install-bundled target for Rust binding tests
- Fixed ARM64 detection for macOS (arm64 vs aarch64)
- ADR-0003: Mark as decided - GPU acceleration not pursued
  - Metal provides no benefit (~1.0x) on Apple Silicon
  - CPU caching provides 2x speedup with minimal complexity
  - Document lessons learned from wgpu and Metal experiments

- ADR-0004: Archive - GPU threshold config no longer relevant
@dylanbstorey dylanbstorey changed the title Feat/cache optimizations feat: CSR graph caching for 2x algorithm speedup Jan 10, 2026
Dylan Storey added 2 commits January 9, 2026 20:15
- Add perf cache-comparison and hop-depth benchmark tasks
- Add GPU test task structure (for future use)
- Update test-rust to rebuild bundled extension
- Add struct tag to csr_graph typedef for C type compatibility
- Remove redundant serde_json import (clippy warning)
@dylanbstorey dylanbstorey merged commit 0216c4b into main Jan 10, 2026
15 checks passed
@dylanbstorey dylanbstorey deleted the feat/cache-optimizations branch January 10, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants