Skip to content
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

Reduce micromatch overhead in jest-haste-map HasteFS #10132

Closed
wants to merge 1 commit into from

Commits on Jun 5, 2020

  1. Reduce micromatch overhead in jest-haste-map HasteFS

    I was profiling some Jest runs at Airbnb and noticed that on my
    MacBook Pro, we can spend over 30 seconds after running Jest with code
    coverage as the coverage reporter adds all of the untested files. I
    believe that this will grow as the size of the codebase increases.
    
    Looking at the call stacks, it appears to be calling micromatch
    repeatedly, which calls picomatch, which builds a regex out of the
    globs. It seems that the parsing and regex building also triggers the
    garbage collector frequently.
    
    Since this is in a tight loop and the globs won't change between
    checks, we can greatly improve the performance here by using
    micromatch.matcher.
    
    This optimization reduces the block of time here from about 30s to
    about 10s. The aggregated total time of coverage reporter's
    onRunComplete goes from 23s to 600ms.
    lencioni committed Jun 5, 2020
    Configuration menu
    Copy the full SHA
    4fb53b1 View commit details
    Browse the repository at this point in the history