cloudflare / miniflare

🔥 Fully-local simulator for Cloudflare Workers. For the latest version, see https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare.
https://miniflare.dev
MIT License
3.78k stars 205 forks source link

[Miniflare 3] Re-enable concurrent `dispatchFetch()`s and batch proxy heap frees #713

Closed mrbbot closed 1 year ago

mrbbot commented 1 year ago

In order to fix tests when adding the magic proxy, we restricted dispatchFetch() to one concurrent TCP connection. Unfortunately, this prevented long-lived dispatchFetch() requests.

When proxies are garbage collected, we send a network request to workerd to free the corresponding entry in the ProxyServer heap. Garbage collection often happens in phases though, freeing lots of objects at once. This caused many concurrent requests to workerd (~60 in some tests), leading to many TCP connections being created.

This change re-enables using multiple TCP connections, and attempts to address the root cause of the issues we were seeing, by batching frees before sending the network request.

changeset-bot[bot] commented 1 year ago

⚠️ No Changeset found

Latest commit: 6124292c7ec4b0ebc076b515d26ed656e8ed83d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/cloudflare/miniflare/new/bcoll/tre-concurrent-requests?filename=.changeset/pink-flowers-lay.md&value=---%0A%22%40fake-scope%2Ffake-pkg%22%3A%20patch%0A---%0A%0A%5BMiniflare%203%5D%20Re-enable%20concurrent%20%60dispatchFetch()%60s%20and%20batch%20proxy%20heap%20frees%20%0A)