iops_profiler.collector
Data collection module for IOPS Profiler.
This module contains all the data collection functionality including: - Parsing strace and fs_usage output - Platform-specific measurement methods (Linux, macOS, Windows) - Helper functions for collecting I/O statistics
Attributes
Classes
Collector class for I/O profiling data collection. |
Module Contents
- STRACE_IO_SYSCALLS = ['read', 'write', 'pread64', 'pwrite64', 'readv', 'writev', 'preadv', 'pwritev', 'preadv2', 'pwritev2'][source]
- class Collector(shell)[source]
Collector class for I/O profiling data collection.
This class encapsulates all data collection functionality and maintains necessary state like the IPython shell, strace patterns, and syscall sets.
- static parse_fs_usage_line_static(line, byte_pattern=None, collect_ops=False)[source]
Parse a single fs_usage output line for I/O operations (static version)
- Parameters:
line – The line to parse
byte_pattern – Compiled regex pattern for extracting byte count (optional)
collect_ops – If True, return full operation info for histogram collection
- Returns:
(op_type, bytes_transferred) If collect_ops is True: {‘type’: op_type, ‘bytes’: bytes_transferred}
- Return type:
If collect_ops is False
- parse_fs_usage_line(line, collect_ops=False)[source]
Parse a single fs_usage output line for I/O operations (instance method)
This is a convenience wrapper that uses the instance’s compiled byte pattern.
- static parse_strace_line_static(line, strace_pattern, io_syscalls, collect_ops=False)[source]
Parse a single strace output line for I/O operations (static version)
Example strace lines: 3385 write(3, “Hello World…”, 1100) = 1100 3385 read(3, “data”, 4096) = 133 3385 pread64(3, “…”, 1024, 0) = 1024
Note: Lines with <unfinished …> or <… resumed> are not matched as they don’t contain complete result information in a single line.
- Parameters:
line – The line to parse
strace_pattern – Compiled regex pattern for strace output
io_syscalls – Set of I/O syscall names to track
collect_ops – If True, return full operation info for histogram collection
- Returns:
(op_type, bytes_transferred) If collect_ops is True: {‘type’: op_type, ‘bytes’: bytes_transferred}
- Return type:
If collect_ops is False
- parse_strace_line(line, collect_ops=False)[source]
Parse a single strace output line for I/O operations (instance method)
This is a convenience wrapper that uses the instance’s strace pattern and syscalls.
- static _create_helper_script(pid, output_file, control_file)[source]
Create a bash helper script that runs fs_usage with elevated privileges
- _launch_helper_via_osascript(helper_script_path)[source]
Launch helper script with sudo via osascript (prompts for password)
- measure_macos_osascript(code, collect_ops=False)[source]
Measure IOPS on macOS using fs_usage via osascript
- Parameters:
code – The code to profile
collect_ops – If True, collect individual operation sizes for histogram