Skip to content

more: reduce memory usage a bit#6399

Merged
sylvestre merged 3 commits intouutils:mainfrom
tertsdiepraam:more-mem-usage
Dec 3, 2024
Merged

more: reduce memory usage a bit#6399
sylvestre merged 3 commits intouutils:mainfrom
tertsdiepraam:more-mem-usage

Conversation

@tertsdiepraam
Copy link
Collaborator

Work towards (but definitely does not close): #6397

This just reduces the number of strings that are allocated. We're still at 5x the file though. Even though technically, we don't need to keep the file in memory at all.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@tertsdiepraam tertsdiepraam force-pushed the more-mem-usage branch 2 times, most recently from 109d4ec to ce29ac5 Compare May 13, 2024 18:47
@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

Copy link
Collaborator

@BenWiederhake BenWiederhake left a comment

Choose a reason for hiding this comment

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

LGTM! Can you do something like src/uu/shuf/BENCHMARKING.md and write down how exactly you measure our progress?

For this PR it's obvious that this should reduce memory consumption, so it should be trivial to prove it. For future PRs, I'm afraid that an "optimization" worsens our memory consumption and we don't notice it.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)

@tertsdiepraam
Copy link
Collaborator Author

tertsdiepraam commented May 14, 2024

Changes since last push:

  • Changed some u16 to usize to reduce conversions
  • Made the pattern search take &str instead of Option

Nothing to improve performance, but cleans up a bit.

@sylvestre
Copy link
Contributor

Clippy is unhappy:


error: useless conversion to the same type: `usize`
   --> src/uu/more/src/more.rs:472:29
    |
472 |             .saturating_add(self.content_rows.into())
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `self.content_rows`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `-D clippy::useless-conversion` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::useless_conversion)]`

error: useless conversion to the same type: `usize`
   --> src/uu/more/src/more.rs:488:58
    |
488 |         self.upper_mark = self.upper_mark.saturating_add(self.content_rows.into());
    |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `self.content_rows`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

error: useless conversion to the same type: `usize`
   --> src/uu/more/src/more.rs:527:49
    |
527 |             .min(self.upper_mark.saturating_add(self.content_rows.into()));
    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `self.content_rows`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

@sylvestre
Copy link
Contributor

@tertsdiepraam ping ? :)

@github-actions
Copy link

github-actions bot commented Dec 2, 2024

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Dec 3, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

@sylvestre sylvestre merged commit 17d4e4f into uutils:main Dec 3, 2024
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.

3 participants