-
Notifications
You must be signed in to change notification settings - Fork 716
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
🐛 BUG: wrangler dev --experimental-local
slows down over time and leaks memory
#2386
Comments
The issue is very easy to repro when load testing the local server with
Interestingly, I occasionally see the workerd crash with the following:
|
Could you post the script of your worker, and your |
Hey Samuel, apologies for late response. This was a simple "hello world" worker with no bindings or special config. |
Hey @IgorMinar! I've just tried to reproduce this with the latest That being said, I do still get |
I’ll retest it but it will likely take a few days before I can get around
to this. Thanks for the heads up though, looks like a good progress was
made on this upstream already.
…On Tue, Feb 21, 2023 at 7:59 AM MrBBot ***@***.***> wrote:
Hey @IgorMinar <https://github.com/IgorMinar>! I've just tried to
reproduce this with the latest ***@***.***, and I'm not seeing the
response slowdown over time anymore, even with large -n. Would you be
able to try out npx ***@***.*** dev --experimental-local? Memory usage
does creep up (not as high as you were seeing), but this might just be slow
GC, as it usually comes down after a while.
That being said, I do still get *** Received signal #10: Bus error: 10
stack: (indicating memory access out of process address space) if I try -n
10000 a few times, so there's still something strange happening here.
Notably, this also happens when you run workerd serve
samples/helloworld/config.capnp in the workerd repo, so I don't think
this is a Wrangler/Miniflare problem.
—
Reply to this email directly, view it on GitHub
<#2386 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABUZ2E4MZOY26VPFG4WUZ3WYTQ4VANCNFSM6AAAAAAS2NPN5U>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@IgorMinar were you able to confirm whether this is still a problem? |
oops.. I dropped the ball on this one. I'll retest today. My apologies. |
hey @IgorMinar! :) just bumping this -- did you have a chance to retest? |
I was not able to verify/test because I got blocked on #3007 which seems to suggest that |
Getting a similar issue on the latest wrangler. Don't know if it "slows down" but memory usage quickly goes to 10->20->30gb and it doesn't come back down unless killed. |
Can report this is still the case in Note that this does not require the wrangler server to be used at all. It will leak just by starting it. Command:
I also get this error after some time; I'm not sure if it's related to the leak.
|
I'd like to double down on this issue, as it's currently blocking our effort to use wrangler dev in a local development / integration testing environment. 3.1.0 MacOS For measurement I used
Bare minimum worker, no deps, no bindings
Observed
Did a control measurement with Service Worker format vs Module worker
The worker performs a lot better with I'll perform an experiment with emulated amd64 arch a bit later |
Hopefully this will help in some small way, but I've had issues with the slowdown and the bus 10 errors as well. Started at 3.0.1, and now on 3.1.0 on MAC Both gave me a I used this command, Command used:
I did, however, get a different error than the bus 10 error after the CLI XCode update:
For additional context, the application runs as expected on the miniflare 2.X versions. Command used with miniflare:
I hope this isn't just adding static |
I can confirm what @Cragady reported:
However:
IMO the main issue here is the slowdown and outrageous memory pressure accompanying it |
We were looking into the This appears to be limited to workerd on OS X and only for optimized builds (
The good news is that we have a stack trace and can pinpoint where the failure occurs, the bad news is that it's an optimized build and so there's only partial symbols along with registers and memory. We'll figure something out :-) With the slowdown and memory pressure issue, you can capture heap snapshots with devtools by enabling the inspector in workerd, e.g. workerd serve -i0.0.0.0 . If you open https://devtools.devprod.cloudflare.dev/js_app?ws=localhost:9229/main (or chrome://inspect) in Chrome on the dev machine, then go to the The heap looks stable across batches of 10000 requests from hey using the workerd |
The root cause of bus errors from workerd opt builds are being investigated. In the interim, use fastbuild instead. The impact of this workaround is that the uncompressed macOS arm64 binary goes from 61MB to 155MB. The compressed binary increases from 21MB to 35MB. Bug: cloudflare/workers-sdk#2386 Bug: CUSTESC-29094
Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: cloudflare/workers-sdk#2386
Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: cloudflare/workers-sdk#2386
The root cause of bus errors from workerd opt builds are being investigated. In the interim, use fastbuild instead. The impact of this workaround is that the uncompressed macOS arm64 binary goes from 61MB to 155MB. The compressed binary increases from 21MB to 35MB. Bug: cloudflare/workers-sdk#2386 Bug: CUSTESC-29094
Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: cloudflare/workers-sdk#2386
Allows running optimized builds in the vscode debugger (gdb, lldb). Bug: cloudflare/workers-sdk#2386
This reverts commit d0ac3f3. The preceding commit adding --single-threaded-gc addresses the issue. Bug: CUSTESC-29094 Bug: cloudflare/workers-sdk#2386
Consecutive requests could lead to calling into the isolate whilst code pages are being collected. This problem has only been observed on macOS arm64. Bug: CUSTESC-29094 Bug: cloudflare/workers-sdk#2386 Review: #803
This reverts commit d0ac3f3. The preceding commit adding --single-threaded-gc addresses the issue. Bug: CUSTESC-29094 Bug: cloudflare/workers-sdk#2386
Consecutive requests could lead to calling into the isolate whilst code pages are being collected. This problem has only been observed on macOS arm64. Bug: CUSTESC-29094 Bug: cloudflare/workers-sdk#2386 Review: #803
This reverts commit d0ac3f3. The preceding commit adding --single-threaded-gc addresses the issue. Bug: CUSTESC-29094 Bug: cloudflare/workers-sdk#2386
Hi @lrapoport-cf, the fix to workerd is in and available for the next workers-sdk release. We can close this ticket when that happens. (I've unassigned the ticket trying to re-assign it, but don't appear to have permissions to do that). |
thanks @ohodson ! i've linked your fix to the ticket and reassigned :) |
Looking at a merged PR in the comments above, it seems like there is a fix 🎉 Do we have an expect date for this to be released? |
Hey everyone! 👋 We've just released a new |
@mrbbot |
@BillBrower-Shopify thanks for letting us know. Will see if we can translate this to a |
@BillBrower-Shopify I've been able to reproduce this just using |
Thanks @mrbbot! Is there a separate Github issue we can use to track progress on that work? |
@BillBrower-Shopify I've filed cloudflare/workerd#831 against |
Previously, the middleware loader for module workers would register all middleware on each request. These registrations would be in addition to previous requests' registrations, meaning the middleware chain grew linearly with each request. This eventually lead to a stack overflow, as the middleware dispatcher is recursive. It also significantly slowed down requests over time. Editing code and reloading the dev server would reset the middleware chain. This change ensures middleware is only registered on the first request. Closes #2386
Previously, the middleware loader for module workers would register all middleware on each request. These registrations would be in addition to previous requests' registrations, meaning the middleware chain grew linearly with each request. This eventually lead to a stack overflow, as the middleware dispatcher is recursive. It also significantly slowed down requests over time. Editing code and reloading the dev server would reset the middleware chain. This change ensures middleware is only registered on the first request. Closes #2386
@BillBrower-Shopify the maximum call stack exceeded error and slowdowns should've been resolved with #3585, and released in |
Previously, the middleware loader for module workers would register all middleware on each request. These registrations would be in addition to previous requests' registrations, meaning the middleware chain grew linearly with each request. This eventually lead to a stack overflow, as the middleware dispatcher is recursive. It also significantly slowed down requests over time. Editing code and reloading the dev server would reset the middleware chain. This change ensures middleware is only registered on the first request. Closes #2386
What version of
Wrangler
are you using?2.6.2
What operating system are you using?
Mac
Describe the Bug
If I test my simple worker with
wrangler dev --experimental-local
and monitor the browser devtools network tab I see that after the initial (cold) requests then next requests return in 2ms.If I keep on refreshing the browser, I see that time slowly starts to creep up, 4ms, 6ms, 8ms, and if I keep on refreshing the browser tab a lot, it slows down to 50-70ms and keeps on slowing down further with additional http requests.
At the same time I observe that the memory usage increases from 17MB to 34MB, 50MB, 75MB, all the way to over 1GB.
The text was updated successfully, but these errors were encountered: