Bug 286605 - Regression since using LLVM’s strings
Summary: Regression since using LLVM’s strings
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL: https://reviews.freebsd.org/D50084
Keywords: regression
Depends on:
Blocks:
 
Reported: 2025-05-05 15:22 UTC by Olivier Cochard
Modified: 2025-05-07 12:27 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Cochard freebsd_committer freebsd_triage 2025-05-05 15:22:06 UTC
We have a memory usage regression since the migration from elftoolchain’s strings to the LLVM’s version:

It seems the LLVM’s version isn’t able to mmap while used in a pipe, so it copy ALL the file into memory.

Example:
$ dd if=/dev/urandom of=/tmp/test.file bs=1M count=1024
$ cat /tmp/test.file | strings > /dev/null &

Now with elftoolchain’s strings:
$ ps -o pid,command,vsz,rss | grep strings
53243 strings          12992  2556

And with LLVM’strings:
$ ps -o pid,command,vsz,rss | grep strings
41791 strings          5027836 3413864

And with our use-case, we are using strings on GB files (like core dump), and it is now consumming all our memory.

Peraps commit "81fa5c4a828bec9f1ead280c59c31bd423e6eeea" (llvm-strings: Install as strings when WITH_LLVM_BINUTILS=YES) should be reverted until fixed.
Comment 1 commit-hook freebsd_committer freebsd_triage 2025-05-05 19:39:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=fbd7087b0be2f327f806a85b92789a719138df8c

commit fbd7087b0be2f327f806a85b92789a719138df8c
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2025-04-30 13:35:54 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-05-05 19:38:06 +0000

    strings: Unconditionally install ELF Tool Chain's strings

    llvm-strings may consume a large amount of memory while reading the
    input file before producing any output.

    ELF Tool Chain's strings is small and lightweight, and we always install
    strings regardless of WITH_/WITHOUT_TOOLCHAIN settings (as it is useful
    in many contexts).  Return to always installing ELF Tool Chain's version
    of strings.

    This reverts commit 81fa5c4a828bec9f1ead280c59c31bd423e6eeea.
    This reverts commit 7ca3db1999cd967f9d6d7b259aa7af54aae14a5f.

    PR:             286605
    Reported by:    olivier
    Reviewed by:    olivier, brooks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D50084

 share/man/man5/src.conf.5                 | 4 +++-
 tools/build/options/WITHOUT_LLVM_BINUTILS | 2 ++
 tools/build/options/WITH_LLVM_BINUTILS    | 2 ++
 usr.bin/Makefile                          | 8 +-------
 usr.bin/clang/llvm-strings/Makefile       | 7 -------
 5 files changed, 8 insertions(+), 15 deletions(-)
Comment 2 Ed Maste freebsd_committer freebsd_triage 2025-05-07 12:27:45 UTC
Opened an upstream bug report at https://github.com/llvm/llvm-project/issues/138855. 

We've switched back to ELF Tool Chain strings now, so closing the FreeBSD-specific issue.