undici icon indicating copy to clipboard operation
undici copied to clipboard

fetch: limit web streams usage in body mixin methods

Open mertcanaltin opened this issue 1 year ago โ€ข 3 comments

This PR aims to improve performance by optimizing the processing of webflows in the fetch module. This experiment was already done by @KhafraDev , I just opened a pr

I thought there would be discussion about it and it might benefit fetch ๐Ÿš€ #2164 here is a benchmark made by @KhafraDev ๐Ÿ™ benchmarks:

import { Response as UndiciResponse } from './index.js'
import { cronometro } from 'cronometro'

await cronometro({
  async 'undici Response' () {
    await new UndiciResponse('abc').text()
  },
  async 'global Response' () {
    await new Response('abc').text()
  }
})

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ Slower tests    โ”‚ Samples โ”‚          Result โ”‚ Tolerance โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ global Response โ”‚   10000 โ”‚ 40169.19 op/sec โ”‚  ยฑ 1.59 % โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ Fastest test    โ”‚ Samples โ”‚          Result โ”‚ Tolerance โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ undici Response โ”‚   10000 โ”‚ 44024.31 op/sec โ”‚  ยฑ 2.12 % โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

mertcanaltin avatar Apr 13 '24 17:04 mertcanaltin

I'm running tests, I'll fix them ๐Ÿงช

mertcanaltin avatar Apr 13 '24 17:04 mertcanaltin

There are related failures, but I don't necessarily think this should land as-is even if those failures were fixed.

KhafraDev avatar Apr 16 '24 17:04 KhafraDev

I wonder if you have a suggestion, if it's healthy to keep it as it is, I'll close this place @KhafraDev

mertcanaltin avatar Apr 27 '24 10:04 mertcanaltin