ddn.util.monaco.optimize
Performance optimization utilities for Monaco system monitoring.
This module provides optimized file reading, memory-mapped I/O, and other performance enhancements for system monitoring operations.
Copyright
Types 8
Exception thrown when optimization operations fail.
this(string msg, string file = __FILE__, size_t line = __LINE__)Configuration for optimization features.
bool useMmapWhether to use memory-mapped files for readingsize_t bufferSizeBuffer size for file reading (in bytes)bool enableCachingWhether to cache parsed valuessize_t maxMmapSizeMaximum size for files to be memory-mapped (in bytes)Optimized file reader with buffering and memory mapping support.
This class provides efficient file reading operations, particularly for /proc and /sys files which are commonly accessed in system monitoring.
Example:
auto reader = new OptimizedFileReader();
auto content = reader.readText("/proc/stat");string[string] readKeyValuePairs(string path, char separator = ':') @safeReads a file and parses it as key-value pairs.this()Creates a new optimized file reader with default configuration.this(OptimizationConfig cfg)Creates a new optimized file reader with custom configuration.Lazy evaluation range for process enumeration.
This struct provides lazy iteration over processes, avoiding the overhead of loading all process information at once.
Example:
auto range = ProcessRange("/proc");
foreach (pid; range)
{
// Process pid lazily
}private string procPathprivate int currentPidprivate bool initializedthis(string path)Creates a new process range.Batch reader for reading multiple files efficiently.
This class optimizes reading multiple files by grouping operations and minimizing system calls.
Example:
auto batch = new BatchReader();
batch.add("/proc/stat");
batch.add("/proc/meminfo");
auto results = batch.readAll();this()Creates a new batch reader.Parsing utilities optimized for system files.
long parseNumber(string str) @safe pureParses a number from a string, skipping non-numeric characters.ulong parseMemoryValue(string str) @safe pureParses a memory value with optional suffix (kB, MB, GB).String interning pool for reducing memory allocations.
This class maintains a pool of unique strings, returning references to existing strings rather than creating duplicates.
private string[string] poolGlobal optimization manager singleton.
private OptimizationManager instanceprivate OptimizedFileReader fileReaderprivate StringPool stringPoolprivate OptimizationConfig configthis()