| Crates.io | system-profile |
| lib.rs | system-profile |
| version | 0.1.1 |
| created_at | 2025-08-22 11:42:30.830965+00 |
| updated_at | 2025-11-03 21:52:10.475316+00 |
| description | Cached system profile information for runtime optimization decisions |
| homepage | https://gitlab.com/deepbrain.space/system-profile |
| repository | https://gitlab.com/deepbrain.space/system-profile |
| max_upload_size | |
| id | 1806220 |
| size | 39,698 |
Cached system profile information for runtime optimization decisions.
System Profile provides a lazily-initialized, cached view of system resources that applications can use to make intelligent runtime optimization decisions. Information is gathered once at first access and cached for the lifetime of the application.
Add to your Cargo.toml:
[dependencies]
system-profile = "0.1.0"
use system_profile::SystemProfile;
// Get cached system profile (initialized on first call)
let profile = SystemProfile::global();
// Use profile information for runtime decisions
let worker_count = if profile.cpu_count() > 8 {
8 // Cap at 8 workers for large systems
} else {
profile.cpu_count()
};
// Check available memory for workload sizing
let available_memory = profile.available_memory_mb();
if available_memory < 1000 {
println!("Warning: Low memory available");
}
// Make optimization decisions based on system capabilities
let batch_size = match (profile.cpu_count(), available_memory) {
(cpu, mem) if cpu >= 8 && mem >= 8000 => 1000, // High-end system
(cpu, mem) if cpu >= 4 && mem >= 4000 => 500, // Mid-range system
_ => 100, // Conservative default
};
SystemProfile::global() - Get the global cached system profilecpu_count() - Number of logical CPU corestotal_memory_mb() - Total system memory in megabytesavailable_memory_mb() - Available system memory in megabytesis_low_memory() - Returns true if available memory is below thresholdOptional GPU detection (requires gpu feature):
[dependencies]
system-profile = { version = "0.1.0", features = ["gpu"] }
use system_profile::SystemProfile;
let profile = SystemProfile::global();
let optimal_workers = profile.cpu_count().min(8);
// Use optimal worker count for parallel processing
rayon::ThreadPoolBuilder::new()
.num_threads(optimal_workers)
.build_global()
.unwrap();
use system_profile::SystemProfile;
let profile = SystemProfile::global();
let cache_size = if profile.available_memory_mb() > 4000 {
1000 // Large cache for systems with plenty of memory
} else {
100 // Conservative cache for memory-constrained systems
};
use system_profile::SystemProfile;
fn determine_batch_size() -> usize {
let profile = SystemProfile::global();
match profile.cpu_count() {
n if n >= 16 => 1000, // High-performance server
n if n >= 8 => 500, // Desktop/workstation
n if n >= 4 => 250, // Laptop
_ => 100, // Single/dual-core system
}
}
std::sync::LazyLock for safe concurrent accessMIT License - see LICENSE for details.
Contributions welcome! Please see CONTRIBUTING.md for guidelines.