-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
limit number of open files #22560
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
base: main
Are you sure you want to change the base?
limit number of open files #22560
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little nervous to do this: you could end up with every running loader acquiring a single file, but then needing a second file to complete, and then being deadlocked.
It's unclear whether this is better than just failing to load. I guess so since it's less likely that users have 128 assets that also need a second file load to complete (e.g., an immediate load). Though having 128 gltfs that reference other textures isn't completely impossible.
|
Also this doesn't take into consideration multiple asset sources. This might need to be a global semaphore? |
I've added a timeout of 500ms on acquiring the semaphore, and it continues like before if not possible in that timeout, so it will never block |
I would prefer to have an actual case where this happens before adding it. I'm not a fan of global things, and apple OS + multiple asset sources + many simultaneously open files starts becoming a very specific use case |
andriyDev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be treating multiple asset sources as some exotic use case. Users often want to store data in different locations.
But whatever, I'm not gonna block on it. Could we at least add a TODO to consider making the semaphore global to work across multiple asset sources?
|
now global |
|
|
||
| #[cfg(any(target_os = "macos", target_os = "ios"))] | ||
| static OPEN_FILE_LIMITER: Semaphore = Semaphore::new(128); | ||
| #[cfg(not(any(target_os = "macos", target_os = "ios")))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows doesn't have a limit though. I'd prefer to avoid it for windows? Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hoo so it's windows that doesn't have a limit!
| #[cfg(any(target_os = "macos", target_os = "ios"))] | ||
| static OPEN_FILE_LIMITER: Semaphore = Semaphore::new(128); | ||
| #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))] | ||
| static OPEN_FILE_LIMITER: Semaphore = Semaphore::new(512); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did 512 come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on macOS it works best with the limit (256) / 2 => 128
so I did the same of linux: 1024 / 2 => 512
Added a comment about it
Objective
FileAssetReader,AssetMode::Processedcauses some assets to fail to load #14542bistroscene on macOS gives errors in the log, and some texture are randomly not loaded:Solution
Semaphoreto ensure we're not opening more than 128 files in parallelTesting
cargo run --release --package bistroworks without errors in the log