analyzer module provides advanced pattern detection and performance insights from profiling data.
Classes
MemoryPattern
Represents a detected memory usage pattern.Attributes
Type of pattern: ‘memory_leak’, ‘fragmentation’, ‘inefficient_allocation’, ‘memory_spikes’, ‘repeated_allocations’
Human-readable description of the pattern
Severity level: ‘info’, ‘warning’, ‘critical’
List of function names affected by this pattern
Quantitative metrics about the pattern
Actionable suggestions to address the issue
PerformanceInsight
Performance insight derived from profiling data.Attributes
Insight category: ‘execution_time’, ‘memory_efficiency’, ‘correlation’, ‘temporal’
Insight title
Detailed description
Impact level: ‘low’, ‘medium’, ‘high’
Confidence score from 0.0 to 1.0
Supporting data for the insight
Recommended actions
MemoryAnalyzer
Advanced analyzer for memory profiling data.Constructor
GPUMemoryProfiler instance to analyze
Methods
analyze_memory_patterns()
Detect memory usage patterns in profiling data.List of ProfileResults to analyze (uses profiler.results if None)
Detected memory patterns including:
- Memory leaks
- Fragmentation issues
- Inefficient allocations
- Memory spikes
- Repeated allocations
generate_performance_insights()
Generate performance insights from profiling data.List of ProfileResults to analyze
Performance insights including:
- Slow function detection
- Execution time variance analysis
- Memory-intensive functions
- Time-memory correlations
- Memory growth trends
analyze_memory_gaps()
Classify allocator-vs-device hidden memory gaps over time.Chronologically ordered telemetry samples
Prioritized list of gap findings (by severity and confidence)
generate_optimization_report()
Generate a comprehensive optimization report.List of ProfileResults to analyze
Optional telemetry events for gap analysis
Comprehensive report including:
summary: Overall statisticscritical_issues: Critical memory patternshigh_impact_insights: High-impact performance insightsall_patterns: All detected patternsall_insights: All generated insightsrecommendations: Prioritized recommendationsoptimization_score: Score, grade, and descriptiongap_analysis: Hidden-memory gap findings (when events provided)
Configuration
Analysis thresholds can be customized:memory_leak_ratio: Memory growth indicating potential leak (default: 0.1)fragmentation_ratio: Fragmentation concern threshold (default: 0.3)inefficient_allocation_ratio: Allocation waste threshold (default: 0.5)slow_function_percentile: Top percentile for slow functions (default: 0.9)high_memory_percentile: Top percentile for memory-heavy (default: 0.9)min_calls_for_analysis: Minimum calls to analyze (default: 3)gap_ratio_threshold: Gap size threshold (default: 0.05)gap_spike_zscore: Z-score for spike detection (default: 2.0)gap_drift_r_squared: R-squared for drift (default: 0.6)gap_fragmentation_ratio: Reserved-allocated ratio (default: 0.3)