Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

use FinalizationRegistry for cloned response body #3458

Merged
merged 3 commits into from
Aug 15, 2024

Conversation

KhafraDev
Copy link
Member

@KhafraDev KhafraDev commented Aug 14, 2024

running test with node --expose-gc --test test/fetch/fire-and-forget.js

Before
RSS 66 MB after 50 fetch() requests
RSS 68 MB after 100 fetch() requests
RSS 76 MB after 150 fetch() requests
RSS 84 MB after 200 fetch() requests
RSS 93 MB after 250 fetch() requests
RSS 101 MB after 300 fetch() requests
RSS 110 MB after 350 fetch() requests
RSS 117 MB after 400 fetch() requests
RSS 125 MB after 450 fetch() requests
RSS 133 MB after 500 fetch() requests
RSS 141 MB after 550 fetch() requests
RSS 134 MB after 600 fetch() requests
RSS 143 MB after 650 fetch() requests
RSS 149 MB after 700 fetch() requests
RSS 155 MB after 750 fetch() requests
RSS 163 MB after 800 fetch() requests
RSS 171 MB after 850 fetch() requests
RSS 178 MB after 900 fetch() requests
RSS 185 MB after 950 fetch() requests
RSS 183 MB after 1000 fetch() requests
RSS 196 MB after 1050 fetch() requests
RSS 205 MB after 1100 fetch() requests
RSS 212 MB after 1150 fetch() requests
RSS 219 MB after 1200 fetch() requests
RSS 226 MB after 1250 fetch() requests
RSS 233 MB after 1300 fetch() requests
RSS 241 MB after 1350 fetch() requests
RSS 249 MB after 1400 fetch() requests
RSS 257 MB after 1450 fetch() requests
RSS 264 MB after 1500 fetch() requests
RSS 240 MB after 1550 fetch() requests
RSS 244 MB after 1600 fetch() requests
RSS 248 MB after 1650 fetch() requests
RSS 257 MB after 1700 fetch() requests
RSS 263 MB after 1750 fetch() requests
RSS 269 MB after 1800 fetch() requests
RSS 275 MB after 1850 fetch() requests
RSS 282 MB after 1900 fetch() requests
RSS 290 MB after 1950 fetch() requests
RSS 299 MB after 2000 fetch() requests
RSS 307 MB after 2050 fetch() requests
RSS 284 MB after 2100 fetch() requests
RSS 287 MB after 2150 fetch() requests
RSS 294 MB after 2200 fetch() requests
RSS 300 MB after 2250 fetch() requests
RSS 305 MB after 2300 fetch() requests
RSS 312 MB after 2350 fetch() requests
RSS 318 MB after 2400 fetch() requests
RSS 325 MB after 2450 fetch() requests
RSS 333 MB after 2500 fetch() requests
RSS 340 MB after 2550 fetch() requests
RSS 348 MB after 2600 fetch() requests
RSS 328 MB after 2650 fetch() requests
RSS 331 MB after 2700 fetch() requests
RSS 337 MB after 2750 fetch() requests
RSS 344 MB after 2800 fetch() requests
RSS 350 MB after 2850 fetch() requests
RSS 356 MB after 2900 fetch() requests
RSS 362 MB after 2950 fetch() requests
RSS 369 MB after 3000 fetch() requests
RSS 377 MB after 3050 fetch() requests
RSS 384 MB after 3100 fetch() requests
RSS 392 MB after 3150 fetch() requests
RSS 380 MB after 3200 fetch() requests
RSS 389 MB after 3250 fetch() requests
RSS 390 MB after 3300 fetch() requests
RSS 390 MB after 3350 fetch() requests
RSS 392 MB after 3400 fetch() requests
RSS 398 MB after 3450 fetch() requests
RSS 404 MB after 3500 fetch() requests
RSS 411 MB after 3550 fetch() requests
RSS 418 MB after 3600 fetch() requests
RSS 426 MB after 3650 fetch() requests
RSS 433 MB after 3700 fetch() requests
RSS 419 MB after 3750 fetch() requests
RSS 421 MB after 3800 fetch() requests
RSS 423 MB after 3850 fetch() requests
RSS 423 MB after 3900 fetch() requests
RSS 429 MB after 3950 fetch() requests
RSS 435 MB after 4000 fetch() requests
RSS 440 MB after 4050 fetch() requests
RSS 447 MB after 4100 fetch() requests
RSS 454 MB after 4150 fetch() requests
RSS 461 MB after 4200 fetch() requests
RSS 469 MB after 4250 fetch() requests
RSS 477 MB after 4300 fetch() requests
RSS 465 MB after 4350 fetch() requests
RSS 467 MB after 4400 fetch() requests
RSS 467 MB after 4450 fetch() requests
RSS 467 MB after 4500 fetch() requests
RSS 472 MB after 4550 fetch() requests
RSS 478 MB after 4600 fetch() requests
RSS 484 MB after 4650 fetch() requests
RSS 491 MB after 4700 fetch() requests
RSS 497 MB after 4750 fetch() requests
RSS 505 MB after 4800 fetch() requests
RSS 512 MB after 4850 fetch() requests
RSS 520 MB after 4900 fetch() requests
RSS 501 MB after 4950 fetch() requests
RSS 505 MB after 5000 fetch() requests
After
RSS 65 MB after 50 fetch() requests
RSS 69 MB after 100 fetch() requests
RSS 77 MB after 150 fetch() requests
RSS 85 MB after 200 fetch() requests
RSS 93 MB after 250 fetch() requests
RSS 98 MB after 300 fetch() requests
RSS 107 MB after 350 fetch() requests
RSS 114 MB after 400 fetch() requests
RSS 122 MB after 450 fetch() requests
RSS 129 MB after 500 fetch() requests
RSS 109 MB after 550 fetch() requests
RSS 119 MB after 600 fetch() requests
RSS 126 MB after 650 fetch() requests
RSS 133 MB after 700 fetch() requests
RSS 139 MB after 750 fetch() requests
RSS 146 MB after 800 fetch() requests
RSS 152 MB after 850 fetch() requests
RSS 160 MB after 900 fetch() requests
RSS 137 MB after 950 fetch() requests
RSS 141 MB after 1000 fetch() requests
RSS 147 MB after 1050 fetch() requests
RSS 154 MB after 1100 fetch() requests
RSS 160 MB after 1150 fetch() requests
RSS 166 MB after 1200 fetch() requests
RSS 173 MB after 1250 fetch() requests
RSS 181 MB after 1300 fetch() requests
RSS 188 MB after 1350 fetch() requests
RSS 196 MB after 1400 fetch() requests
RSS 150 MB after 1450 fetch() requests
RSS 165 MB after 1500 fetch() requests
RSS 172 MB after 1550 fetch() requests
RSS 178 MB after 1600 fetch() requests
RSS 185 MB after 1650 fetch() requests
RSS 191 MB after 1700 fetch() requests
RSS 198 MB after 1750 fetch() requests
RSS 205 MB after 1800 fetch() requests
RSS 212 MB after 1850 fetch() requests
RSS 161 MB after 1900 fetch() requests
RSS 162 MB after 1950 fetch() requests
RSS 167 MB after 2000 fetch() requests
RSS 173 MB after 2050 fetch() requests
RSS 180 MB after 2100 fetch() requests
RSS 186 MB after 2150 fetch() requests
RSS 193 MB after 2200 fetch() requests
RSS 200 MB after 2250 fetch() requests
RSS 207 MB after 2300 fetch() requests
RSS 213 MB after 2350 fetch() requests
RSS 160 MB after 2400 fetch() requests
RSS 164 MB after 2450 fetch() requests
RSS 169 MB after 2500 fetch() requests
RSS 175 MB after 2550 fetch() requests
RSS 182 MB after 2600 fetch() requests
RSS 188 MB after 2650 fetch() requests
RSS 195 MB after 2700 fetch() requests
RSS 202 MB after 2750 fetch() requests
RSS 208 MB after 2800 fetch() requests
RSS 215 MB after 2850 fetch() requests
RSS 161 MB after 2900 fetch() requests
RSS 173 MB after 2950 fetch() requests
RSS 179 MB after 3000 fetch() requests
RSS 186 MB after 3050 fetch() requests
RSS 192 MB after 3100 fetch() requests
RSS 199 MB after 3150 fetch() requests
RSS 205 MB after 3200 fetch() requests
RSS 212 MB after 3250 fetch() requests
RSS 218 MB after 3300 fetch() requests
RSS 225 MB after 3350 fetch() requests
RSS 171 MB after 3400 fetch() requests
RSS 181 MB after 3450 fetch() requests
RSS 187 MB after 3500 fetch() requests
RSS 194 MB after 3550 fetch() requests
RSS 200 MB after 3600 fetch() requests
RSS 206 MB after 3650 fetch() requests
RSS 213 MB after 3700 fetch() requests
RSS 220 MB after 3750 fetch() requests
RSS 226 MB after 3800 fetch() requests
RSS 170 MB after 3850 fetch() requests
RSS 175 MB after 3900 fetch() requests
RSS 179 MB after 3950 fetch() requests
RSS 185 MB after 4000 fetch() requests
RSS 192 MB after 4050 fetch() requests
RSS 198 MB after 4100 fetch() requests
RSS 205 MB after 4150 fetch() requests
RSS 213 MB after 4200 fetch() requests
RSS 219 MB after 4250 fetch() requests
RSS 226 MB after 4300 fetch() requests
RSS 169 MB after 4350 fetch() requests
RSS 177 MB after 4400 fetch() requests
RSS 184 MB after 4450 fetch() requests
RSS 190 MB after 4500 fetch() requests
RSS 197 MB after 4550 fetch() requests
RSS 203 MB after 4600 fetch() requests
RSS 210 MB after 4650 fetch() requests
RSS 217 MB after 4700 fetch() requests
RSS 224 MB after 4750 fetch() requests
RSS 170 MB after 4800 fetch() requests
RSS 178 MB after 4850 fetch() requests
RSS 184 MB after 4900 fetch() requests
RSS 190 MB after 4950 fetch() requests
RSS 197 MB after 5000 fetch() requests

@KhafraDev KhafraDev requested review from mcollina and Uzlopak August 14, 2024 19:32
Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh. Simple solution.

Impressive.

LGTM

@Uzlopak
Copy link
Contributor

Uzlopak commented Aug 14, 2024

@KhafraDev

Wouldnt it be maybe better to do this in cloneResponse?

newResponse.body = cloneBody(response.body)

Would this line have the same issue, if we dont put the response into the FinalizationRegistry?

const clonedResponse = cloneResponse(innerResponse)

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@KhafraDev
Copy link
Member Author

I went for the simplest and least invasive solution, but that does leave other holes left to fill. I'll fix it up.

@mcollina
Copy link
Member

@KhafraDev seems this conflicts now, can you resolve them?

@mcollina mcollina merged commit 8a9db10 into nodejs:main Aug 15, 2024
32 checks passed
@KhafraDev KhafraDev deleted the fr-response-clone branch August 15, 2024 18:09
mcollina pushed a commit that referenced this pull request Aug 17, 2024
Signed-off-by: Matteo Collina <hello@matteocollina.com>
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
This was referenced Dec 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants