Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more: reduce memory usage a bit #6399

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tertsdiepraam
Copy link
Member

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.

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

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.

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
Member 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
Sponsor 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
Sponsor Contributor

@tertsdiepraam ping ? :)

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.

None yet

3 participants