@grafema/rfdb 0.2.3-beta → 0.2.6-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# @grafema/rfdb
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> **RFDB** (Rega Flow Database) — high-performance disk-backed graph database server for Grafema
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
*Named after the author's wife Regina (Rega for short). The Hebrew word רגע (rega, "moment") conveniently fits the concept — a flow of discrete moments captured in the graph.*
|
|
6
|
+
|
|
7
|
+
**Warning: This package is in beta stage and the API may change between minor versions.**
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -12,9 +14,8 @@ npm install @grafema/rfdb
|
|
|
12
14
|
|
|
13
15
|
Prebuilt binaries are included for:
|
|
14
16
|
- macOS x64 (Intel)
|
|
15
|
-
- macOS arm64 (Apple Silicon)
|
|
16
|
-
- Linux x64
|
|
17
|
-
- Linux arm64 - coming soon
|
|
17
|
+
- macOS arm64 (Apple Silicon)
|
|
18
|
+
- Linux x64
|
|
18
19
|
|
|
19
20
|
For other platforms, build from source (requires Rust):
|
|
20
21
|
|
|
@@ -30,10 +31,10 @@ cargo build --release
|
|
|
30
31
|
|
|
31
32
|
```bash
|
|
32
33
|
# Start the server
|
|
33
|
-
npx rfdb-server --socket /tmp/rfdb.sock
|
|
34
|
+
npx rfdb-server ./my-graph.rfdb --socket /tmp/rfdb.sock
|
|
34
35
|
|
|
35
|
-
#
|
|
36
|
-
rfdb-server
|
|
36
|
+
# Using default socket path (/tmp/rfdb.sock)
|
|
37
|
+
rfdb-server ./my-graph.rfdb
|
|
37
38
|
```
|
|
38
39
|
|
|
39
40
|
### Programmatic usage
|
|
@@ -66,7 +67,7 @@ server.kill();
|
|
|
66
67
|
|
|
67
68
|
## With Grafema
|
|
68
69
|
|
|
69
|
-
RFDB is
|
|
70
|
+
RFDB is the default storage backend for Grafema. The MCP server and CLI auto-start RFDB when needed.
|
|
70
71
|
|
|
71
72
|
```javascript
|
|
72
73
|
const { Orchestrator, RFDBServerBackend } = require('@grafema/core');
|
|
@@ -79,20 +80,22 @@ const orchestrator = new Orchestrator({
|
|
|
79
80
|
|
|
80
81
|
## Features
|
|
81
82
|
|
|
82
|
-
- **
|
|
83
|
-
- **
|
|
84
|
-
- **
|
|
85
|
-
- **
|
|
86
|
-
- **
|
|
83
|
+
- **Adaptive tuning** — Auto-detects CPU cores, memory, and disk type; tunes write buffers, compaction parallelism, and prefetch strategy
|
|
84
|
+
- **Columnar storage** — Efficient storage for graph nodes and edges
|
|
85
|
+
- **Deterministic IDs** — BLAKE3 hash-based node identification
|
|
86
|
+
- **Zero-copy access** — Memory-mapped files for fast reads
|
|
87
|
+
- **BFS/DFS traversal** — Fast graph traversal algorithms
|
|
88
|
+
- **Parallel compaction** — Multi-threaded background compaction
|
|
87
89
|
|
|
88
90
|
## Protocol
|
|
89
91
|
|
|
90
92
|
RFDB server communicates via Unix socket using MessagePack-encoded messages. The protocol supports:
|
|
91
93
|
|
|
92
|
-
- `add_nodes` / `add_edges`
|
|
93
|
-
- `get_node` / `find_by_attr`
|
|
94
|
-
- `bfs` / `dfs`
|
|
95
|
-
- `flush` / `compact`
|
|
94
|
+
- `add_nodes` / `add_edges` — Batch insert operations
|
|
95
|
+
- `get_node` / `find_by_attr` — Query operations
|
|
96
|
+
- `bfs` / `dfs` — Graph traversal
|
|
97
|
+
- `flush` / `compact` — Persistence operations
|
|
98
|
+
- `compact_with_stats` — Compaction with statistics reporting
|
|
96
99
|
|
|
97
100
|
## Building from source
|
|
98
101
|
|
|
@@ -102,11 +105,71 @@ cargo build --release
|
|
|
102
105
|
|
|
103
106
|
# Run tests
|
|
104
107
|
cargo test
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Performance Benchmarks
|
|
105
111
|
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
RFDB includes Criterion-based benchmarks covering all core graph operations.
|
|
113
|
+
|
|
114
|
+
### Running Locally
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
cd packages/rfdb-server
|
|
118
|
+
|
|
119
|
+
# Run all benchmarks
|
|
120
|
+
cargo bench --bench graph_operations
|
|
121
|
+
|
|
122
|
+
# Run specific benchmark group
|
|
123
|
+
cargo bench --bench graph_operations -- 'add_nodes'
|
|
124
|
+
cargo bench --bench graph_operations -- 'get_node'
|
|
125
|
+
|
|
126
|
+
# Save baseline for future comparison
|
|
127
|
+
cargo bench --bench graph_operations -- --save-baseline my-baseline
|
|
128
|
+
|
|
129
|
+
# Compare against saved baseline
|
|
130
|
+
cargo bench --bench graph_operations -- --baseline my-baseline
|
|
108
131
|
```
|
|
109
132
|
|
|
133
|
+
### Benchmark Coverage (16 groups)
|
|
134
|
+
|
|
135
|
+
| Category | Operations |
|
|
136
|
+
|----------|-----------|
|
|
137
|
+
| **Node write** | add_nodes |
|
|
138
|
+
| **Edge write** | add_edges |
|
|
139
|
+
| **Node read** | get_node, find_by_type, find_by_type (wildcard), find_by_attr |
|
|
140
|
+
| **Edge read** | get_outgoing_edges, get_incoming_edges, neighbors |
|
|
141
|
+
| **Mutation** | delete_node, delete_edge |
|
|
142
|
+
| **Traversal** | bfs, reachability (forward/backward) |
|
|
143
|
+
| **Maintenance** | flush, compact |
|
|
144
|
+
| **Analysis** | reanalysis_cost, compaction |
|
|
145
|
+
|
|
146
|
+
### Additional Tools
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Memory profiling
|
|
150
|
+
cargo run --bin memory_profile
|
|
151
|
+
|
|
152
|
+
# Benchmark report generation
|
|
153
|
+
cargo run --bin bench_report
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### CI Regression Detection
|
|
157
|
+
|
|
158
|
+
Benchmarks run on PRs with the `benchmark` label (comparing PR vs main branch).
|
|
159
|
+
Regressions >20% will fail the workflow.
|
|
160
|
+
|
|
161
|
+
### What to Do If Benchmarks Regress
|
|
162
|
+
|
|
163
|
+
1. **Check if it's noise** — re-run the workflow
|
|
164
|
+
2. **Reproduce locally** — save baselines before/after:
|
|
165
|
+
```bash
|
|
166
|
+
git stash && cargo bench --bench graph_operations -- --save-baseline before
|
|
167
|
+
git stash pop && cargo bench --bench graph_operations -- --save-baseline after
|
|
168
|
+
cargo install critcmp && critcmp before after
|
|
169
|
+
```
|
|
170
|
+
3. **Identify the cause** — `add_nodes` regression = storage overhead; `bfs`/`reachability` = traversal changes
|
|
171
|
+
4. **Fix or justify** — document trade-offs in PR description
|
|
172
|
+
|
|
110
173
|
## License
|
|
111
174
|
|
|
112
175
|
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafema/rfdb",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.6-beta",
|
|
4
|
+
"description": "RFDB (Rega Flow Database) — high-performance disk-backed graph database server for Grafema",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"bin": {
|
|
@@ -9,14 +9,17 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/Disentinel/
|
|
12
|
+
"url": "https://github.com/Disentinel/grafema.git",
|
|
13
|
+
"directory": "packages/rfdb-server"
|
|
13
14
|
},
|
|
14
15
|
"keywords": [
|
|
15
16
|
"graph",
|
|
16
17
|
"database",
|
|
17
18
|
"semantic-analysis",
|
|
18
19
|
"code-analysis",
|
|
19
|
-
"rust"
|
|
20
|
+
"rust",
|
|
21
|
+
"rega-flow",
|
|
22
|
+
"rfdb"
|
|
20
23
|
],
|
|
21
24
|
"author": "Vadim Reshetnikov",
|
|
22
25
|
"license": "Apache-2.0",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|