Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
cache bodies to avoid reparsing #186
ljharb left a comment
What's the actual performance difference here?
Parsing JSON is very fast, and if any changes are going to be made solely because of performance, they'll need extensive benchmarks.
@ljharb I added some instrumentation to the PR and ran the following script in the airbnb repo:
This resolves a path 10k times, which seems to be approximately on the order of number of modules in our webpack build.
I also made a small change to hash the contents instead of using the raw file contents as the cache key. The cached version is 6x faster. Complexity probably scales with package.json size (we have a 48kb package json file).
I ran some more tests using the Benchmark npm module: