A cyberpunk-inspired terminal UI for monitoring Minigun pipelines in real-time. Features an htop-like interface with animated flow diagrams and live performance metrics.
GO BRRRRR WITH STYLE 🔥💚⚡
- Features
- Installation
- Quick Start
- Keyboard Controls
- Display Elements
- Example
- Architecture
- API Reference
- Performance
- Troubleshooting
- Future Enhancements
- Real-time monitoring: Live updates of pipeline execution
- Dual-panel layout:
- Left: Animated ASCII flow diagram showing data moving through stages
- Right: Process statistics table with throughput, latency, and resource metrics
- Cyberpunk aesthetic: Matrix/Blade Runner-inspired color scheme with animations
- Keyboard controls: Navigate, pause, and inspect pipeline execution
- Zero dependencies: Pure Ruby with ANSI terminal control
The HUD is included with Minigun. Simply require it:
require 'minigun/hud'Perfect for development and debugging. Run your task in the background, then open HUD:
class MyPipelineTask
include Minigun::DSL
pipeline do
producer :generate { loop { emit(Time.now) } }
processor :process, threads: 4 { |item| emit(transform(item)) }
consumer :save { |item| save_to_db(item) }
end
end
# In IRB or your console:
task = MyPipelineTask.new
task.run(background: true) # Runs in background thread
task.hud # Opens HUD (blocks until you press 'q')
# HUD closed, but task still running!
task.running? # => true
task.hud # Reopen HUD anytime
task.stop # Stop execution when doneUse Minigun::HUD.run_with_hud to automatically run your task with HUD monitoring:
# Run with HUD (blocks until complete or user quits)
Minigun::HUD.run_with_hud(MyPipelineTask)Note: When the pipeline finishes, the HUD stays open to display final statistics. Press q to exit. This allows you to review the final state, throughput metrics, and latency percentiles before closing.
For more control, manually create and manage the HUD controller:
task = MyPipelineTask.new
task.send(:_evaluate_pipeline_blocks!)
pipeline = task.instance_variable_get(:@_minigun_task).root_pipeline
# Start HUD in background thread
hud = Minigun::HUD::Controller.new(pipeline)
hud_thread = Thread.new { hud.start }
# Run your pipeline
task.run
# Stop HUD
hud.stop
hud_thread.join| Key | Action |
|---|---|
q / Q |
Quit HUD (works anytime, including when pipeline finished) |
Space |
Pause/Resume updates (disabled when finished) |
h / H / ? |
Toggle help overlay (disabled when finished) |
r / R |
Force refresh / recalculate layout (disabled when finished) |
↑ / ↓ |
Scroll process list |
w / s |
Pan flow diagram up/down |
a / d |
Pan flow diagram left/right |
c / C |
Compact view (future) |
The left panel shows your pipeline stages as boxes with animated connections. Use w/a/s/d keys to pan the diagram for large pipelines.
┌─────────────────┐
│ ▶ generator ⚡ │
└──── 23.5/s ─────┘
⣿ ← flowing animation
┌─────────────────┐
│ ◆ processor ⚡ │
└──── 23.5/s ─────┘
⣿
┌─────────────────┐
│ ◀ consumer ⏸ │
└─────────────────┘
Box Components:
- Header Line: Top border with stage name
- Content: Icon + Stage Name + Status Indicator
- Footer: Bottom border with throughput rate (when active)
- Colors: Status-based (green=active, yellow=bottleneck, red=error, gray=idle)
Stage Icons:
▶Producer (generates data)◆Processor (transforms data)◀Consumer (consumes data)⊞Accumulator (batches items)◇Router (distributes to multiple stages)⑂Fork (IPC/COW process)
Status Indicators:
⚡Active (currently processing)⏸Idle (waiting for work)⚠Bottleneck (slowest stage)✖Error (failures detected)✓Done (completed)
Connection Animations:
- Active connections show flowing Braille characters:
⠀⠁⠃⠇⠏⠟⠿⡿⣿ - Horizontal lines pulse with dashed patterns:
─╌┄┈ - Inactive connections shown as static gray lines
- Flow direction top-to-bottom through pipeline stages
- Fan-out patterns use proper split/fork characters:
┬ ┼for tree-like visualization
Example Fan-Out Pattern:
┌──────────┐
│ producer │
└──────────┘
│
┬───┴───┬
│ │ │
┌───┘ │ └───┐
┌──────┐┌──────┐┌──────┐
│cons1 ││cons2 ││cons3 │
└──────┘└──────┘└──────┘
The right panel displays a performance table:
| Column | Description |
|---|---|
| STAGE | Stage name with type icon |
| STATUS | Current status indicator |
| ITEMS | Total items processed |
| THRU | Throughput (items/second) |
| P50 | Median latency (50th percentile) |
| P99 | 99th percentile latency |
Color coding:
- Green: High performance / good metrics
- Yellow: Moderate performance / warning
- Red: Poor performance / critical
- Cyan: UI chrome / borders
- Gray: Idle or inactive
Shows:
- Pipeline status: RUNNING, PAUSED, or FINISHED
- Pipeline name: Current pipeline being monitored
- Keyboard hints: Available controls (changes to "Press [q] to exit..." when finished)
See examples/hud_demo.rb for a complete working example:
ruby examples/hud_demo.rbThis demo creates a multi-stage pipeline with varying latencies to demonstrate the HUD's monitoring capabilities.
When using the DSL, tasks have these methods for background execution and monitoring:
Run the task in a background thread. Returns immediately.
Example:
task = MyTask.new
task.run(background: true)
# Task running in background (Thread #12345)
# Use task.hud to open the HUD monitor
# Use task.stop to stop executionOpen HUD monitor for the running pipeline. Blocks until user quits (q).
Can be called multiple times - close and reopen as needed.
Example:
task.hud # Opens HUD
# Press 'q' to close
task.hud # Open againCheck if task is running in background. Returns true or false.
Example:
task.running? # => true
task.stop
task.running? # => falseStop background execution immediately.
Example:
task.stop
# Background task stoppedWait for background task to complete. Blocks until finished.
Example:
task.run(background: true)
task.wait # Blocks until complete
# Background task completedLaunch HUD for a pipeline. Blocks until user quits.
Parameters:
pipeline- AMinigun::Pipelineinstance
Example:
pipeline = task.instance_variable_get(:@_minigun_task).root_pipeline
Minigun::HUD.launch(pipeline)Run a task with HUD monitoring. Automatically manages HUD lifecycle.
Parameters:
task- A task class or instance (must have a pipeline)
Returns: Nothing (blocks until completion or user quits)
Example:
Minigun::HUD.run_with_hud(MyTask)
# or
Minigun::HUD.run_with_hud(MyTask.new)Create a HUD controller for manual management.
Parameters:
pipeline- AMinigun::Pipelineinstanceon_quit- Optional callback lambda called when user quits
Methods:
start()- Start the HUD (blocks)stop()- Stop the HUDrunning- Boolean indicating if HUD is runningpaused- Boolean indicating if HUD is paused
Example:
hud = Minigun::HUD::Controller.new(pipeline)
hud_thread = Thread.new { hud.start }
# Do work...
hud.stop
hud_thread.joinAccess theme colors via Minigun::HUD::Theme:
Theme.primary # Matrix green
Theme.secondary # Cyan
Theme.success # Bright green
Theme.warning # Yellow
Theme.danger # Red
Theme.stage_active # Bold bright green
Theme.stage_idle # GrayTheme.stage_icon(:producer) # ▶
Theme.stage_icon(:processor) # ◆
Theme.stage_icon(:consumer) # ◀
Theme.stage_icon(:accumulator) # ⊞
Theme.stage_icon(:router) # ◇
Theme.stage_icon(:fork) # ⑂
Theme.status_indicator(:active) # ⚡
Theme.status_indicator(:idle) # ⏸
Theme.status_indicator(:bottleneck) # ⚠
Theme.status_indicator(:error) # ✖
Theme.status_indicator(:done) # ✓The HUD is built with modular components under the Minigun::HUD namespace:
lib/minigun/hud/
├── terminal.rb # ANSI terminal control & rendering
├── theme.rb # Cyberpunk color schemes
├── keyboard.rb # Non-blocking input handling
├── flow_diagram.rb # ASCII flow visualization
├── process_list.rb # Statistics table renderer
├── stats_aggregator.rb # Stats collection from pipeline
└── controller.rb # Main orchestrator
- No external dependencies: Uses only Ruby stdlib with ANSI escape sequences
- Double buffering: Prevents screen flicker during updates
- Non-blocking I/O: Keyboard input doesn't interrupt rendering
- Fixed FPS: Updates at 15 FPS for smooth animations
- Thread-safe: Safe to run HUD in parallel with pipeline execution
- CPU overhead: ~1-2% for HUD rendering thread
- Memory overhead: Minimal (~1MB for stats buffering)
- Refresh rate: 15 FPS (configurable in
Controller::FPS) - Stats sampling: Uses reservoir sampling for latency tracking
The HUD is designed to be extensible. Planned features:
- IPC stats transmission: Real-time stats from forked child processes
- Detailed view mode: Expanded per-stage metrics
- Compact view mode: More stages on screen
- Multiple pipelines: Monitor multiple pipelines simultaneously
- Historical graphs: Throughput/latency over time
- Export stats: Save performance data to file
- Custom themes: User-configurable color schemes
- Stage filtering: Show/hide specific stages
- Alert thresholds: Configurable warnings for bottlenecks
The HUD requires a terminal (TTY). If running in CI or piped contexts, the HUD will detect this and gracefully degrade.
Ensure your terminal supports ANSI escape sequences and UTF-8:
export TERM=xterm-256color
export LANG=en_US.UTF-8If the HUD causes performance issues:
- Reduce FPS: Edit
Controller::FPSconstant - Simplify animations: Disable flow animations in
FlowDiagram - Skip HUD entirely for production: Only use in development
The HUD is part of Minigun's core. Contributions welcome:
- New visualization modes
- Additional metrics (CPU, memory per stage)
- Export/logging capabilities
- Theme customization
- Improved layouts for complex pipelines
Same as Minigun (MIT License)
GO BRRRRR WITH STYLE 🔥
