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
Heavy memory usage #5072
Comments
We're definitely working on addressing this, it's currently one of our top priorities. We're mainly focusing on stability and performance at this point, so we can release a stable version of Parcel 2 I'm able to reproduce this and will figure out why this is happening exactly, will report back in this issue. |
I've been able to mitigate this problem by passing |
I have (it seems) exactly the same issue with |
@roman-petrov You should try using Parcel 2 with the workaround literally on top of your comment.
|
@Banou26 , thank you. I will try to upgrade to Parcel 2 and use |
This comment has been minimized.
This comment has been minimized.
They aren't. Node's WorkerThreads are used when available (you could set Could you check what parcel/packages/core/workers/src/cpuCount.js Lines 49 to 52 in e183e32
PARCEL_WORKERS value on Windows.
I think we should cap that count to 4. |
Also, could you test this with a bigger project (that takes something like 30s) to determine whether this is the overhead from starting the workers itself. |
It returns 16 which is correct, but I don't think you should spawn all the 16 threads due to its overhead. I need to do more testing, but it seems that more than 4 is destructive. |
(It should return 8 because that function is supposed to determine the number of real cores and not threads.) |
I fixed it in #5617 |
I don't think hard coding to 4 is a good idea. It doesn't make sense to me that there is a limit regardless of hardware. We currently base it on the number of available cores, which seems to make sense in regards to the amount of parallelism that is possible. If it slows down after a certain number, there must be a bottleneck somewhere that we can potentially solve. I had looked into this somewhat before but couldn't determine what the problem was. Maybe someone will have better luck. |
Wrong benchmarkRunning the benchmark using Parcel 2.0.0-nightly.520 gives another result. Using workers is slower altogether! No matter how many.
Ran on solid-simple-table. The command was
Parallelism is only helpful when the overhead is low. That's when parallelism can have performance benefits. |
In your 300ms example, no workers might be faster (btw you can also do But if you build takes more than a few seconds, it is beneficial. |
This comment has been minimized.
This comment has been minimized.
OK, here is the correct benchmark. Still, increasing the number of workers has no effect.
Ran on solid-simple-table. The command was |
Interesting. That indicates that there is some kind of bug to me. More workers definitely shouldn't be slower. Can you run with the |
Here is the profile: What I see is that in the Node file system a lot of This load function for example is calling sync functions
BTW, the profiler seems to have issues in writing the files to the disk. I have to run the profiler a couple of times (with clean in between) to get one working. It exits with a crash code.
|
Based on the profile I see a couple things:
That said, one thing that could explain workers not being faster for some cases is if a majority of the build time is spent in minification of one large bundle, for example. This is not parallelizable, so we'd expect the times to be similar in this case. In your profile, transformation only accounts for 1.4s of the total build time, whereas minification accounts for 11s. During that time, only a single thread will be active. |
Results I get with your project: macOS (4 core i5), last number is wall time
Windows 10 (much older 4 core i5):
not sure why it's slower in your case. Tested with Yarn & pnpm on macOS and Yarn on Windows. |
No. The worker number was set to 8.
I have only one small less file! I am not sure what minification it is doing there!
Yes. The Disk IO seems the bottleneck here. It is irrelevant to the CPU. |
I used Powershell for timing. Parcel itself reports almost 4 seconds less!
|
Just to add some extra data, on my Ryzen 7 4800H with 16 GB of RAM, running parcel@2.0.0-nightly.535 on node v15.6.0 takes:
I did the 3 workers test after testing with 2, 4 and 8 just to check for any potential sweet spot. I noticed that rebuilding with a non-empty dist folder (that is, serve, kill, then serve again without cleaning) is slower: 35.56s, with 2383M resident memory. However, parcel memory usage is as inconsistent as it gets, so I attribute it to sheer luck. |
One interesting thing we haven't explored yet is whether this is specific to worker threads or whether it also applies to processes. Is there a single memory limit across all threads or is it per thread? This could affect the frequency of garbage collection. Could people in this thread also run it with the |
@devongovett with 4 workers, using process backend, it takes 35.73s (albeit I have more software running simultaneously) but the resident memory usage dropped to 834M |
@aminya have you looked into why disk access on your machine is so slow? I don't think anyone else has been able to reproduce the cssnano issue. Are you running off a network drive by chance? |
My drive is a fast SSD with high bandwidth. The issue is not my hardware.
There is also the problem with not using |
Sure, I agree re require being slow. But there still exists the question why it takes 3s on your machine and milliseconds on other machines so trying to get to the bottom of it... |
Is there any update on this? |
@AndyOGo Could you share more details about your situation (and ideally a reproduction)? Do you also have many cores like some of the other commenters above? Does setting |
can confirm heavy memory usage. A basic 200 line typescript file (32K in file-size according to No special settings, config or anything. Exactly the getting-started demo, but with different typescript (typescript that tsc handles just fine). (Running fedora linux if that matters. I'm not using windows.) (It's also really hard to kill. Spawns like 20-30 node processes. Note that my system is a meager 4 core Intel Core I5 mobile. Not some sorta threadripper. No reason to have that many workers for 200 lines of typescript on such low-grade hardware) |
@Lazerbeak12345 Can you share your project (or some version of that typescript file which still causes this problem)? |
Sure https://github.com/Lazerbeak12345/pixelmanipulator/tree/v5-alpha is the closest thing - but you're going to have to remove these files (and replace them with the appropriate matching files from the getting started guide):
Another note is that you might need to remove Sorry - I had actually planned on making a separate branch to recreate this easier, but I don't have much time on my hands these days. Alternatively, as the typescript file is (currently) completely standalone, copying the content of I suspect that this might not actually be easy to recreate without hardware as old as mine though (more-or-less factory Lenovo ThinkPad T420 but with a more-or-less factory Fedora Linux 35 WS). |
Yeah, it works for me on macOS (also 4 core i5). But I'm also not sure if this is because I didn't modify your repo correctly or if it's actually caused by some hardware/OS difference. |
I'll make a branch with the specific changes made then and link it here. This might take some time. |
I'm actively working on this right now, and here's an interesting finding: If I provide |
I'm guessing this is caused by a bad entry root/project root calculation then: parcel/packages/core/core/src/resolveOptions.js Lines 52 to 53 in e294eaf
Which should get fixed by #7537 |
Alright, I've figured it out. (I actually solved it half an hour from my last post, but was offline so couldn't post this). @mischnic Your hunch was correct. Parcel seems to search for the "root" from I don't really like that that was the problem - I expected parcel to use a depth-first search for the "root," as this is the behavior of |
It is also interesting to note, however, that while this is resolved for me - it still used a ton of threads and ran out of memory. This implies that parcel might fail on huge projects. Running Also unexpected, was that |
The |
On our case, parcel was failing to build for ARM64 on a Graviton2 instance due to insane memory usage.
|
We have again the problem with memory usage, even specifying the entry point. We tried Still researching a workaround, can't build on arm64 ( |
Does really fail only on ARM64 and other archs build fine with lower memory usage? |
Our build works fine on |
🐛 bug report/question
Trying to import
ffmpeg.js
results in a process taking up 5GBs+ of RAM in a few seconds.The imported file is 10mb so i can understand it taking up a lot of ram but that much ?
This is something that has been recurring over my projects, parcel processes taking up a lot of ram.
Do you guys have any plans on reducing the memory footprint ?
The text was updated successfully, but these errors were encountered: