Skip to content

refactor(sort): demote algorithm-internal info! logs to debug - #367

Merged
nh13 merged 1 commit into
mainfrom
nh/issue-364-sort-log-levels
May 25, 2026
Merged

nh13 merged 1 commit into
mainfrom
nh/issue-364-sort-log-levels

Conversation

@nh13

@nh13 nh13 commented May 22, 2026

Copy link
Copy Markdown
Member

Summary

fgumi_lib::commands::sort emitted ~80 info! lines at the default log level, mixing user-relevant "what ran" output (config snapshot, summary, phase-timing report) with algorithm-internal chatter (per-phase markers, in-memory fast-path decisions, k-way merge thread budgets, memory-probe samples, worker-pool stats). Downstream library consumers worked around the volume by raising their own default filter (see fg-labs/mako#5); this fixes the cause instead.

Kept at info (user-visible "what ran")

  • commands/sort.rs Sort::execute config snapshot (Input, Output, Sort order, Cell tag, Max memory, Threads, Temp compression level, Write index, Temp directories) and the trailing === Summary === block.
  • commands/sort.rs Sort::verify config snapshot (Input, Expected order, Cell tag) and the trailing === Verification Summary === block.
  • fgumi-sort/src/external.rs final === Sort Phase Timing === report and the two Wrote BAM index: … outcome events.

Demoted to debug (algorithm-internal)

  • Starting Sort / Starting Sort Verification banners (the config snapshot already announces the operation).
  • Auto memory: using … lines adjacent to the memory-fallback warn!s (they read as debug context for the warning, not standalone events).
  • Per-phase markers (Phase 1: …, Phase 2: Merging N chunks …, Consolidating N temp files …, Consolidation complete …).
  • Algorithm-layer startup duplicates (Starting raw-bytes sort, Memory limit, Threads) that duplicate the header config block at a different layer.
  • Algorithm-choice noise (All records fit in memory …, Using queryname sort with X comparator).
  • Intermediate progress already covered by the summary (Read N records total, Sort complete: N records processed).
  • K-way merge internals (Starting k-way merge …, Merge complete: 0 records merged, Merging from N sources …, Merge thread budget …, Pool-integrated merge: …, Starting parallel/buffered parallel merge of N chunks).
  • Indexing enabled: … pre-stage announcement (the final Wrote BAM index: … stays at info).
  • async sort reader enabled: … (the user passed --async-reader; the algorithm-layer confirmation is debug detail).
  • All four memory_probe.rs info! samples and the matching log_enabled!(target, Level::Info) gate, which is now Level::Debug so the cheap-path short-circuit still works at the new level.
  • Both worker_pool.rs info! sites (Pool stats: …, per-line {line} forwarder).
  • Pre-existing comment in memory_probe.rs that documented the gate as Info/RUST_LOG=…=info was updated to Debug/…=debug.

Compatibility

The fgumi CLI's -v flag already jumps info → debug, so anyone who used it for "extra detail" keeps the same observable behavior; only the default level becomes quieter. Log lines are not a documented API surface, but anyone scraping stdout/stderr for the demoted phrases will see fewer of them at the default level.

Out of scope

  • No changes to warn!/error!/debug! calls.
  • No new CLI flags (existing -v debug toggle is the escape hatch).
  • No format changes (env_logger default keeps emitting [<ts> <LEVEL> <module>] <msg>).

Test plan

  • cargo build --release (workspace)
  • cargo nextest run -p fgumi-sort — 396/396 pass
  • cargo nextest run -E 'test(/sort/)' — 56/56 pass
  • cargo ci-fmt
  • cargo ci-lint
  • cargo ci-tag-literals
  • CI green

Closes #364

@nh13
nh13 temporarily deployed to github-actions May 22, 2026 22:52 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented May 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 65678c49-daf3-4836-acb5-1963718e4b6d

📥 Commits

Reviewing files that changed from the base of the PR and between 71b82b2 and e1ebd5c.

📒 Files selected for processing (5)
  • crates/fgumi-sort/src/external.rs
  • crates/fgumi-sort/src/memory_probe.rs
  • crates/fgumi-sort/src/pipeline.rs
  • crates/fgumi-sort/src/worker_pool.rs
  • src/lib/commands/sort.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/fgumi-sort/src/external.rs

📝 Walkthrough

Walkthrough

This PR systematically demotes algorithm-internal logging from info! to debug! across the sort pipeline. Changes span the sort command entry point, memory probe instrumentation, worker pool and pipeline infrastructure, and the raw-bytes sort execution engine. Diagnostic messages around memory resolution, sort initialization, per-phase progress, in-memory optimization paths, consolidation, k-way merges, and worker statistics are lowered to debug level. Public APIs and signatures are unchanged; only verbosity is adjusted.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: demoting algorithm-internal info! logs to debug level in the sort module.
Description check ✅ Passed The description thoroughly explains the rationale, scope, and specific changes, directly relating to the log-level demotion changeset.
Linked Issues check ✅ Passed All key objectives from issue #364 are met: info logs kept for config snapshots and summaries, algorithm-internal logs demoted to debug, no warn/error/format changes, and -v flag preserves verbose behavior.
Out of Scope Changes check ✅ Passed All changes are directly scoped to log-level demotion across the specified modules; no unrelated functional logic, API changes, or feature additions are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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/issue-364-sort-log-levels

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

@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 (1)
crates/fgumi-sort/src/memory_probe.rs (1)

52-55: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix stale log-level guidance for memory probe target.

This comment still says RUST_LOG=fgumi_lib::sort::memory_probe=info, but probe logging now gates on debug. Update it to ...=debug to match enabled().

🤖 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 `@crates/fgumi-sort/src/memory_probe.rs` around lines 52 - 55, The comment in
the memory probe module still suggests using
`RUST_LOG=fgumi_lib::sort::memory_probe=info` but the probe logging is gated at
debug via the `enabled()` check; update the comment string to
`RUST_LOG=fgumi_lib::sort::memory_probe=debug` so the guidance matches the
actual behavior (refer to the `memory_probe` module comment and the `enabled()`
call that controls logging).
🤖 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 `@crates/fgumi-sort/src/memory_probe.rs`:
- Around line 52-55: The comment in the memory probe module still suggests using
`RUST_LOG=fgumi_lib::sort::memory_probe=info` but the probe logging is gated at
debug via the `enabled()` check; update the comment string to
`RUST_LOG=fgumi_lib::sort::memory_probe=debug` so the guidance matches the
actual behavior (refer to the `memory_probe` module comment and the `enabled()`
call that controls logging).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d1ca1cc6-e922-4656-8163-5bda473a96a5

📥 Commits

Reviewing files that changed from the base of the PR and between d148595 and 71b82b2.

📒 Files selected for processing (5)
  • crates/fgumi-sort/src/external.rs
  • crates/fgumi-sort/src/memory_probe.rs
  • crates/fgumi-sort/src/pipeline.rs
  • crates/fgumi-sort/src/worker_pool.rs
  • src/lib/commands/sort.rs

@codecov

codecov Bot commented May 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.89%. Comparing base (d148595) to head (e1ebd5c).

Files with missing lines Patch % Lines
src/lib/commands/sort.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #367      +/-   ##
==========================================
- Coverage   90.95%   90.89%   -0.06%     
==========================================
  Files          78       78              
  Lines       51101    51101              
==========================================
- Hits        46480    46450      -30     
- Misses       4621     4651      +30     

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

The sort engine emitted ~80 info! lines at the default log level, mixing
user-relevant "what ran" output (config snapshot, summary, phase-timing
report) with algorithm-internal chatter (per-phase markers, in-memory
fast-path decisions, k-way merge thread budgets, memory-probe samples,
worker-pool stats). Downstream library consumers worked around the
volume by raising their own default filter (see fg-labs/mako#5); this
fixes the cause instead.

Split the existing info! sites into two buckets:

Kept at info (user-visible "what ran"):
- commands/sort.rs Sort::execute config snapshot (Input, Output, Sort
  order, Cell tag, Max memory, Threads, Temp compression level, Write
  index, Temp directories) and the trailing Summary block.
- commands/sort.rs Sort::verify config snapshot (Input, Expected order,
  Cell tag) and the trailing Verification Summary block.
- fgumi-sort/src/external.rs final Sort Phase Timing report and the two
  "Wrote BAM index" outcome events.

Demoted to debug (algorithm-internal):
- "Starting Sort" / "Starting Sort Verification" banners (the config
  snapshot already announces the operation).
- "Auto memory: using …" lines adjacent to the memory-fallback warn!s
  (they read as debug context for the warning, not standalone events).
- Per-phase markers ("Phase 1: …", "Phase 2: Merging N chunks …",
  "Consolidating N temp files …", "Consolidation complete …").
- Algorithm-layer startup duplicates ("Starting raw-bytes sort",
  "Memory limit", "Threads") that duplicate the header config block at
  a different layer.
- Algorithm-choice noise ("All records fit in memory …",
  "Using queryname sort with X comparator").
- Intermediate progress already covered by the summary ("Read N records
  total", "Sort complete: N records processed").
- K-way merge internals ("Starting k-way merge …", "Merge complete: 0
  records merged", "Merging from N sources …", "Merge thread budget …",
  "Pool-integrated merge: …", "Starting parallel/buffered parallel
  merge of N chunks").
- "Indexing enabled: …" pre-stage announcement (the final "Wrote BAM
  index: …" stays at info).
- "async sort reader enabled: …" (the user passed --async-reader; the
  algorithm-layer confirmation is debug detail).
- All four memory_probe.rs info! samples and the matching
  log_enabled!(target, Level::Info) gate, which is now Level::Debug so
  the cheap-path short-circuit still works at the new level.
- Both worker_pool.rs info! sites ("Pool stats: …", per-line "{line}"
  forwarder).

The fgumi CLI's -v flag already jumps info -> debug, so anyone who used
it for "extra detail" keeps the same observable behavior; only the
default level becomes quieter.

Closes #364
@nh13
nh13 force-pushed the nh/issue-364-sort-log-levels branch from 71b82b2 to e1ebd5c Compare May 24, 2026 19:49
@nh13
nh13 temporarily deployed to github-actions May 24, 2026 19:49 — with GitHub Actions Inactive
@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13

nh13 commented May 24, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 24, 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.

@nh13
nh13 merged commit a49e36f into main May 25, 2026
8 of 10 checks passed
@nh13
nh13 deleted the nh/issue-364-sort-log-levels branch May 25, 2026 17:20
@nh13 nh13 mentioned this pull request May 25, 2026

This branch was previously deployed

1 inactive deployment
github-actions — e1ebd5c3 Deployed May 24, 2026 by nh13 via coverage #1529
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.

polish(sort): demote algorithm-internal info! logs to debug; keep config + summary at info

1 participant