Skip to content

utilities always open and parse translation files, even when they're not needed #9103

@andreacorbellini

Description

@andreacorbellini

When tracing (via strace) the uutils coreutils, I've noticed that they always open and fully read the translation files, for example:

$ strace -e trace=open,openat,read -- target/debug/cat /dev/null
...
openat(AT_FDCWD, "/home/andrea/src/coreutils/src/uucore/locales/en-US.ftl", O_RDONLY|O_CLOEXEC) = 3
read(3, "# Common strings shared across a"..., 2553) = 2553
read(3, "", 32)                         = 0
openat(AT_FDCWD, "/home/andrea/src/coreutils/src/uucore/../uu/cat/locales/en-US.ftl", O_RDONLY|O_CLOEXEC) = 3
read(3, "cat-about = Concatenate FILE(s),"..., 965) = 965
read(3, "", 32)                         = 0
openat(AT_FDCWD, "/home/andrea/src/coreutils/src/uucore/locales/en-US.ftl", O_RDONLY|O_CLOEXEC) = 3
read(3, "# Common strings shared across a"..., 2553) = 2553
read(3, "", 32)                         = 0
openat(AT_FDCWD, "/home/andrea/src/coreutils/src/uucore/../uu/cat/locales/en-US.ftl", O_RDONLY|O_CLOEXEC) = 3
read(3, "cat-about = Concatenate FILE(s),"..., 965) = 965
read(3, "", 32)                         = 0
openat(AT_FDCWD, "/dev/null", O_RDONLY|O_CLOEXEC) = 3
read(3, "", 65536)                      = 0
+++ exited with 0 +++

In release mode, it seems like the tools can't generate the correct path (this happens both when building using cargo run --release from a fresh checkout, and also with the version of coreutils shipped with Ubuntu 25.10), but that's a separate problem from the one in this bug report:

$ strace -e trace=open,openat,read -- target/release/cat /dev/null
...
openat(AT_FDCWD, "/home/andrea/src/coreutils/target/release/cat/en-US.ftl", O_RDONLY|O_CLOEXEC) = -1 ENOTDIR (Not a directory)
openat(AT_FDCWD, "/home/andrea/src/coreutils/target/release/cat/en-US.ftl", O_RDONLY|O_CLOEXEC) = -1 ENOTDIR (Not a directory)
openat(AT_FDCWD, "/dev/null", O_RDONLY|O_CLOEXEC) = 3
read(3, "", 65536)                      = 0
+++ exited with 0 +++

In the majority of the cases however, the utilities don't need any of these messages: most utilities in fact won't ever print a message when used correctly. Utilities only print messages when (1) the user specifies --help or similar, or (2) an error has occurred. For most scripts, these two scenarios are relatively rare. I believe that implementing a "lazy loading" strategy for translation would give a significant performance boost for all utilities.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions