Skip to content

revert(sort): restore --max-memory default to 768M - #245

Merged
nh13 merged 1 commit into
mainfrom
nh/sort-default-revert-768m
Apr 8, 2026
Merged

nh13 merged 1 commit into
mainfrom
nh/sort-default-revert-768m

Conversation

@nh13

@nh13 nh13 commented Apr 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Revert fgumi sort --max-memory default from auto back to 768M (samtools-compatible)
  • auto remains available as an opt-in value
  • Updates help text / examples to reflect the new default

Why

On c7g.4xlarge benchmarks, --max-memory=auto regresses WES/WGS sort runtimes (up to +54% on WES coordinate t8) and uses 1.4-3.4x more RSS than 768M. Root cause is page-cache eviction: when the sort budget approaches total RAM, the OS cannot keep phase-1 spill files hot, and phase 2 re-reads them from NVMe instead of from the page cache. Local dev machines with abundant RAM and fast NVMe masked this during the original PR #236 validation.

This restores the previous default as an immediate fix. A follow-up will introduce a hybrid sort (small per-cycle sorts + in-memory chunk pool) that can use the extra memory safely; once that lands and is verified on the full c7g matrix, the default will flip back to auto.

Test plan

On c7g.4xlarge benchmarks, --max-memory=auto regresses WES/WGS sort
runtimes (up to +54% on WES coordinate t8) and uses 1.4-3.4x more RSS
than 768M. Root cause is page-cache eviction: when the sort budget
approaches total RAM, the OS cannot keep phase-1 spill files hot and
phase 2 re-reads them from NVMe instead of the page cache.

auto remains available as an opt-in value. A follow-up will introduce
a hybrid sort that can use the extra memory safely, after which the
default will flip back to auto.
@nh13
nh13 temporarily deployed to github-actions April 7, 2026 22:30 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Apr 7, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The fgumi sort command's --max-memory flag default changed from "auto" to "768M". Documentation and examples were updated to reflect the new fixed memory limit per thread, with additional guidance showing how to explicitly enable automatic system memory detection using --max-memory auto. The underlying memory resolution logic remained unchanged; only the user-facing default and clap attribute were modified.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: reverting the --max-memory default from auto back to 768M, which is the core purpose of this PR.
Description check ✅ Passed The description clearly relates to the changeset, explaining the rationale for reverting the default, performance regression details, and test plan.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 nh/sort-default-revert-768m

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 and usage tips.

@codecov

codecov Bot commented Apr 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.94%. Comparing base (f0b83c6) to head (3e2f9eb).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #245      +/-   ##
==========================================
- Coverage   89.04%   88.94%   -0.11%     
==========================================
  Files         114      119       +5     
  Lines       55304    57819    +2515     
==========================================
+ Hits        49247    51425    +2178     
- Misses       6057     6394     +337     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nh13 nh13 added the fgumi sort label Apr 7, 2026
@nh13

nh13 commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

🧹 Nitpick comments (1)
src/lib/commands/sort.rs (1)

205-205: Add a regression test for the clap default.

To prevent future flips/regressions, add one parser-level test asserting Sort defaults max_memory to "768M".

Proposed test
 #[test]
 fn test_parse_memory_auto() {
@@
 }
+
+#[test]
+fn test_clap_default_max_memory_is_768m() {
+    let sort = <Sort as clap::Parser>::parse_from([
+        "fgumi",
+        "sort",
+        "-i",
+        "in.bam",
+        "-o",
+        "out.bam",
+    ]);
+    assert_eq!(
+        sort.max_memory,
+        parse_memory("768M").expect("parse_memory should succeed for 768M")
+    );
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/commands/sort.rs` at line 205, Add a parser-level unit test that
verifies the Clap default for Sort::max_memory remains "768M": write a test that
constructs/parses the Sort command with no arguments (e.g., via clap's
parse_from or deriving Parser for Sort) and assert that the resulting
Sort.max_memory (or the field name max_memory) equals the string "768M" (or the
parsed Memory type's original string if using a wrapper) to lock in the
attribute #[arg(..., default_value = "768M", value_parser = parse_memory)]
behavior; place the test alongside other command tests and reference the Sort
struct, the max_memory field, and parse_memory in the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/lib/commands/sort.rs`:
- Line 205: Add a parser-level unit test that verifies the Clap default for
Sort::max_memory remains "768M": write a test that constructs/parses the Sort
command with no arguments (e.g., via clap's parse_from or deriving Parser for
Sort) and assert that the resulting Sort.max_memory (or the field name
max_memory) equals the string "768M" (or the parsed Memory type's original
string if using a wrapper) to lock in the attribute #[arg(..., default_value =
"768M", value_parser = parse_memory)] behavior; place the test alongside other
command tests and reference the Sort struct, the max_memory field, and
parse_memory in the assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e188877-e6b0-43a2-b176-24a0cd47b050

📥 Commits

Reviewing files that changed from the base of the PR and between 5df7e17 and 3e2f9eb.

📒 Files selected for processing (1)
  • src/lib/commands/sort.rs

@nh13
nh13 merged commit 0757238 into main Apr 8, 2026
8 of 9 checks passed
@nh13
nh13 deleted the nh/sort-default-revert-768m branch April 8, 2026 19:43
@nh13 nh13 mentioned this pull request Apr 8, 2026

This branch was previously deployed

1 inactive deployment
github-actions — 3e2f9ebf Deployed Apr 7, 2026 by nh13 via coverage #983
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant