Skip to content

Optimize memory management and fix parallel deadlocks for HPC#28

Open
Lesky47 wants to merge 3 commits into
VanLoo-lab:v0.2.0from
Lesky47:fix-datatable-v020
Open

Optimize memory management and fix parallel deadlocks for HPC#28
Lesky47 wants to merge 3 commits into
VanLoo-lab:v0.2.0from
Lesky47:fix-datatable-v020

Conversation

@Lesky47
Copy link
Copy Markdown
Collaborator

@Lesky47 Lesky47 commented Feb 24, 2026

  • Replaced DT sorting with setorder. Replaced 'foreach' + '.combine="rbind"' with 'lapply' + 'rbindlist' to avoid quadratic copying. Peak RAM dropped from >400GB to ~20GB with 16 cores in this step. Runtime dropped from 1.5 hrs to seconds.

  • Updated parallelization in allele counting with 'callr' package. Previous 'doParallel::stopImplicitCluster' creates OpenMP deadlocks for the second bam at allele counting step. Now using callr::r() to isolate per-sample processing. Reclaims memory and clears locks between BAM files.

  • Bugfix: Corrected invalid 'on=' argument to 'by=' in SNP data.table merge

Lesky47 and others added 2 commits February 11, 2026 21:37
ASCAT expects data frames; convert SNPpos to data.frame. Deep copy of SNPpos to avoid modifying the original object by reference.
- Replaced DT sorting with setorder. Replaced 'foreach' + '.combine="rbind"' with 'lapply' + 'rbindlist' to avoid quadratic copying. Peak RAM dropped from >400GB to ~20GB with 16 cores in this step. Runtime dropped from 1.5 hrs to seconds.
- Updated parallelization in allele counting with 'callr' package. Previous 'doParallel::stopImplicitCluster' creates OpenMP deadlocks for the second bam at allele counting step. Now using callr::r() to isolate per-sample processing. Reclaims memory and clears locks between BAM files.
- Bugfix: Corrected invalid 'on=' argument to 'by=' in SNP data.table merge
@Lesky47 Lesky47 requested a review from NMNS93 February 24, 2026 21:57
Copy link
Copy Markdown
Collaborator

@NMNS93 NMNS93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the TODO, LGTM. Thanks!

Comment thread R/ascat.R
tsnps <- tsnps[BAF_n >= 0.08 & BAF_n <= 0.92]

# Temporarily changed to 0.2 and 0.8 for high coverage WGBS data.
# TODO: fix this later !!!
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO comment not required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants