bevyengine / bevyengine/bevy

Bevy hot asset reloader decides to scan every file in project directory

Open
#14,903 3 comments 0 reactions 0 assignees View on GitHub
A-Assets C-Bug C-Performance S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.14.1

## Relevant system information

Linux, nixOS

## What you did

1. Use cargo-generate to make a bevy project with the [Bevy quickstart](https://github.com/TheBevyFlock/bevy_quickstart/tree/main) template
2. Add a flake.nix and a few other things to provide dependencies
3. Run the program

## What went wrong

Startup takes about ~10s on my moderately fast machine (that is, time from executable launch to window opening)
Removing the 'file_watcher' and (probably not related) 'embedded_watcher' feature cuts this down significantly (to what I would expect - maybe 1s or so)

## Additional information

I ran strace to see what could possibly take so long. A typical section of the very long output is

```
openat(AT_FDCWD, "<>/.direnv/flake-inputs/sfycwi72zfjsspidinx56ajaiffpyh17-source/pkgs/development/python-modules/gevent-socketio", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 9
fstat(9, {st_mode=S_IFDIR|0555, st_size=3, ...}) = 0
statx(AT_FDCWD, "<>/.direnv/flake-inputs/sfycwi72zfjsspidinx56ajaiffpyh17-source/pkgs/development/python-modules/gevent-socketio", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_TYPE|STATX_MODE|STATX_NLINK|STATX_UID|STATX_GID|STATX_MTIME|STATX_CTIME|STATX_INO|STATX_SIZE|STATX_BLOCKS|STATX_BTIME|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFDIR|0555, stx_size=3, ...}) = 0
getdents64(9, 0x55f146642040 /* 3 entries */, 32768) = 80
statx(AT_FDCWD, "<>/.direnv/flake-inputs/sfycwi72zfjsspidinx56ajaiffpyh17-source/pkgs/development/python-modules/gevent-socketio/default.nix", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_TYPE|STATX_MODE|STATX_NLINK|STATX_UID|STATX_GID|STATX_MTIME|STATX_CTIME|STATX_INO|STATX_SIZE|STATX_BLOCKS|STATX_BTIME|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=791, ...}) = 0
getdents64(9, 0x55f146642040 /* 0 entries */, 32768) = 0
close(9)
```

TLDR: it's crawling every file in the project directory. In this case, it's managed to find a symlink provided by the nix flake, which sends it crawling the entire Nixpkgs source, which explains part of just why it takes so long, but regardless of nix, it still also crawls ./target, which has plenty of files put there by Cargo.

I can't figure out why it would crawl the whole project directory like this. Maybe I've misconfigured something? Anyway, it should only crawl ./assets at most, and if it does a full crawl of that folder, this behaviour would still be nice to document...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.