Repository navigation
Description
Problem Statement
PR #37 added live graph benchmarking (/benchmark-live, SSE streaming of per-second samples, one-click index optimization), but it currently behaves like a standalone demo rather than a part of the application:
- Demo-only. The page and the
/api/demo/*endpoints are served only withDEMO_MODE=trueand alive_demosection. Scenarios, graph topology and the "suggested index" are hand-written configuration. A user with their ownperformance.benchmarks.custom_queriescannot run them from the UI. - Not connected to the transformed graph. The live graph nodes come from
live_demo.topology, not from the Neo4j graph or the transformation rules. The main visualization (/) has a performance overlay (/api/performance/data/graph,visualization.js) that matches Neo4j node ids to table-derived ids heuristically, and benchmark samples never reach it. - Two parallel performance-graph models and transports.
GraphPerformanceMapper/RealtimePerformanceMonitor(WebSocket/ws/performance, based on Performance Schema) andports.LiveSample/LiveGraph(SSE) describe the same thing (table heat, edge latency and load) twice. - Simulated metrics.
bootstrap.InitAllalways startsSimpleMetricsInjectorwithSimulationMode: true, which writes fake metrics into Neo4j relationships, while real measured data now exists. - No history. Samples are kept in an in-memory ring buffer per run and are lost on restart. Results are persisted by
FileBenchmarkResultStore, but the UI keeps only Run A/B in memory, so past runs cannot be reopened or compared after a reload. - Suggestions are not connected. "Apply suggested index" is a static configuration entry, while
PerformanceAnalyzeralready produces index suggestions. - sysbench does not stream, although
SysbenchDefaults.ReportIntervalexists in the configuration model and is unused. - MySQL-only pieces. The index state check (
indexExistsininternal/interfaces/api/demo_handlers.go) readsinformation_schema.statistics.
Proposed Solution
Integrate in phases, each shippable on its own:
- Generic mode (no
DEMO_MODE). AddGET /api/performance/benchmarks/query-setsand let/benchmark-livepick any configured custom query set. Derive the topology from the querytablesand schema discovery (foreign keys, as used byanalyze/transformation rules), keepinglive_demo.topologyonly as an override. The index apply/revert endpoints stayDEMO_MODE-only. - One model, one id convention, shared UI. Unify on a single performance-graph model (map
LiveGraphontoPerformanceEnhancedGraph/PerformanceGraphData, or the reverse) with ids that match the Neo4j nodes. Optionally publish live samples on abenchmarktopic of/ws/performance. Extract the D3 graph renderer frombenchmark-live.jsinto a shared module used by/benchmark-live,/performanceand the main visualization. - Live overlay on the main graph. Add a "Live benchmark" toggle to
/that colours the real Neo4j nodes and relationships with live heat, mapping table names to nodes throughsource_tableof the transformation rules. - Persistence and history. Persist samples together with results, serve
GET .../{id}/samplesfrom the store after a restart, and add a run history list with reopen and a compare picker to the UI. Align with the snapshot work in 📸 Performance Graph Snapshot System #17 / Performance Graph Snapshot System #20. - Analyzer-driven suggestions. Build the suggested optimization from
PerformanceAnalyzerindex suggestions instead of static configuration, keeping theCREATE INDEX/DROP INDEXallowlist and theDEMO_MODEguard. Replace the simulatedSimpleMetricsInjectordata with real data, or remove it. - Tool and database coverage. Stream sysbench runs through
--report-intervalinto the same live view, and make the index inspection database-agnostic (for examplepg_indexesfor PostgreSQL).
Alternative Solutions
Keep live benchmarking as a documented demo feature. This is cheaper, but it leaves the original goal of #12 (benchmark integration with graph load visualization) unmet and keeps the duplicated models and transports.
Use Case
A user transforms their MySQL schema to Neo4j, opens the graph, runs their own query set and sees live heat on the same nodes they are already exploring, then reopens last week's run to compare it with today's.
Priority Level
Important
Implementation Ideas
- Keep handlers thin and the model in
internal/application/ports, in line with the existing DDD layers; the id mapping can reuseSourceConfig.SourceTablefrominternal/domain/models. - Align the
live_demosection with the configuration consolidation in Configuration Consolidation and Standardization #23. - Split into one sub-issue per phase once scope and order are agreed.
- Tests: golden tests for the id mapping, SSE/WebSocket integration tests, and a browser test of the overlay toggle.
Additional Context
Related: #12, #17, #20, #21 (Grafana Plugin and Monitoring Systems Integration, could reuse the unified model), #23. Companion issue: #38 (headless bench CLI). Needs discussion on scope and order before implementation.
Activity