GroveEngine/tests/benchmarks/plans/01_topictree.md
StillHammer 063549bf17 feat: Add comprehensive benchmark suite for GroveEngine performance validation
Add complete benchmark infrastructure with 4 benchmark categories:

**Benchmark Helpers (00_helpers.md)**
- BenchmarkTimer.h: High-resolution timing with std::chrono
- BenchmarkStats.h: Statistical analysis (mean, median, p95, p99, stddev)
- BenchmarkReporter.h: Professional formatted output
- benchmark_helpers_demo.cpp: Validation suite

**TopicTree Routing (01_topictree.md)**
- Scalability validation: O(k) complexity confirmed
- vs Naive comparison: 101x speedup achieved
- Depth impact: Linear growth with topic depth
- Wildcard overhead: <12% performance impact
- Sub-microsecond routing latency

**IntraIO Batching (02_batching.md)**
- Baseline: 34,156 msg/s without batching
- Batching efficiency: Massive message reduction
- Flush thread overhead: Minimal CPU usage
- Scalability with low-freq subscribers validated

**DataNode Read-Only API (03_readonly.md)**
- Zero-copy speedup: 2x faster than getChild()
- Concurrent reads: 23.5M reads/s with 8 threads (+458%)
- Thread scalability: Near-linear scaling confirmed
- Deep navigation: 0.005µs per level

**End-to-End Real World (04_e2e.md)**
- Game loop simulation: 1000 msg/s stable, 100 modules
- Hot-reload under load: Overhead measurement
- Memory footprint: Linux /proc/self/status based

Results demonstrate production-ready performance:
- 100x routing speedup vs linear search
- Sub-microsecond message routing
- Millions of concurrent reads per second
- Stable throughput under realistic game loads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 16:08:10 +08:00

114 lines
2.7 KiB
Markdown

# Plan: TopicTree Routing Benchmarks
## Objectif
Prouver que le routing est **O(k)** et mesurer le speedup vs approche naïve.
---
## Benchmark A: Scalabilité avec nombre de subscribers
**Test**: Temps de routing constant malgré augmentation du nombre de subs.
**Setup**:
- Topic fixe: `"player:123:damage"` (k=3)
- Créer N subscribers avec patterns variés
- Mesurer `findSubscribers()` pour 10k routes
**Mesures**:
| Subscribers | Temps moyen (µs) | Variation |
|-------------|------------------|-----------|
| 10 | ? | baseline |
| 100 | ? | < 10% |
| 1000 | ? | < 10% |
| 10000 | ? | < 10% |
**Succès**: Variation < 10% O(k) confirmé
---
## Benchmark B: Comparaison TopicTree vs Naïve
**Test**: Speedup par rapport à linear search.
**Setup**:
- Implémenter version naïve: loop sur tous subs, match chacun
- 1000 subscribers
- 10000 routes
**Mesures**:
- TopicTree: temps total
- Naïve: temps total
- Speedup: ratio (attendu >10x)
**Succès**: Speedup > 10x
---
## Benchmark C: Impact de la profondeur (k)
**Test**: Temps croît linéairement avec profondeur du topic.
**Setup**:
- Topics de profondeur variable
- 100 subscribers
- 10000 routes par profondeur
**Mesures**:
| Profondeur k | Topic exemple | Temps (µs) |
|--------------|---------------------|------------|
| 2 | `a:b` | ? |
| 5 | `a:b:c:d:e` | ? |
| 10 | `a:b:c:...:j` | ? |
**Graphe**: Temps = f(k) → droite linéaire
**Succès**: Croissance linéaire avec k
---
## Benchmark D: Wildcards complexes
**Test**: Performance selon type de wildcard.
**Setup**:
- 100 subscribers
- Patterns variés
- 10000 routes
**Mesures**:
| Pattern | Exemple | Temps (µs) |
|-----------------|-----------|------------|
| Exact | `a:b:c` | ? |
| Single wildcard | `a:*:c` | ? |
| Multi wildcard | `a:.*` | ? |
| Multiple | `*:*:*` | ? |
**Succès**: Wildcards < 2x overhead vs exact match
---
## Implémentation
**Fichier**: `benchmark_topictree.cpp`
**Dépendances**:
- `topictree::topictree` (external)
- Helpers: Timer, Stats, Reporter
**Structure**:
```cpp
void benchmarkA_scalability();
void benchmarkB_naive_comparison();
void benchmarkC_depth_impact();
void benchmarkD_wildcards();
int main() {
benchmarkA_scalability();
benchmarkB_naive_comparison();
benchmarkC_depth_impact();
benchmarkD_wildcards();
}
```
**Output attendu**: 4 sections avec headers, tableaux de résultats, verdicts ✅/❌