Skip to content

module: cache stat() results more aggressively#4575

Closed
bnoordhuis wants to merge 4 commits intonodejs:masterfrom
bnoordhuis:require-perf
Closed

module: cache stat() results more aggressively#4575
bnoordhuis wants to merge 4 commits intonodejs:masterfrom
bnoordhuis:require-perf

Conversation

@bnoordhuis
Copy link
Member

Reduce the number of stat() system calls that require() makes by caching
the results more aggressively.

To avoid unbounded growth without implementing a LRU cache, scope the
cache to the lifetime of the first call to require(). Recursive calls
(i.e. require() calls in the included code) transparently profit from
the cache.

The benchmarked application is the loopback-sample-app[0] and it sees
the number of stat calls at start-up go down by 40%, from 4736 to 2810.

[0] https://github.com/strongloop/loopback-sample-app

CI: https://ci.nodejs.org/job/node-test-pull-request/1160/

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module Issues and PRs related to the module subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants