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

module: skip directories known not to exist #9196

Merged
merged 3 commits into from
Oct 24, 2016

Commits on Oct 24, 2016

  1. test: add more module loader test coverage

    Verify that a package.json without a .main property loads index.js.
    
    PR-URL: nodejs#9196
    Reviewed-By: Brian White <mscdex@mscdex.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Evan Lucas <evanlucas@me.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    bnoordhuis committed Oct 24, 2016
    Configuration menu
    Copy the full SHA
    8fca311 View commit details
    Browse the repository at this point in the history
  2. doc: add performance warning to require.extensions

    Discourage using require.extensions because it slows down the module
    loader.  The number of file system operations that the module system
    has to perform in order to resolve a `require(...)` statement to a
    filename is proportional to the number of registered extensions.
    
    PR-URL: nodejs#9196
    Reviewed-By: Brian White <mscdex@mscdex.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Evan Lucas <evanlucas@me.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    bnoordhuis committed Oct 24, 2016
    Configuration menu
    Copy the full SHA
    df29d9f View commit details
    Browse the repository at this point in the history
  3. module: skip directories known not to exist

    There is no point in trying to search for files in a directory that
    we know does not exist, so stop doing that.
    
    Reduces the total number of stat(2) calls and the number of stat(2)
    misses on a medium-sized application by about 21% and 29% respectively.
    
    Reduces the total number of package.json open(2) calls and the number
    of open(2) misses by about 21% and 93% (!) respectively.
    
    Before:
    
        % time     seconds  usecs/call     calls    errors syscall
        ------ ----------- ----------- --------- --------- ----------------
         50.93    0.178419          38      4702           lstat
         29.08    0.101875          36      2800      2010 stat
         11.36    0.039796          43       932       215 open
          5.39    0.018897          34       550           fstat
          3.24    0.011337          34       336           pread
        ------ ----------- ----------- --------- --------- ----------------
        100.00    0.350324                  9320      2225 total
    
    After:
    
        % time     seconds  usecs/call     calls    errors syscall
        ------ ----------- ----------- --------- --------- ----------------
         55.49    0.176638          38      4702           lstat
         24.76    0.078826          35      2225      1435 stat
         10.19    0.032434          44       733        16 open
          6.19    0.019719          36       550           fstat
          3.37    0.010723          32       336           pread
        ------ ----------- ----------- --------- --------- ----------------
        100.00    0.318340                  8546      1451 total
    
    PR-URL: nodejs#9196
    Reviewed-By: Brian White <mscdex@mscdex.net>
    Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
    Reviewed-By: Evan Lucas <evanlucas@me.com>
    Reviewed-By: Michaël Zasso <targos@protonmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>
    bnoordhuis committed Oct 24, 2016
    Configuration menu
    Copy the full SHA
    678c094 View commit details
    Browse the repository at this point in the history