raptiye 0.1.0
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 +171 -0
- package/bench/bench-batch-curve.js +121 -0
- package/bench/bench-event-loop.js +91 -0
- package/bench/bench-failover.js +172 -0
- package/bench/bench-memory.js +107 -0
- package/bench/bench-partition.js +134 -0
- package/bench/bench-pipeline.js +94 -0
- package/bench/bench-recovery.js +134 -0
- package/bench/bench-replication.js +107 -0
- package/bench/bench-single-node.js +77 -0
- package/bench/bench-slow-follower.js +96 -0
- package/bench/harness.js +87 -0
- package/bench/run-all.js +83 -0
- package/bench-results.json +598 -0
- package/index.js +30 -0
- package/package.json +24 -0
- package/src/core/engine.js +907 -0
- package/src/core/invariants.js +146 -0
- package/src/node/raptiye.js +296 -0
- package/src/node/stats.js +82 -0
- package/src/protocol/checksum.js +66 -0
- package/src/protocol/wire.js +551 -0
- package/src/replication/pipeline.js +235 -0
- package/src/sim/cluster.js +316 -0
- package/src/sim/prng.js +52 -0
- package/src/sim/virtual-clock.js +82 -0
- package/src/storage/file-log.js +394 -0
- package/src/storage/interface.js +113 -0
- package/src/storage/memory-log.js +183 -0
- package/src/transport/interface.js +47 -0
- package/src/transport/memory-transport.js +67 -0
- package/src/transport/tcp-transport.js +200 -0
- package/src/types.js +87 -0
- package/test/chaos/chaos.test.js +112 -0
- package/test/integration/cluster.test.js +192 -0
- package/test/integration/node.test.js +78 -0
- package/test/integration/replication-pipeline.test.js +45 -0
- package/test/unit/core.test.js +163 -0
- package/test/unit/protocol.test.js +181 -0
- package/test/unit/storage.test.js +127 -0
- package/test/unit/transport.test.js +90 -0
package/bench/harness.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Benchmark harness for Raptiye.
|
|
3
|
+
* Collects system environment metadata, high-resolution timing,
|
|
4
|
+
* percentiles (p50, p90, p95, p99, max), throughput, and memory stats.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import os from 'node:os';
|
|
8
|
+
import { execSync } from 'node:child_process';
|
|
9
|
+
|
|
10
|
+
export function getEnvironmentMetadata() {
|
|
11
|
+
let gitCommit = 'unknown';
|
|
12
|
+
try {
|
|
13
|
+
gitCommit = execSync('git rev-parse --short HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
|
|
14
|
+
} catch {}
|
|
15
|
+
|
|
16
|
+
const cpus = os.cpus();
|
|
17
|
+
return {
|
|
18
|
+
nodeVersion: process.version,
|
|
19
|
+
os: os.type(),
|
|
20
|
+
platform: os.platform(),
|
|
21
|
+
release: os.release(),
|
|
22
|
+
arch: process.arch,
|
|
23
|
+
cpuModel: cpus.length > 0 ? cpus[0].model : 'unknown',
|
|
24
|
+
cpuCores: cpus.length,
|
|
25
|
+
totalMemoryMB: Math.round(os.totalmem() / (1024 * 1024)),
|
|
26
|
+
date: new Date().toISOString(),
|
|
27
|
+
gitCommit
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class LatencyHistogram {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.samples = [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
record(latencyMs) {
|
|
37
|
+
this.samples.push(latencyMs);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
percentile(p) {
|
|
41
|
+
if (this.samples.length === 0) return 0;
|
|
42
|
+
const sorted = this.samples.slice().sort((a, b) => a - b);
|
|
43
|
+
const index = Math.min(sorted.length - 1, Math.floor((p / 100) * sorted.length));
|
|
44
|
+
return sorted[index];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
summary() {
|
|
48
|
+
if (this.samples.length === 0) {
|
|
49
|
+
return { p50: 0, p90: 0, p95: 0, p99: 0, max: 0, mean: 0 };
|
|
50
|
+
}
|
|
51
|
+
const sorted = this.samples.slice().sort((a, b) => a - b);
|
|
52
|
+
const count = sorted.length;
|
|
53
|
+
let sum = 0;
|
|
54
|
+
for (let i = 0; i < count; i++) sum += sorted[i];
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
p50: sorted[Math.floor(0.50 * count)],
|
|
58
|
+
p90: sorted[Math.floor(0.90 * count)],
|
|
59
|
+
p95: sorted[Math.floor(0.95 * count)],
|
|
60
|
+
p99: sorted[Math.min(count - 1, Math.floor(0.99 * count))],
|
|
61
|
+
max: sorted[count - 1],
|
|
62
|
+
mean: sum / count
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function formatTable(title, headers, rows) {
|
|
68
|
+
console.log(`\n=== ${title} ===`);
|
|
69
|
+
const colWidths = headers.map((h, i) => {
|
|
70
|
+
let max = h.length;
|
|
71
|
+
for (const r of rows) {
|
|
72
|
+
const valStr = String(r[i] !== undefined ? r[i] : '');
|
|
73
|
+
if (valStr.length > max) max = valStr.length;
|
|
74
|
+
}
|
|
75
|
+
return max + 2;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const headerLine = headers.map((h, i) => h.padEnd(colWidths[i])).join(' | ');
|
|
79
|
+
const sepLine = colWidths.map(w => '-'.repeat(w)).join('-+-');
|
|
80
|
+
console.log(headerLine);
|
|
81
|
+
console.log(sepLine);
|
|
82
|
+
|
|
83
|
+
for (const r of rows) {
|
|
84
|
+
const line = r.map((c, i) => String(c).padEnd(colWidths[i])).join(' | ');
|
|
85
|
+
console.log(line);
|
|
86
|
+
}
|
|
87
|
+
}
|
package/bench/run-all.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Master benchmark runner for Raptiye.
|
|
3
|
+
* Runs the full suite of 9 benchmarks and outputs machine-readable JSON + console summaries.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { getEnvironmentMetadata, formatTable } from './harness.js';
|
|
9
|
+
import { runSingleNodeBenchmark } from './bench-single-node.js';
|
|
10
|
+
import { runReplicationBenchmark } from './bench-replication.js';
|
|
11
|
+
import { runBatchCurveBenchmark } from './bench-batch-curve.js';
|
|
12
|
+
import { runPipelineBenchmark } from './bench-pipeline.js';
|
|
13
|
+
import { runSlowFollowerBenchmark } from './bench-slow-follower.js';
|
|
14
|
+
import { runFailoverBenchmark } from './bench-failover.js';
|
|
15
|
+
import { runPartitionBenchmark } from './bench-partition.js';
|
|
16
|
+
import { runRecoveryBenchmark } from './bench-recovery.js';
|
|
17
|
+
import { runEventLoopBenchmark } from './bench-event-loop.js';
|
|
18
|
+
import { runMemorySoakBenchmark } from './bench-memory.js';
|
|
19
|
+
|
|
20
|
+
async function main() {
|
|
21
|
+
console.log('===============================================================');
|
|
22
|
+
console.log(' RAPTIYE COMPREHENSIVE BENCHMARK SUITE ');
|
|
23
|
+
console.log('===============================================================');
|
|
24
|
+
|
|
25
|
+
const env = getEnvironmentMetadata();
|
|
26
|
+
console.log(`Environment: Node ${env.nodeVersion} on ${env.platform} ${env.arch} (${env.cpuModel}, ${env.cpuCores} cores, ${env.totalMemoryMB} MB RAM)`);
|
|
27
|
+
console.log(`Timestamp: ${env.date}`);
|
|
28
|
+
console.log(`Git Commit: ${env.gitCommit}\n`);
|
|
29
|
+
|
|
30
|
+
const results = {
|
|
31
|
+
environment: env,
|
|
32
|
+
startedAt: env.date,
|
|
33
|
+
benchmarks: {}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
results.benchmarks.singleNode = await runSingleNodeBenchmark();
|
|
38
|
+
results.benchmarks.replication = await runReplicationBenchmark();
|
|
39
|
+
results.benchmarks.batchCurve = await runBatchCurveBenchmark();
|
|
40
|
+
results.benchmarks.pipeline = await runPipelineBenchmark();
|
|
41
|
+
results.benchmarks.slowFollower = await runSlowFollowerBenchmark();
|
|
42
|
+
results.benchmarks.failover = await runFailoverBenchmark(50);
|
|
43
|
+
results.benchmarks.partition = await runPartitionBenchmark();
|
|
44
|
+
results.benchmarks.recovery = await runRecoveryBenchmark();
|
|
45
|
+
results.benchmarks.eventLoop = await runEventLoopBenchmark();
|
|
46
|
+
results.benchmarks.memorySoak = await runMemorySoakBenchmark();
|
|
47
|
+
|
|
48
|
+
results.completedAt = new Date().toISOString();
|
|
49
|
+
|
|
50
|
+
const outputPath = path.join(process.cwd(), 'bench-results.json');
|
|
51
|
+
fs.writeFileSync(outputPath, JSON.stringify(results, null, 2));
|
|
52
|
+
|
|
53
|
+
console.log('\n===============================================================');
|
|
54
|
+
console.log(' BENCHMARK SUITE COMPLETE ');
|
|
55
|
+
console.log('===============================================================');
|
|
56
|
+
console.log(`Machine-readable JSON output saved to: ${outputPath}`);
|
|
57
|
+
|
|
58
|
+
// Master Dashboard summary
|
|
59
|
+
formatTable('RAPTIYE CORE PERFORMANCE DASHBOARD',
|
|
60
|
+
['Benchmark Metric', 'Value', 'Assessment'],
|
|
61
|
+
[
|
|
62
|
+
['Single-Node Overhead', `${results.benchmarks.singleNode.opsPerSec.toLocaleString()} ops/sec (${results.benchmarks.singleNode.nsPerOp} ns/op)`, 'Ultra Low Core Overhead'],
|
|
63
|
+
['3-Node Replication (64B)', `${results.benchmarks.replication.results[1].opsPerSec.toLocaleString()} cmd/sec (${results.benchmarks.replication.results[1].mbPerSec} MB/s)`, 'Fast Quorum Throughput'],
|
|
64
|
+
['Commit Latency p50 (64B)', `${results.benchmarks.replication.results[1].commitP50Ms} ms`, 'Sub-Millisecond Quorum'],
|
|
65
|
+
['Commit Latency p99 (64B)', `${results.benchmarks.replication.results[1].commitP99Ms} ms`, 'Deterministic Latency'],
|
|
66
|
+
['Payload Copies / Byte', `${results.benchmarks.replication.results[1].copiesPerByte.toFixed(2)} copies`, 'Zero-Copy Scatter/Gather'],
|
|
67
|
+
['Headline Failover (T7-T0 p50)', `${results.benchmarks.failover.metrics.totalWriteUnavailability.p50} ms`, 'Fast Automatic Failover'],
|
|
68
|
+
['Headline Failover (T7-T0 p99)', `${results.benchmarks.failover.metrics.totalWriteUnavailability.p99} ms`, 'Predictable Recovery'],
|
|
69
|
+
['Slow Follower Isolation', `${results.benchmarks.slowFollower.quorumOpsPerSec.toLocaleString()} ops/sec (Slow RTT 200ms)`, 'Quorum Unblocked'],
|
|
70
|
+
['Split-Brain Prevention', results.benchmarks.partition.scenarios[0].passed ? 'VERIFIED (100% Invariants)' : 'FAILED', 'Split-Brain Proof'],
|
|
71
|
+
['Follower Catch-up (100K)', `${results.benchmarks.recovery.results[1].entriesPerSec.toLocaleString()} entries/s (${results.benchmarks.recovery.results[1].timeToReadyMs} ms)`, 'High-Speed Catch-up'],
|
|
72
|
+
['Event-Loop Lag p99', `${results.benchmarks.eventLoop.eventLoopLagMs.p99} ms`, 'Responsive Node Runtime'],
|
|
73
|
+
['Memory Plateau (50K Soak)', `${results.benchmarks.memorySoak.finalHeapMB} MB Heap`, 'Bounded Memory Plateau']
|
|
74
|
+
]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.error('Error during benchmark execution:', err);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main();
|