Module pool

Module pool 

Source
Expand description

Copyright © 2025-2026 Wenze Wei. All Rights Reserved.

This file is part of DMSC. The DMSC project belongs to the Dunimd Team.

Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

§Resource Pool Management

This file implements resource pool management for the DMSC framework, providing a way to group similar devices together for efficient resource allocation and management. It includes both single resource pools and a resource pool manager for handling multiple pools.

§Key Components

  • DMSCResourcePool: Manages a pool of similar devices
  • DMSCResourcePoolConfig: Configuration for resource pools
  • DMSCResourcePoolStatistics: Statistics for monitoring resource pools
  • DMSCResourcePoolManager: Manages multiple resource pools

§Design Principles

  1. Resource Grouping: Groups similar devices together for efficient management
  2. Capacity Tracking: Tracks total, available, and allocated capacity
  3. Statistics Collection: Collects comprehensive statistics for monitoring
  4. Device Filtering: Filters devices by availability and allocation status
  5. Health Monitoring: Monitors pool health based on available devices
  6. Utilization Tracking: Tracks resource utilization rates
  7. Multi-Pool Management: Supports managing multiple pools through a central manager
  8. Device Type Segregation: Each pool contains devices of a single type
  9. Arc-Based Sharing: Uses Arc for safe concurrent access to devices
  10. Serialization Support: All structures support serialization/deserialization
  11. Builder Pattern: Configurable through DMSCResourcePoolConfig
  12. Resource Optimization: Calculates total compute, memory, storage, and bandwidth

§Usage

use dmsc::device::{DMSCResourcePoolManager, DMSCResourcePoolConfig, DMSCDeviceType};
use dmsc::core::DMSCResult;
 
fn example() -> DMSCResult<()> {
    // Create a resource pool manager
    let mut manager = DMSCResourcePoolManager::new();
     
    // Create a resource pool configuration
    let config = DMSCResourcePoolConfig {
        name: "cpu-pool-1".to_string(),
        device_type: DMSCDeviceType::CPU,
        max_concurrent_allocations: 10,
        allocation_timeout_secs: 60,
        health_check_interval_secs: 30,
    };
     
    // Create a resource pool
    let pool = manager.create_pool(config);
     
    // Get pool statistics
    let stats = pool.get_statistics();
    println!("Pool has {} devices, utilization: {:.2}%", 
             stats.total_devices, stats.utilization_rate * 100.0);
     
    // Get all pools by device type
    let cpu_pools = manager.get_pools_by_type(DMSCDeviceType::CPU);
    println!("Found {} CPU pools", cpu_pools.len());
     
    // Get overall statistics
    let overall_stats = manager.get_overall_statistics();
    println!("Total devices across all pools: {}", overall_stats.total_devices);
     
    Ok(())
}

Structs§

DMSCConnectionHealthMetrics
Connection health metrics
DMSCConnectionInfo
Connection information for tracking individual connections
DMSCConnectionPool
Connection pool for managing device connections with lifecycle and health monitoring
DMSCConnectionPoolStatistics
Connection pool statistics
DMSCResourcePool
Resource pool for managing multiple similar devices
DMSCResourcePoolConfig
Configuration for a resource pool
DMSCResourcePoolManager
Resource pool manager for managing multiple resource pools
DMSCResourcePoolStatistics
Resource pool statistics structure

Enums§

DMSCConnectionState
Connection state enumeration