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

When starting files in current directory are scanned recursively #40356

Closed
gileri opened this issue May 8, 2020 · 0 comments · Fixed by #40377
Closed

When starting files in current directory are scanned recursively #40356

gileri opened this issue May 8, 2020 · 0 comments · Fixed by #40377
Labels
Code: Performance Performance boosting code (CPU, memory, etc.)

Comments

@gileri
Copy link
Contributor

gileri commented May 8, 2020

Describe the bug

Since #40056 the current working directory is scanned for translations, it's thrashing the disk and slowing down launch. It should only scan the 'lang' subdirectory.

Steps To Reproduce

  1. change directory (cd) to a directory with a lot of files/directories
  2. Start 'strace -o output.log cataclysm'
  3. The current directory is scanned recursively before displaying the menu
  4. Observe lots of stat and related calls in output.log

Expected behavior

Only the 'lang' folder should be scanned recursively.

Versions and configuration

- OS: Linux (Arch up-to-date)
- Game Version: 0.E-1929-gfdb8229269 [64-bit]
- Graphics Version: Curses
- Game Language: System language []
- Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food]
]

Additional context

What happens is that PATH_INFO::langdir() is called at include-time, before PATH_INFO::set_standard_filenames() is called. That means that langdir_value = "", which means that the CWD will be scanned instead of the correct lang directory.

This is not really problematic if the current working directory is the game root (i.e. via cataclysm-launcher), but the game used to start fine directly from the binary and I think this is not expected behavior.

Problematic strace output

This recursive scan shouldn't happen (strace output) :

[...]
openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0711, st_size=4770, ...}) = 0
getdents64(3, /* 228 entries */, 32768) = 7800
getcwd("/home/user", 4096)              = 11
lstat("/home/user/.byobu", {st_mode=S_IFLNK|0777, st_size=22, ...}) = 0
readlink("/home/user/.byobu", ".dotfiles/byobu/.byobu", 4095) = 22
lstat("/home/user/.dotfiles", {st_mode=S_IFDIR|0755, st_size=92, ...}) = 0
lstat("/home/user/.dotfiles/byobu", {st_mode=S_IFDIR|0755, st_size=12, ...}) = 0
lstat("/home/user/.dotfiles/byobu/.byobu", {st_mode=S_IFDIR|0755, st_size=334, ...}) = 0
stat("/home/user/.dotfiles/byobu/.byobu", {st_mode=S_IFDIR|0755, st_size=334, ...}) = 0
getcwd("/home/user", 4096)              = 11
lstat("/home/user/.face.icon", {st_mode=S_IFLNK|0777, st_size=16, ...}) = 0
readlink("/home/user/.face.icon", "/home/user/.face", 4095) = 16
lstat("/home", {st_mode=S_IFDIR|0755, st_size=8, ...}) = 0
lstat("/home/user", {st_mode=S_IFDIR|0711, st_size=4770, ...}) = 0
lstat("/home/user/.face", {st_mode=S_IFREG|0644, st_size=67832, ...}) = 0
stat("/home/user/.face", {st_mode=S_IFREG|0644, st_size=67832, ...}) = 0
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Performance Performance boosting code (CPU, memory, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants