Memory profiling and monitoring
Curated, evidence-grounded skill and software-tool collections for scientific AI agents, generated by the AgenticScienceBuilder
npx -y skills add HolobiomicsLab/asb-skill-collections --skill memory-profiling-and-monitoringAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 14 stars14 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when when benchmarking or validating the scalability of single-cell algorithms that claim linear or sublinear space complexity, particularly when processing datasets with ≥10 million cells.
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
7.0 KB, as published. Nobody here has run it
Memory profiling and monitoring
Summary
Systematically measure and record peak memory usage during computationally intensive single-cell analysis operations (e.g., spectral embedding) to verify that algorithms meet claimed space complexity and scale to large datasets. This skill is essential for validating scalability claims and identifying memory bottlenecks in matrix-free and sparse-matrix workflows.
When to use
When benchmarking or validating the scalability of single-cell algorithms that claim linear or sublinear space complexity, particularly when processing datasets with ≥10 million cells. Apply this skill during spectral embedding, co-embedding, or other dimension-reduction operations on large sparse matrices in CSR format to confirm that memory usage remains manageable and does not exceed system constraints.
When NOT to use
- When profiling algorithms already known to be in-memory (e.g., dense matrix operations on small datasets <1M cells) where memory monitoring provides no new insight.
- When the algorithm's space complexity is not publicly documented or claimed; memory profiling alone cannot validate an unspecified claim.
- When the computational platform (e.g., GPU-accelerated or distributed-memory system) uses memory management schemes that are opaque to Python-level profilers.
Inputs
- single-cell count matrix with ≥10 million cells in CSR format
- algorithm implementation (e.g., tl.spectral from SnapATAC2)
- similarity metric specification (e.g., cosine similarity)
- system profiler configuration (memory_profiler or psutil)
Outputs
- peak memory usage (bytes or MB)
- wall-clock runtime for reference
- memory vs. cell count plot or table
- assessment of observed vs. claimed space complexity
How to apply
Execute the target algorithm (e.g., tl.spectral with cosine similarity metric) on your dataset while simultaneously monitoring memory consumption using a dedicated memory profiler such as memory_profiler or psutil. Record the peak memory usage throughout the entire spectral decomposition operation, noting the timestamp and algorithm phase (e.g., matrix initialization, eigendecomposition, output assembly). After execution, analyze the measured peak memory against the algorithm's documented space complexity claim by plotting execution metrics (memory vs. dataset size or cell count). Compare observed memory behavior against the claimed linear or sublinear scaling to identify whether the algorithm meets its specification or reveals unexpected memory growth.
Related tools
- memory_profiler (Python library for line-by-line memory consumption tracking during spectral embedding execution)
- psutil (System-level profiler for monitoring peak memory usage and process resource consumption in real time)
- SnapATAC2 (Single-cell analysis framework providing tl.spectral (matrix-free spectral embedding) and CSR-based data structures for profiling) — https://github.com/scverse/SnapATAC2
- Python time module (Standard library for capturing wall-clock runtime alongside memory profiling)
Examples
import snapatac2 as snap; import psutil; import time; data = snap.datasets.pbmc500(); t0 = time.time(); snap.tl.spectral(data, metric='cosine'); print(f'Peak memory: {psutil.Process().memory_info().peak_wset / 1e9:.2f} GB, Runtime: {time.time() - t0:.2f}s')
Evaluation signals
- Peak memory usage is lower than or proportional to dataset size (cells × features), confirming sublinear or linear space complexity as claimed.
- Memory growth curve plotted against cell count shows a slope consistent with O(n) or O(n log n) rather than superlinear behavior.
- Peak memory measurement is stable and reproducible across multiple runs on the same dataset, indicating reliable profiler instrumentation.
- No out-of-memory errors or swap thrashing occurs during execution on the tested dataset size, confirming practical scalability.
- Memory profiler output includes timestamps and phase annotations (e.g., initialization, eigendecomposition, output assembly) that identify which algorithm stage consumes the most memory.
Limitations
- Python-level memory profilers (memory_profiler, psutil) cannot directly track memory allocated in compiled extensions (e.g., Rust code in SnapATAC2); overhead of profiling itself may inflate measured peak memory by 5–10%.
- Peak memory measurement depends on system configuration, available RAM, and competing processes; results may vary across hardware platforms and are not portable across different execution environments.
- Memory profiling adds runtime overhead and may not be practical for validating wall-clock performance claims; use dedicated benchmarking without profiling for latency-sensitive analyses.
Evidence
- [other] Monitor and record peak memory usage throughout the spectral decomposition using a memory profiler (e.g., memory_profiler or psutil).: "Monitor and record peak memory usage throughout the spectral decomposition using a memory profiler (e.g., memory_profiler or psutil)"
- [other] Analyze runtime and peak memory against the reported linear complexity claim by plotting execution metrics.: "Analyze runtime and peak memory against the reported linear complexity claim by plotting execution metrics"
- [other] Scale to more than 10 million cells, demonstrating its capacity to handle very large single-cell datasets.: "SnapATAC2 is capable of scaling to more than 10 million cells, demonstrating its capacity to handle very large single-cell datasets"
- [intro] Matrix-free spectral embedding algorithm that is applicable to a wide range of single-cell omics data.: "Matrix-free spectral embedding algorithm that is applicable to a wide range of single-cell omics data, including single-cell ATAC-seq, single-cell RNA-seq, single-cell Hi-C, and single-cell"
- [readme] SnapATAC2: A Python/Rust package with fully backed AnnData and seamless integration with other single-cell analysis packages.: "SnapATAC2: A Python/Rust package for single-cell epigenomics analysis"