A comprehensive Rust library for analyzing system capabilities, workload requirements, and optimal resource allocation. This crate provides tools for determining if a system can run specific workloads, scoring hardware capabilities, and recommending optimal configurations with a focus on AI/ML workloads.
- π Comprehensive System Analysis: Detailed hardware capability assessment including CPU, GPU, memory, storage, and network
- π€ AI/ML Specialization: Built-in support for AI inference and training workloads with model parameter analysis
- βοΈ Workload Modeling: Flexible framework for defining workload requirements and characteristics
- β Compatibility Checking: Determine if a system can run specific workloads with detailed compatibility scoring
- π Resource Utilization Prediction: Estimate resource usage patterns for workloads
- π΄ Bottleneck Detection: Identify system bottlenecks and performance limitations
- β¬οΈ Upgrade Recommendations: Suggest specific hardware upgrades for better performance
- βοΈ Optimal Configuration: Find the best hardware configuration for specific workloads
- π Cross-Platform Support: Works on Windows, Linux, and macOS
- πββοΈ Performance Benchmarking: Built-in benchmarking tools for capability validation
- π Trend Analysis: Track performance trends over time
Add this to your Cargo.toml:
[dependencies]
system-analysis = "0.1.0"
tokio = { version = "1.0", features = ["full"] }use system_analysis::SystemAnalyzer;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut analyzer = SystemAnalyzer::new();
let system_profile = analyzer.analyze_system().await?;
println!("System Overall Score: {}/10", system_profile.overall_score());
println!("CPU Score: {}/10", system_profile.cpu_score());
println!("GPU Score: {}/10", system_profile.gpu_score());
println!("Memory Score: {}/10", system_profile.memory_score());
Ok(())
}use system_analysis::{SystemAnalyzer, WorkloadRequirements};
use system_analysis::workloads::{AIInferenceWorkload, ModelParameters};
use system_analysis::resources::{ResourceRequirement, ResourceType, CapabilityLevel};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut analyzer = SystemAnalyzer::new();
let system_profile = analyzer.analyze_system().await?;
// Define an AI model workload
let model_params = ModelParameters::new()
.parameters(7_000_000_000) // 7B parameter model
.memory_required(16.0) // 16GB memory requirement
.compute_required(6.0) // High compute requirement
.prefer_gpu(true); // Prefer GPU acceleration
let ai_workload = AIInferenceWorkload::new(model_params);
let mut workload_requirements = WorkloadRequirements::new("llama2-7b-inference");
workload_requirements.add_resource_requirement(
ResourceRequirement::new(ResourceType::Memory)
.minimum_gb(16.0)
.recommended_gb(24.0)
);
workload_requirements.set_workload(Box::new(ai_workload));
// Check compatibility
let compatibility = analyzer.check_compatibility(&system_profile, &workload_requirements)?;
if compatibility.is_compatible() {
println!("β System can run the AI model!");
println!("Performance estimate: {}", compatibility.performance_estimate());
} else {
println!("β System cannot run the AI model");
for missing in compatibility.missing_requirements() {
println!("Missing: {}", missing.resource_type());
}
}
Ok(())
}The SystemProfile represents a comprehensive analysis of system capabilities:
let system_profile = analyzer.analyze_system().await?;
// Access individual scores
println!("CPU Score: {}", system_profile.cpu_score());
println!("GPU Score: {}", system_profile.gpu_score());
println!("Memory Score: {}", system_profile.memory_score());
// Get AI capabilities assessment
let ai_capabilities = system_profile.ai_capabilities();
println!("AI Inference Level: {}", ai_capabilities.inference_level());Define what your workload needs to run effectively:
let mut requirements = WorkloadRequirements::new("my-workload");
// Add resource requirements
requirements.add_resource_requirement(
ResourceRequirement::new(ResourceType::Memory)
.minimum_gb(8.0)
.recommended_gb(16.0)
.critical()
);
requirements.add_resource_requirement(
ResourceRequirement::new(ResourceType::GPU)
.minimum_level(CapabilityLevel::High)
.preferred_vendor(Some("NVIDIA"))
);Check if a system can run your workload:
let compatibility = analyzer.check_compatibility(&system_profile, &requirements)?;
println!("Compatible: {}", compatibility.is_compatible());
println!("Score: {}/10", compatibility.score());
println!("Performance: {}", compatibility.performance_estimate());
// Get missing requirements
for missing in compatibility.missing_requirements() {
println!("Need {} {}, have {}",
missing.resource_type(),
missing.required(),
missing.available()
);
}Estimate how your workload will use system resources:
let utilization = analyzer.predict_utilization(&system_profile, &requirements)?;
println!("Expected CPU usage: {}%", utilization.cpu_percent());
println!("Expected GPU usage: {}%", utilization.gpu_percent());
println!("Expected memory usage: {}%", utilization.memory_percent());Get specific recommendations for improving system performance:
let upgrades = analyzer.recommend_upgrades(&system_profile, &requirements)?;
for upgrade in upgrades {
println!("Upgrade {}: {}",
upgrade.resource_type(),
upgrade.recommendation()
);
println!("Expected improvement: {}", upgrade.estimated_improvement());
}Implement the Workload trait for custom workload types:
use system_analysis::workloads::{Workload, WorkloadType, PerformanceCharacteristics};
struct CustomWorkload {
// Your workload parameters
}
impl Workload for CustomWorkload {
fn workload_type(&self) -> WorkloadType {
WorkloadType::Custom("my-workload".to_string())
}
fn resource_requirements(&self) -> Vec<ResourceRequirement> {
// Define your resource requirements
vec![]
}
fn estimated_utilization(&self) -> HashMap<ResourceType, f64> {
// Define expected resource utilization
HashMap::new()
}
// ... implement other required methods
}Enable GPU detection for NVIDIA GPUs:
[dependencies]
system-analysis = { version = "0.1.0", features = ["gpu-detection"] }Run performance benchmarks to validate system capabilities:
use system_analysis::utils::BenchmarkRunner;
use std::time::Duration;
let benchmark = BenchmarkRunner::new(Duration::from_secs(5), 100);
let cpu_result = benchmark.run_cpu_benchmark()?;
let memory_result = benchmark.run_memory_benchmark()?;
println!("CPU Benchmark Score: {}", cpu_result.score);
println!("Memory Benchmark Score: {}", memory_result.score);The examples/ directory contains comprehensive examples:
basic_analysis.rs: Basic system analysis and workload compatibilityai_workload_analysis.rs: AI/ML workload analysis with multiple models
Run examples with:
cargo run --example basic_analysis
cargo run --example ai_workload_analysisCustomize the analyzer behavior:
use system_analysis::analyzer::AnalyzerConfig;
let config = AnalyzerConfig {
enable_gpu_detection: true,
enable_detailed_cpu_analysis: true,
enable_network_testing: false,
cache_duration_seconds: 300,
enable_benchmarking: false,
benchmark_timeout_seconds: 30,
};
let analyzer = SystemAnalyzer::with_config(config);SystemAnalyzer: Main analyzer for system capabilitiesSystemProfile: Comprehensive system analysis resultsWorkloadRequirements: Specification of workload needsCompatibilityResult: Results of compatibility analysisResourceUtilization: Resource usage predictionsUpgradeRecommendation: Hardware upgrade suggestions
ResourceType: CPU, GPU, Memory, Storage, NetworkCapabilityLevel: VeryLow, Low, Medium, High, VeryHigh, ExceptionalResourceAmount: Different ways to specify resource amounts
AIInferenceWorkload: AI model inference workloadsModelParameters: AI model parameter specifications- Custom workloads via the
Workloadtrait
The crate uses the SystemAnalysisError enum for comprehensive error handling:
use system_analysis::error::SystemAnalysisError;
match result {
Ok(profile) => println!("Analysis successful: {}", profile.overall_score()),
Err(SystemAnalysisError::AnalysisError { message }) => {
eprintln!("Analysis failed: {}", message);
}
Err(SystemAnalysisError::SystemInfoError { source }) => {
eprintln!("System information error: {}", source);
}
Err(e) => eprintln!("Other error: {}", e),
}- Windows: Full support with Windows-specific optimizations
- Linux: Full support with Linux-specific hardware detection
- macOS: Full support with macOS-specific APIs
- System analysis results are cached for 5 minutes by default
- GPU detection can be disabled to reduce startup time
- Network testing is disabled by default as it can be slow
- Benchmarking is optional and disabled by default
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Licensed under either of
- Apache License, Version 2.0
- MIT License
at your option.
- Basic system analysis functionality
- AI workload specialization
- Compatibility checking
- Resource utilization prediction
- Upgrade recommendations
- Cross-platform support
- Comprehensive examples and documentation
use system_analysis::{
workloads::{Workload, WorkloadType},
resources::{ResourceRequirement, ResourceType, CapabilityLevel},
};
struct CustomWorkload {
name: String,
cpu_intensive: bool,
memory_gb: f64,
}
impl Workload for CustomWorkload {
fn workload_type(&self) -> WorkloadType {
WorkloadType::Custom(self.name.clone())
}
fn resource_requirements(&self) -> Vec<ResourceRequirement> {
let mut requirements = Vec::new();
requirements.push(
ResourceRequirement::new(ResourceType::Memory)
.minimum_gb(self.memory_gb)
);
if self.cpu_intensive {
requirements.push(
ResourceRequirement::new(ResourceType::CPU)
.minimum_level(CapabilityLevel::High)
.cores(8)
);
}
requirements
}
fn validate(&self) -> system_analysis::Result<()> {
if self.memory_gb <= 0.0 {
return Err(system_analysis::SystemAnalysisError::invalid_workload(
"Memory requirement must be positive"
));
}
Ok(())
}
fn clone_workload(&self) -> Box<dyn Workload> {
Box::new(CustomWorkload {
name: self.name.clone(),
cpu_intensive: self.cpu_intensive,
memory_gb: self.memory_gb,
})
}
}use system_analysis::{SystemAnalyzer, capabilities::CapabilityProfile};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut analyzer = SystemAnalyzer::new();
let system_profile = analyzer.analyze_system().await?;
let capabilities = analyzer.get_capability_profile().await?;
// CPU Analysis
println!("CPU: {} ({} cores)",
capabilities.cpu.brand,
capabilities.cpu.physical_cores
);
println!("CPU AI Score: {}/10", capabilities.cpu.ai_score);
// GPU Analysis
for (i, gpu) in capabilities.gpu.iter().enumerate() {
println!("GPU {}: {} ({}GB VRAM)",
i + 1,
gpu.name,
gpu.memory_gb
);
println!("GPU AI Score: {}/10", gpu.ai_score);
}
// Memory Analysis
println!("Memory: {:.1}GB {} @ {}MHz",
capabilities.memory.total_gb,
capabilities.memory.memory_type,
capabilities.memory.frequency_mhz.unwrap_or(0)
);
Ok(())
}use system_analysis::{SystemAnalyzer, utils::BenchmarkRunner};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut analyzer = SystemAnalyzer::new();
let mut benchmark_runner = BenchmarkRunner::new();
// Run CPU benchmark
let cpu_score = benchmark_runner.benchmark_cpu().await?;
println!("CPU Benchmark Score: {}/10", cpu_score);
// Run memory benchmark
let memory_score = benchmark_runner.benchmark_memory().await?;
println!("Memory Benchmark Score: {}/10", memory_score);
// Run comprehensive system benchmark
let overall_score = benchmark_runner.benchmark_system().await?;
println!("Overall System Score: {}/10", overall_score);
Ok(())
}The crate is organized into several key modules:
analyzer: Main system analysis logic and orchestrationcapabilities: Hardware capability assessment and scoringworkloads: Workload definitions and AI/ML specializationsresources: Resource management and requirement modelingtypes: Core data types and structuresutils: Utility functions and helper toolserror: Comprehensive error handling
Run the comprehensive test suite:
# Run all tests
cargo test
# Run tests with output
cargo test -- --nocapture
# Run specific test modules
cargo test integration_tests
cargo test edge_case_tests
# Run benchmarks
cargo benchThe crate includes comprehensive benchmarks:
# Run all benchmarks
cargo bench
# Run specific benchmarks
cargo bench -- system_analysis
cargo bench -- workload_creation
cargo bench -- compatibility_checking
# Generate HTML benchmark reports
cargo bench -- --output-format html- Model Compatibility: Check if your system can run specific AI models
- Performance Estimation: Predict inference speed and resource usage
- Hardware Recommendations: Get specific upgrade suggestions for AI workloads
- Batch Processing: Optimize batch sizes based on available resources
- Hardware Procurement: Make informed decisions about hardware purchases
- Capacity Planning: Understand current and future resource needs
- Bottleneck Analysis: Identify and resolve system limitations
- Cost Optimization: Balance performance and cost requirements
- Container Sizing: Right-size containers based on workload requirements
- Auto-scaling: Make intelligent scaling decisions based on system capabilities
- Resource Allocation: Optimize resource distribution across workloads
- Performance Monitoring: Track system capability trends over time
Enable optional features based on your needs:
[dependencies]
system-analysis = { version = "0.1.0", features = ["gpu-detection"] }Available features:
gpu-detection: Enable NVIDIA GPU detection and CUDA capabilitiesadvanced-benchmarks: Include additional benchmarking toolsml-models: Extended AI/ML model support and optimizations
We welcome contributions! Please see our Contributing Guidelines for details.
git clone https://github.com/yourusername/system-analysis.git
cd system-analysis
cargo build
cargo test- Hardware Support: Add support for new hardware types
- Workload Types: Implement new workload categories
- Platform Support: Enhance cross-platform compatibility
- Performance: Optimize analysis algorithms
- Documentation: Improve docs and examples
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
- The Rust community for excellent system information crates
- Contributors and testers who help improve this project
- AI/ML community for workload insights and requirements
- Support for ARM and Apple Silicon optimization
- Integration with cloud provider APIs
- Real-time system monitoring capabilities
- Machine learning-based performance prediction
- Web-based dashboard for system analysis
- Integration with container orchestration platforms
- Support for specialized AI hardware (TPUs, FPGAs)
For more detailed documentation, please visit docs.rs/system-analysis.