babel icon indicating copy to clipboard operation
babel copied to clipboard

Improve extract performance via ignoring directory early during os.walk

Open stkao05 opened this issue 5 years ago • 4 comments
trafficstars

Currently, the extraction code will do an os.walk to perform a deep file search. However, this file exploration could be very slow when there were directories that were deep and contain many files. Even if you have specified some directories to be ignored in the mapping file, the os.walk would explore these directories.

The PR improves the extract process performance via making sure to skip exploring those ignore directory early during os.walk.

stkao05 avatar Feb 11 '20 07:02 stkao05

Real-life scenario I have experience

When you are working with front-end, typically you would have a node_modules directory in your codebase which contains source codes of all 3rd party lib (similar to Python's /site-packages/), and this directory typically is very large.

stkao05 avatar Feb 11 '20 07:02 stkao05

Codecov Report

Merging #694 into master will decrease coverage by 0.03%. The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #694      +/-   ##
==========================================
- Coverage   90.97%   90.94%   -0.04%     
==========================================
  Files          24       24              
  Lines        4176     4184       +8     
==========================================
+ Hits         3799     3805       +6     
- Misses        377      379       +2
Impacted Files Coverage Δ
babel/messages/extract.py 94.38% <77.77%> (-0.56%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0cfa69e...6ada6ee. Read the comment docs.

codecov-io avatar Feb 11 '20 07:02 codecov-io

Ping @akx

stkao05 avatar May 21 '20 13:05 stkao05

Hi @stkao05 – #832 landed today, so this would need to be rebased :)

akx avatar Jan 28 '22 15:01 akx