Batch reading content files to prevent too many open files
error
#12079
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should help prevent Node from keeping too many files open at one time. The batching limit is still pretty high (up to 500 files at one time) and we probably have some room to reduce it but we can look into doing that in the future if we end up needing to.
Now, this implementation isn't technically as efficient as it could be. An asynchronous queue could be used to process all files while keeping 500 reads in flight at any given time until there are fewer than 500 files left to process. The implementation for this would probably be more complexity than necessary. So this simple batching solution should suffice for now.
Fixes #12069