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
//! Memory Profiling Module for TrustformeRS Models
//!
//! This module provides comprehensive memory profiling and analysis capabilities for
//! transformer models. It includes real-time monitoring, alerts, and detailed
//! memory analysis tools.
//!
//! # Features
//!
//! - Real-time memory usage tracking
//! - Memory leak detection with advanced heuristics
//! - Allocation pattern analysis
//! - Peak memory analysis
//! - Memory fragmentation monitoring
//! - Historical data tracking with adaptive thresholds
//! - Automated alerts and recommendations
//! - Predictive memory usage analysis
//! - HTML and JSON report generation
//!
//! # Example
//!
//! ```rust
//! use trustformers_models::memory_profiling::{MemoryProfiler, ProfilerConfig};
//!
//! # tokio_test::block_on(async {
//! // Create and start the profiler
//! let config = ProfilerConfig::default();
//! let mut profiler = MemoryProfiler::new(config)?;
//!
//! // Start monitoring
//! profiler.start_monitoring().await?;
//!
//! // ... run your model training/inference ...
//!
//! // Generate comprehensive report
//! let report = profiler.generate_report().await?;
//! profiler.save_report(&report).await?;
//!
//! // Get analytics summary
//! let analytics = profiler.get_analytics_summary().await?;
//! println!("Memory efficiency: {:.1}%",
//! report.summary.memory_efficiency_score * 100.0);
//! # Ok::<(), anyhow::Error>(())
//! # });
//! ```
//!
//! # Module Organization
//!
//! - [`types`] - Core data structures and configurations
//! - [`analytics`] - Advanced analytics components (adaptive thresholds, leak detection, prediction)
//! - [`profiler`] - Main memory profiler implementation
//! - [`system`] - System-level memory collection utilities
//! - [`reporting`] - Report generation and HTML formatting
//! - `tests` - Comprehensive test suite
// Public modules
// Internal modules
// Re-export main types for convenience
pub use ;
pub use ;
pub use ;
pub use MemorySummary;