got icon indicating copy to clipboard operation
got copied to clipboard

Super slow with cache

Open peterbe opened this issue 1 year ago • 0 comments

Describe the bug

  • Node.js version: 18.14.2
  • OS & version: macOS

It takes 50-70 milliseconds to get the response from await got(url, {cache}) No network (except the first time when the cache is of course cold) should be involves so it could be all CPU.

Actual behavior

GET:0: 145.388ms
GET:1: 64.91ms
GET:2: 53.785ms
GET:3: 58.756ms
GET:4: 58.956ms
GET:5: 56.665ms
GET:6: 58.048ms
GET:7: 50.556ms
GET:8: 53.686ms
GET:9: 56.007ms

Expected behavior

More like ~0.1ms per request.

Code to reproduce

import got from 'got'

const cache = new Map()
async function main() {
  for (const i of [...Array(10).keys()]) {
    console.time(`GET:${i}`)
    const res = await got(
      'https://github.github.com/help-docs-archived-enterprise-versions/2.20/redirects.json',
      { cache }
    )
    console.timeEnd(`GET:${i}`)
    //console.log(res.body.length)
  }
}
main()

Checklist

  • [x] I have read the documentation.
  • [x] I have tried my code with the latest version of Node.js and Got.

peterbe avatar Mar 21 '23 00:03 peterbe