-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
133 lines (108 loc) · 3.43 KB
/
Copy pathjustfile
File metadata and controls
133 lines (108 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# SWIM Gossip Protocol - Justfile
# Default recipe: show available commands
default:
@just --list
# Build the project
build:
cargo build
# Build release version
release:
cargo build --release
# Run a single node (usage: just run 127.0.0.1:9000 [seed_addr])
run addr *seeds:
RUST_LOG=info cargo run -- {{addr}} {{seeds}}
# Run the seed node on port 9000
node1:
RUST_LOG=info cargo run -- 127.0.0.1:9000
# Run node 2, joining seed
node2:
RUST_LOG=info cargo run -- 127.0.0.1:9001 127.0.0.1:9000
# Run node 3, joining seed
node3:
RUST_LOG=info cargo run -- 127.0.0.1:9002 127.0.0.1:9000
# Run node 4, joining seed
node4:
RUST_LOG=info cargo run -- 127.0.0.1:9003 127.0.0.1:9000
# Run the interactive cluster test script
cluster:
./test_cluster.sh
# Run tests
test:
cargo test
# Check code without building
check:
cargo check
# Format code
fmt:
cargo fmt
# Run clippy linter
lint:
cargo clippy
# Clean build artifacts
clean:
cargo clean
# Watch for changes and rebuild
watch:
cargo watch -x build
# Show demo instructions
demo:
@echo "=== SWIM Gossip Protocol Demo ==="
@echo ""
@echo "Open 4 terminals and run:"
@echo " Terminal 1: just node1"
@echo " Terminal 2: just node2"
@echo " Terminal 3: just node3"
@echo " Terminal 4: just node4"
@echo ""
@echo "Or run the interactive cluster:"
@echo " just cluster"
@echo ""
@echo "Then try killing a node with Ctrl+C"
@echo "and watch the others detect the failure!"
# ============ Benchmarking & Profiling ============
# Run benchmark (30 seconds by default)
bench duration="30":
cd bench && DURATION={{duration}} ./benchmark.sh
# Trace syscalls with strace (shows epoll_wait, sendto, recvfrom)
trace-syscalls addr seed="":
cd bench && ./trace_syscalls.sh {{addr}} {{seed}}
# Analyze strace output
analyze-trace file:
cd bench && python3 analyze_trace.py {{file}}
# Profile with perf (record mode)
perf-record addr seed="":
cd bench && ./perf_profile.sh record {{addr}} {{seed}}
# Profile with perf (stat mode - real-time stats)
perf-stat addr seed="":
cd bench && ./perf_profile.sh stat {{addr}} {{seed}}
# Generate flamegraph
flamegraph addr seed="":
cd bench && ./perf_profile.sh flamegraph {{addr}} {{seed}}
# Visualize latency from log files
visualize *files:
cd bench && python3 visualize_latency.py {{files}}
# Show benchmarking help
bench-help:
@echo "=== SWIM Benchmarking & Profiling ==="
@echo ""
@echo "Quick benchmark:"
@echo " just bench # Run 30s benchmark with 4 nodes"
@echo " just bench 60 # Run 60s benchmark"
@echo ""
@echo "Syscall tracing (shows epoll efficiency):"
@echo " just trace-syscalls 127.0.0.1:9000"
@echo " just trace-syscalls 127.0.0.1:9001 127.0.0.1:9000"
@echo " just analyze-trace bench/traces/syscalls_9000_*.log"
@echo ""
@echo "CPU profiling:"
@echo " just perf-stat 127.0.0.1:9000 # Real-time CPU stats"
@echo " just perf-record 127.0.0.1:9000 # Record profile"
@echo " just flamegraph 127.0.0.1:9000 # Generate flamegraph"
@echo ""
@echo "Latency visualization:"
@echo " just visualize bench/results/*.log"
@echo ""
@echo "What to look for:"
@echo " - epoll_wait with long waits = efficient (no busy polling)"
@echo " - Low RTT variance = consistent performance"
@echo " - sendto/recvfrom < 10µs = fast syscalls"