-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Parcel MemoryFS significantly slower than default config (importing & large files) #9413
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
Labels
Comments
Some rust-based operations are optimized to access the FS directly if possible (= no memory fs):
Apart from that, we mostly use the MemoryFS for the tests. So there might be some potential for optimization. |
/unstale |
/unstale |
/unstale |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
🐛 bug report
When implementing an in-memory file system for Parcel (as per https://parceljs.org/features/parcel-api/#file-system), Parcel builds become significantly slower than the default configuration, even when caching is disabled to make for a fair comparison. There is a worked example in a repo below; I've attempted to follow the documentation as much as possible (noting the documentation needs fixing as per #9050 (comment)).
It appears that the issue relates to the use of
import
, which may in turn be related to the module loader or else file access under the hood. If an empty or basic file (e.g.console.log('foobar')
) is built without anyimport
s, then the in-memory implementation is vastly quicker (177ms vs 345ms). However, with eachimport
, the in-memory implementation gets slower and slower. In the example below, just 1 import from a plugin from a library called amCharts takes 4x longer (7.3s vs 1.8s) in memory compared to the default.As I mention below though, the issue isn't isolated to this one library. Mocking out a single JavaScript file full of noop lines of
1;
, the default implementation is quicker than usingMemoryFS
.🎛 Configuration (.babelrc, package.json, cli command)
See https://gist.github.com/davidjb/1f3c090b7bae52fecc0a6eac57e32db2 for a worked example.
To run:
It boils down to:
running a lot quicker than:
🤔 Expected Behavior
Ideally, the in-memory implementation would be faster, otherwise it negates its reason for being. Otherwise, if there are situations where the
MemoryFS
implementation is known to be slower, these should be documented so it's clear whenMemoryFS
is a better choice.😯 Current Behavior
That said, this is time to first build in a cold environment. Once having built initially and bundler/workers/FS are already in existence, a re-build is faster on the in-memory implementation by a measurable amount compared to the defaults (e.g. 650ms vs 750ms).
💁 Possible Solution
🔦 Context
I'm attempting to speed up builds by using memory compared to using the file system.
💻 Code Sample
See https://gist.github.com/davidjb/1f3c090b7bae52fecc0a6eac57e32db2
As a more contrived test, by replacing
a.js
with just a lot of lines like so:1;
, the default configuration's build time increases somewhat linearly, but the in-memory implementation is consistently worse aftera.js
reaches a few 1000 lines of code, and gets progressively worse. For a 10MB .js file full of lines of1;
, the results look this:🌍 Your Environment
The text was updated successfully, but these errors were encountered: