Skip to content

refactor(dataProcess): Stabilize Child Process RAM usage for parallel processing - #218

Open
tonywu1999 wants to merge 15 commits into
develfrom
refactor-parallel-processing
Open

refactor(dataProcess): Stabilize Child Process RAM usage for parallel processing#218
tonywu1999 wants to merge 15 commits into
develfrom
refactor-parallel-processing

Conversation

@tonywu1999

@tonywu1999 tonywu1999 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Motivation and solution

Parallel summarization could cause unstable worker memory usage because workers received large data objects. This PR introduces a packed-data workflow that limits task payloads and stabilizes RAM usage. Workers reconstruct per-protein records and perform TMP or linear summarization.

Changes

  • Modified MSstatsSummarizeWithMultipleCores().
  • Added packed protein record creation and reconstruction.
  • Added persistent worker support with bounded protein batches.
  • Added worker warm-up, progress reporting, RSS monitoring, and optional peak-memory collection.
  • Added single-core fallback and nonfatal worker error handling.
  • Added configurable BPPARAM, track_memory, and max_proteins_per_worker arguments.
  • Added matter (for data transfer serialization and garbage collection), and BiocParallel (for bplapply in-memory parallelization management) imports.
  • Added documentation for the new function and internal packing helpers.

Coding guidelines

  • No specific coding guideline violations are identified in the provided changes.

Tests

  • Verified output is completely the same from single core - script
  • Added integration test on the HPC
  • Tested a 1 GB dataset with four cores.
    • Observed lower worker memory usage (~500MB per worker, 300MB of that being from the MSstats package initialization) with the new packed-data workflow.
    • Observed improved processing times on Linux HPC, macOS, and Windows (2x faster with 4 cores)
    • Verified speed improvements with "linear" summarization too with similar memory use as TMP (2x faster with 4 cores)
  • Tested an 8 GB dataset with four workers.
    • Observed approximately 1.7 GB peak memory per worker.
    • Observed processing time to be close to 4x faster with 4 cores.

Out of Scope

  • The parent process memory is still not well controlled once bplapply returns all of the results. For the 8GB dataset, memory in the parent process peaked to 37GB. However, this was already a problem in the previous implementation too, so this will be addressed in a future PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
R/MSstatsSummarizeWithMultipleCores.R (2)

795-799: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Pass drop = TRUE to split to avoid empty protein slots.

split defaults to drop = FALSE. With factor keys and a two-element split_keys, it emits one element for every PROTEIN × LABEL combination, including combinations with no rows. Each empty group is packed, serialized to a worker, and returns list(NULL, NULL) from the step-3 early exit at line 373. meta$PROTEIN for those slots is NA_character_.

♻️ Proposed change
-    protein_indices <- split(seq_len(nrow(input)), split_keys)
+    protein_indices <- split(seq_len(nrow(input)), split_keys, drop = TRUE)

Run the following script to confirm the key column types and how downstream code consumes the result names:

#!/bin/bash
# Check whether PROTEIN/LABEL are factors and how summarization results are consumed.
rg -nP -C 5 'MSstatsSummarizeWithMultipleCores\s*\(' --glob 'R/*.R'
echo '--- LABEL / PROTEIN factor coercion ---'
rg -nP -C 3 '(PROTEIN|LABEL)\s*:=\s*factor' --glob 'R/*.R'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@R/MSstatsSummarizeWithMultipleCores.R` around lines 795 - 799, Update the
split call in MSstatsSummarizeWithMultipleCores around protein_indices to pass
drop = TRUE, preventing empty PROTEIN × LABEL groups from being created and
dispatched. Preserve the existing split_keys construction, protein_ids naming,
and num_proteins calculation.

138-184: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

The packed layout always allocates five dense FL×R matrices, including constant-fill ones.

mat_ABU and mat_anom become all-NA matrices when their source columns are absent, and mat_cens becomes all-zero. The packed vector still reserves FL*R doubles for each of them. .MSstatsSummarizeSingleTMPV2 then skips ABUNDANCE (line 350) and ANOMALYSCORES (line 353) outright.

For the TMP path this inflates the per-protein payload by about 2.5x over the three matrices actually read. That payload is what bplapply serializes to every worker, so it directly raises the peak RAM this PR aims to stabilize.

Consider storing a per-slot presence bitmap in meta and omitting absent or constant-fill sections from packed. Keep the section offsets derived from the bitmap so .reconstructProteinDTV3 and .MSstatsSummarizeSingleTMPV2 stay in sync with the layout comment at lines 86-99.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@R/MSstatsSummarizeWithMultipleCores.R` around lines 138 - 184, Update the
packing logic around packed and the per-slot metadata to record presence for
ABUNDANCE and ANOMALYSCORES, and omit their all-NA sections; omit the
constant-fill censored section when appropriate as well. Derive section offsets
from this bitmap and update .reconstructProteinDTV3 and
.MSstatsSummarizeSingleTMPV2 to read only present sections while preserving
synchronization with the documented layout.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@man/MSstatsSummarizeWithMultipleCores.Rd`:
- Around line 14-19: Update the documentation for
MSstatsSummarizeWithMultipleCores by adding \arguments{} entries for
aft_iterations, verbose, BPPARAM, and track_memory, matching the existing
parameter conventions. Replace the vague \value{} text with the concrete
returned list structure, including each element’s type and naming contract.

In `@R/MSstatsSummarizeWithMultipleCores.R`:
- Around line 422-423: Remove the unnecessary MSstats namespace qualifiers from
both worker calls: in R/MSstatsSummarizeWithMultipleCores.R lines 422-423,
update .fitSurvival invocation to use .fitSurvival directly; at line 532, update
median_polish_summary invocation to use median_polish_summary directly. No other
changes are needed; .warmupV6Worker already attaches MSstats for socket workers.
- Around line 697-781: Update the roxygen documentation for
MSstatsSummarizeWithMultipleCores to add `@param` entries for aft_iterations,
BPPARAM, and track_memory, and either connect verbose to the existing progress
or memory-reporting behavior or remove it from the function signature since it
is unused. Replace user-facing references to MSstatsSummarizeWithMultipleCoresV5
and “V6” with MSstatsSummarizeWithMultipleCores, then regenerate the
corresponding Rd file.
- Around line 515-536: The wide-matrix construction currently retains unobserved
LABEL/RUN combinations, causing all-NA rows to reach median_polish_summary.
Update the TMP preparation around wide_mat and median_polish_summary to retain
only observed label-run pairs, then build result_labels and result_runs from the
same filtered row set rather than every label-run combination. Preserve the
existing label/run ordering for observed pairs.
- Around line 18-42: Update .peakRSS_MB to avoid Rcpp compilation and POSIX-only
getrusage calls on unsupported platforms, returning NA_real_ when no safe
peak-RSS mechanism is available. Store any compiled helper in a package-local
environment rather than .GlobalEnv, and ensure failures in compilation or lookup
are caught so .reportWorkerPeakV6() and .printMemReport() continue with “n/a”
output.

---

Nitpick comments:
In `@R/MSstatsSummarizeWithMultipleCores.R`:
- Around line 795-799: Update the split call in
MSstatsSummarizeWithMultipleCores around protein_indices to pass drop = TRUE,
preventing empty PROTEIN × LABEL groups from being created and dispatched.
Preserve the existing split_keys construction, protein_ids naming, and
num_proteins calculation.
- Around line 138-184: Update the packing logic around packed and the per-slot
metadata to record presence for ABUNDANCE and ANOMALYSCORES, and omit their
all-NA sections; omit the constant-fill censored section when appropriate as
well. Derive section offsets from this bitmap and update .reconstructProteinDTV3
and .MSstatsSummarizeSingleTMPV2 to read only present sections while preserving
synchronization with the documented layout.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b9884130-c99e-4499-a07f-53ce312d7d8f

📥 Commits

Reviewing files that changed from the base of the PR and between f5259ee and 45484bc.

📒 Files selected for processing (9)
  • DESCRIPTION
  • NAMESPACE
  • R/MSstatsSummarizeWithMultipleCores.R
  • R/dataProcess.R
  • man/MSstatsSummarizeWithMultipleCores.Rd
  • man/dot-MSstatsSummarizeSingleTMPV2.Rd
  • man/dot-buildProteinSlotV3.Rd
  • man/dot-buildSummarizeWorkerV6.Rd
  • man/dot-reconstructProteinDTV3.Rd
💤 Files with no reviewable changes (1)
  • R/dataProcess.R

Comment thread man/MSstatsSummarizeWithMultipleCores.Rd Outdated
Comment thread R/MSstatsSummarizeWithMultipleCores.R Outdated
Comment thread R/MSstatsSummarizeWithMultipleCores.R Outdated
Comment thread R/MSstatsSummarizeWithMultipleCores.R Outdated
Comment thread R/MSstatsSummarizeWithMultipleCores.R Outdated
@tonywu1999
tonywu1999 requested a review from Rudhik1904 August 4, 2026 22:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
man/dot-build_summarize_worker.Rd (1)

8-16: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

This Rd file has no \arguments section.

\usage declares six arguments, and no \item documents them. R CMD check reports "Undocumented arguments in documentation object '.build_summarize_worker'". Add @param tags for use_TMP, impute, censored_symbol, remove50missing, aft_iterations, and equal_variance in R/MSstatsSummarizeWithMultipleCores.R, then regenerate this file. An @keywords internal function is still checked for argument documentation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@man/dot-build_summarize_worker.Rd` around lines 8 - 16, Add roxygen2 `@param`
entries for use_TMP, impute, censored_symbol, remove50missing, aft_iterations,
and equal_variance in .build_summarize_worker within
MSstatsSummarizeWithMultipleCores.R, then regenerate the .build_summarize_worker
Rd documentation so its \arguments section matches the six parameters declared
by \usage.
R/MSstatsSummarizeWithMultipleCores.R (3)

20-65: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

.peak_rss_mb still writes into .GlobalEnv and still compiles C++ at runtime without a fallback.

Lines 36 and 62 assign compiled helpers into .GlobalEnv. R CMD check flags writes to the global environment. Line 50 also calls Rcpp::cppFunction with <sys/resource.h>, which requires a C++ toolchain at run time. If compilation fails, track_memory = TRUE aborts the whole summarization. Store the helpers in a package-local environment and wrap compilation in tryCatch that returns NA_real_, so .print_memory_report prints "n/a".

This repeats an earlier review comment that was marked as addressed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@R/MSstatsSummarizeWithMultipleCores.R` around lines 20 - 65, Update
.peak_rss_mb to store compiled helper functions in a package-local environment
instead of .GlobalEnv, and wrap both Rcpp::cppFunction calls and helper
invocation in tryCatch. Return NA_real_ whenever compilation or measurement
fails, preserving the existing platform-specific memory paths so
.print_memory_report can display “n/a” without aborting summarization.

608-640: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Worker errors pass silently into results.

SnowfastParam(stop.on.error = FALSE) makes bplapply return condition objects in place of failed elements instead of raising. Line 639 collects those objects and line 640 names them, so a partially failed run looks like a successful one. MSstatsSummarizeWithSingleCore has no equivalent behavior, and MSstatsSummarizationOutput in R/dataProcess.R receives the mixed list. Inspect the results with BiocParallel::bpok() after dispatch, then log or raise for the failed slots.

🛡️ Proposed check
     results <- BiocParallel::bplapply(protein_records, worker_fn, BPPARAM = BPPARAM)
     names(results) <- protein_ids
+    failed <- !BiocParallel::bpok(results)
+    if (any(failed)) {
+        msg <- paste0(sum(failed), " protein slot(s) failed during summarization: ",
+                      paste(utils::head(protein_ids[failed], 10L), collapse = ", "))
+        getOption("MSstatsLog")("ERROR", msg)
+        stop(msg)
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@R/MSstatsSummarizeWithMultipleCores.R` around lines 608 - 640, After the main
`BiocParallel::bplapply` call that assigns `results`, inspect the returned slots
with `BiocParallel::bpok()` before naming or passing them onward. Detect any
failed elements and raise an error (including the failed slot details) so
`MSstatsSummarizeWithMultipleCores` cannot return a partially successful results
list; leave successful results unchanged.

386-397: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Handle failed summarization results before indexing result[[idx]].

MSstatsSummarizeSingleTMP returns list(NULL, NULL) and MSstatsSummarizeSingleLinear can return list(NULL, survival), but the worker unconditionally indexes result[[1]] and result[[2]]. Add a length/null guard before the level-normalization loop so unsummarizable proteins pass through without a subscript error.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@R/MSstatsSummarizeWithMultipleCores.R` around lines 386 - 397, Add a guard in
the result-normalization flow before the loop over result indices to return
unsummarizable outputs safely when the summarization result is missing or too
short. Ensure both list(NULL, NULL) and list(NULL, survival) outcomes avoid
invalid result[[idx]] access, while valid results continue through RUN, FEATURE,
and cen normalization unchanged.
🧹 Nitpick comments (1)
R/MSstatsSummarizeWithMultipleCores.R (1)

642-655: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The memory report contains a single checkpoint.

memory_checkpoints receives only "parent peak (main)", so the "Delta" column that .print_memory_report renders is always empty. .current_rss_mb is defined at line 5 but never called. Record checkpoints after packing and after dispatch with .current_rss_mb(), or simplify the report.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@R/MSstatsSummarizeWithMultipleCores.R` around lines 642 - 655, Update the
memory-tracking flow around .print_memory_report to record multiple checkpoints:
call .current_rss_mb() after packing and again after dispatch, storing both
values in memory_checkpoints alongside the existing parent peak checkpoint.
Preserve the worker peak collection and report generation while ensuring the
resulting report has meaningful Delta values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@man/dot-build_summarize_worker.Rd`:
- Around line 8-16: Add roxygen2 `@param` entries for use_TMP, impute,
censored_symbol, remove50missing, aft_iterations, and equal_variance in
.build_summarize_worker within MSstatsSummarizeWithMultipleCores.R, then
regenerate the .build_summarize_worker Rd documentation so its \arguments
section matches the six parameters declared by \usage.

In `@R/MSstatsSummarizeWithMultipleCores.R`:
- Around line 20-65: Update .peak_rss_mb to store compiled helper functions in a
package-local environment instead of .GlobalEnv, and wrap both Rcpp::cppFunction
calls and helper invocation in tryCatch. Return NA_real_ whenever compilation or
measurement fails, preserving the existing platform-specific memory paths so
.print_memory_report can display “n/a” without aborting summarization.
- Around line 608-640: After the main `BiocParallel::bplapply` call that assigns
`results`, inspect the returned slots with `BiocParallel::bpok()` before naming
or passing them onward. Detect any failed elements and raise an error (including
the failed slot details) so `MSstatsSummarizeWithMultipleCores` cannot return a
partially successful results list; leave successful results unchanged.
- Around line 386-397: Add a guard in the result-normalization flow before the
loop over result indices to return unsummarizable outputs safely when the
summarization result is missing or too short. Ensure both list(NULL, NULL) and
list(NULL, survival) outcomes avoid invalid result[[idx]] access, while valid
results continue through RUN, FEATURE, and cen normalization unchanged.

---

Nitpick comments:
In `@R/MSstatsSummarizeWithMultipleCores.R`:
- Around line 642-655: Update the memory-tracking flow around
.print_memory_report to record multiple checkpoints: call .current_rss_mb()
after packing and again after dispatch, storing both values in
memory_checkpoints alongside the existing parent peak checkpoint. Preserve the
worker peak collection and report generation while ensuring the resulting report
has meaningful Delta values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 331dce4b-6553-4982-9276-2d3a501e71ff

📥 Commits

Reviewing files that changed from the base of the PR and between 29f34da and d232302.

📒 Files selected for processing (5)
  • R/MSstatsSummarizeWithMultipleCores.R
  • man/MSstatsSummarizeWithMultipleCores.Rd
  • man/dot-build_summarize_worker.Rd
  • man/dot-pack_protein_slot.Rd
  • man/dot-unpack_protein_slot.Rd
🚧 Files skipped from review as they are similar to previous changes (1)
  • man/MSstatsSummarizeWithMultipleCores.Rd

@Vitek-Lab Vitek-Lab deleted a comment from coderabbitai Bot Aug 5, 2026
@Vitek-Lab Vitek-Lab deleted a comment from github-actions Bot Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

Parallel summarization

Layer / File(s) Summary
Packed protein records
R/MSstatsSummarizeWithMultipleCores.R, man/dot-pack_protein_slot.Rd, man/dot-unpack_protein_slot.Rd
Protein data is packed with metadata and reconstructed into compatible data.table objects.
Worker summarization and dispatch
R/MSstatsSummarizeWithMultipleCores.R, R/dataProcess.R, DESCRIPTION, NAMESPACE
The new API dispatches TMP or linear summarization across persistent workers, supports batching and custom BPPARAM, and retains single-core fallback behavior.
Cross-platform RSS instrumentation
src/peak_rss.cpp, src/RcppExports.cpp, R/RcppExports.R, src/Makevars.win
Peak resident memory is exposed to R with platform-specific implementations and Windows linking support.
Benchmarks and documentation
benchmark/*, man/*, R/utils_censored.R, R/utils_summarization.R
Benchmarks compare single-core and four-core execution. Generated documentation describes the new API, helpers, and parameter behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant MSstatsSummarizeWithMultipleCores
  participant BiocParallelWorkers
  participant MSstatsSummarization
  Caller->>MSstatsSummarizeWithMultipleCores: submit input and parallel options
  MSstatsSummarizeWithMultipleCores->>BiocParallelWorkers: dispatch packed protein records
  BiocParallelWorkers->>MSstatsSummarization: reconstruct records and summarize
  MSstatsSummarization-->>BiocParallelWorkers: return per-protein result
  BiocParallelWorkers-->>MSstatsSummarizeWithMultipleCores: return named results and memory data
  MSstatsSummarizeWithMultipleCores-->>Caller: return per-protein-slot list
Loading

Possibly related PRs

Suggested labels: Review effort 4/5

Suggested reviewers: mstaniak, devonjkohler, rudhik1904

Poem

A rabbit packs each protein tight,
Then sends it hopping worker-flight.
RSS peaks rise into view,
Four cores dash where one once grew.
Docs and benchmarks mark the way. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: stabilizing worker RAM usage during parallel processing.
Description check ✅ Passed The description covers motivation, changes, testing, and scope, but it omits the repository checklist section.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-parallel-processing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@benchmark/benchmark_summarize_perf_selevsek.R`:
- Around line 14-24: Release result_1core after the single-core timing completes
and before invoking MSstatsSummarizeWithMultipleCores for time_4core, using the
script’s existing cleanup or garbage-collection mechanism if available. Preserve
the single-core measurement while ensuring result_1core is no longer reachable
when the parallel run starts.

In `@benchmark/config.slurm`:
- Line 30: Update the benchmark setup in config.slurm to install or load the PR
branch’s checked-out Vitek-Lab/MSstats source instead of the devel branch,
ensuring R/MSstatsSummarizeWithMultipleCores.R is available before the scripts
in R_SCRIPTS run.

In `@R/utils_censored.R`:
- Around line 87-88: Update the `.setCensoredByThreshold` documentation for
`remove50missing` to match the helper’s actual behavior: do not claim it removes
features when the helper does not read or apply that option, and instead state
that filtering occurs before this call if that is the intended contract.

In `@R/utils_summarization.R`:
- Around line 3-4: Update the remove50missing parameter documentation in the
summarization function to say proteins with at least 50% missing values are
excluded, matching the inclusive input$prop_features <= 0.5 condition.
Regenerate man/dot-isSummarizable.Rd so the generated documentation reflects
this wording.

In `@src/peak_rss.cpp`:
- Around line 20-21: Update peak_rss_mb() to initialize the rusage struct before
calling getrusage, check the call’s return value, and return NA_REAL immediately
when it fails; only read ru.ru_maxrss after a successful call.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3b7a378a-2f67-489b-9834-16d567fd5568

📥 Commits

Reviewing files that changed from the base of the PR and between d232302 and cfb812e.

