Skip to content

sed: restart R command readers for separate input files - #666

Open
Himanshu-singh04 wants to merge 3 commits into
uutils:mainfrom
Himanshu-singh04:fix/653-restart-named-readers
Open

Himanshu-singh04 wants to merge 3 commits into
uutils:mainfrom
Himanshu-singh04:fix/653-restart-named-readers

Conversation

@Himanshu-singh04

Copy link
Copy Markdown
Contributor

Fixes #653.

Restart shared R command readers when processing each separate input file. This gives each file the first line of the named file under -s and -i, while retaining the existing shared cursor for ordinary processing.

Add an integration regression covering both -s output and -i file contents. It failed before the fix and passes afterward.

Validation: cargo test --offline --quiet; cargo fmt --check; cargo clippy --offline --all-targets -- -D warnings; git diff --check.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.43%. Comparing base (6ae5577) to head (d6befd4).
⚠️ Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
src/sed/processor.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #666      +/-   ##
==========================================
+ Coverage   95.25%   95.43%   +0.18%     
==========================================
  Files          14       14              
  Lines        7500     7735     +235     
  Branches      442      460      +18     
==========================================
+ Hits         7144     7382     +238     
+ Misses        355      352       -3     
  Partials        1        1              
Flag Coverage Δ
macos_latest 96.89% <83.33%> (+0.14%) ⬆️
ubuntu_latest 96.82% <83.33%> (+0.14%) ⬆️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Comment thread src/sed/processor.rs Outdated
context.line_number = 0;
reset_latched_address_ranges(&mut context.range_commands);

if context.separate {

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 if needed? on the first file the readers are still unopened anyway

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I removed the unnecessary first-file check in dc25158; the named readers now reset directly under the existing per-file reset guard.

@codspeed

codspeed Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.86%

2 warnings

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark with a significant change ran in a different software environment

Its base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the change might come from this difference rather than from the code. Open the benchmark to see what changed.

See affected benchmarks

❌ 1 regressed benchmark
✅ 10 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ access_log_translit 953.6 ms 991.9 ms -3.86%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Himanshu-singh04:fix/653-restart-named-readers (d6befd4) with main (70960fc)

Open in CodSpeed

Comment thread src/sed/processor.rs Outdated
context.line_number = 0;
reset_latched_address_ranges(&mut context.range_commands);

for reader in context.named_readers.values() {

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.

could you please rename it? it shadows reader above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed the loop variable to named_reader in d6befd4 so it no longer shadows the input reader. The focused R-reader test and formatting check pass.

@Himanshu-singh04

Copy link
Copy Markdown
Contributor Author

I checked the two remaining failed checks. The focused read_one_line_restarts_for_separate_input_files test and cargo fmt --all -- --check pass locally.

Codecov reports one uncovered changed line: the for named_reader header at src/sed/processor.rs:999. Its report marks the reset() call inside that loop as covered, so I can't identify an untested behavior from this report alone. I haven't reproduced CI's coverage instrumentation locally.

CodSpeed reports the same access_log_translit benchmark and identical 953.6 ms → 991.9 ms (-3.86%) figures on #663, #665, and this PR. Its report also flags different hardware and software environments for this comparison. I haven't verified a performance regression on matched runners, and this PR's new reset runs at file setup rather than in transliteration.

Would you prefer a matched-environment rerun or an acknowledgement of the CodSpeed result? For the Codecov line, is there a preferred way to handle coverage mapping when the loop body is already reported as covered? I don't want to add a redundant test or alter the working loop just to change the report.

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.

sed - with -s or -i, the file read by R is not restarted for each input file

2 participants