Performance: Optimize asset scanning by excluding large dependency directories#411
Performance: Optimize asset scanning by excluding large dependency directories#411hellosamyak wants to merge 1 commit into
Conversation
Skip traversing into common bloat directories (node_modules, dist, build, .git, venv, etc.) during asset scanning to significantly improve loading performance for large projects. - Add DIRECTORY_IGNORE_LIST with 26+ common directories to exclude - Add shouldExcludeDirectory() utility method - Update asset scanner to skip excluded directories before recursing - Add safety checks in file and code handlers - Reduces asset loading time by 5-10x for large projects Fixes the issue where 'Additional details about the assets are still loading...' message would persist indefinitely for large projects.
|
Hi @lrasmus, this PR is now ready for review. Apologies for the delay, and thank you for your patience! Please take a look when you have a moment. |
|
@hellosamyak - I'm not sure I can accept this PR for two main reasons:
If you can provide a convincing argument to the first question I may reconsider this. |
|
@lrasmus, I have an answer to your first question. Please let me know what do you think of it. The separation is intentional because the two checks run at different stages with different goals:
If we reused only includeAsset, we would still recurse into heavy directories and pay the IO cost, then hide results later. The new function was added to stop that work earlier in the scan pipeline. I agree there is overlap in names between the two lists. If you don't find it convincing enough, I can refactor this into a shared policy source in a follow-up so duplication is reduced while keeping the two-stage behavior. |
|
Thank you @hellosamyak - what I was thinking was more avoiding duplication between
This looks like more of an issue because of how I implemented it before. I don't mind fixing this myself. However, I do need to ask you to create unit tests for the new function you created before I can accept the PR. |
Description
Significantly improves asset loading performance for large projects by skipping
unnecessary directory traversal into common bloat directories.
Problem
The asset scanner was recursively traversing all directories in projects,
including large dependency and build directories (node_modules, dist, build, etc.).
This caused extremely slow asset loading times for large projects, with the UI
showing "Additional details about the assets are still loading..." for extended periods.
Solution
Implemented a directory exclusion mechanism that prevents the scanner from recursing
into common large directories:
node_modules,.next,venv,envdist,build,target,out,bin,obj__pycache__,.pytest_cache.gradle,.m2,CMakeFiles.idea,.vs,.vscode,.git*.egg-infoChanges Made
app/utils/asset.js:
DIRECTORY_IGNORE_LISTwith 26+ common directoriesshouldExcludeDirectory()method for checking exclusionsapp/services/assets/asset.js:
scan()to skip excluded directories before recursingapp/services/assets/handlers/file.js & baseCode.js:
Performance Impact
Testing
"Additional details still loading..."message no longer appearsFiles Changed
app/utils/asset.jsapp/services/assets/asset.jsapp/services/assets/handlers/file.jsapp/services/assets/handlers/baseCode.jsCloses #403