📒 Files selected for processing (19)
  • R/MSstatsSummarizeWithMultipleCores.R
  • R/RcppExports.R
  • R/utils_censored.R
  • R/utils_summarization.R
  • benchmark/benchmark_summarize_perf_selevsek.R
  • benchmark/config.slurm
  • man/MSstatsSummarizeSingleTMP.Rd
  • man/MSstatsSummarizeWithMultipleCores.Rd
  • man/MSstatsSummarizeWithSingleCore.Rd
  • man/dot-build_summarize_worker.Rd
  • man/dot-getNonMissingFilterStats.Rd
  • man/dot-isSummarizable.Rd
  • man/dot-pack_protein_slot.Rd
  • man/dot-runTukey.Rd
  • man/dot-setCensoredByThreshold.Rd
  • man/reexports.Rd
  • src/Makevars.win
  • src/RcppExports.cpp
  • src/peak_rss.cpp
🚧 Files skipped from review as they are similar to previous changes (3)
  • man/dot-pack_protein_slot.Rd
  • man/dot-build_summarize_worker.Rd
  • R/MSstatsSummarizeWithMultipleCores.R

Comment thread benchmark/benchmark_summarize_perf_selevsek.R
Comment thread benchmark/config.slurm
Comment thread R/utils_censored.R
Comment thread R/utils_summarization.R
Comment thread src/peak_rss.cpp
@tonywu1999 tonywu1999 changed the title refactor(dataProcess): Stabilize RAM usage for parallel processing refactor(dataProcess): Stabilize Child Process RAM usage for parallel processing Aug 6, 2026
# - 4 cores should reduce wall time by at least 25% vs. 1 core
# - peak RSS per worker should stay under ~1GB (see the memory report below)

input <- data.table::fread("/projects/VitekLab/Data/MS/selevsek/before_summarization.csv")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's this path?

Comment thread src/peak_rss.cpp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a bit of docs would help. Goal + output at least

@@ -0,0 +1,401 @@
.peak_rss_mb <- function() {
if (.Platform$OS.type != "windows" && file.exists("/proc/self/status")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please document this path

@@ -0,0 +1,401 @@
.peak_rss_mb <- function() {
if (.Platform$OS.type != "windows" && file.exists("/proc/self/status")) {
ln <- grep("^VmHWM:", readLines("/proc/self/status"), value = TRUE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's this regular expression?

previous_value <- checkpoint_value
}
if (!is.null(worker_peak_mb)) {
observed_peaks <- worker_peak_mb[!is.na(worker_peak_mb)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"observed_peaks" is a bit too general in the MS context (-;
meaning unclear (-;

#' @return data.table compatible with \code{MSstatsSummarizeSingleTMP} /
#' \code{MSstatsSummarizeSingleLinear}
#' @keywords internal
.unpack_protein_slot <- function(packed, meta) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is relying on integer indices here safe?


payload_mb <- sum(vapply(protein_records,
function(r) length(r$packed), integer(1))) * 8 / 1024^2
getOption("MSstatsLog")("INFO",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this still valid after log4r issues with CRAN?
Btw this package may come back soon, there was a github release a couple day ago I think

protein_dt, impute_, censored_symbol_,
remove50missing_, aft_iterations_)
} else {
MSstatsSummarizeSingleLinear(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we still need the linear summarization option?
@tonywu1999 @devonjkohler

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