packagephobia icon indicating copy to clipboard operation
packagephobia copied to clipboard

Improve performance

Open styfle opened this issue 3 years ago • 1 comments

We're currently doing a lot of work to render the top 10 npm version sizes.

  1. Retrieve npm manifest from registry
  2. Sort all versions with semver
  3. Filter down to 5 less than and 5 greater than current version
  4. Fetch all versions from redis (this can be very slow)

Perhaps we can utilize a Sorted Set in Redis so we can easily page through results.

https://redis.io/commands#sorted_set

styfle avatar Dec 20 '21 15:12 styfle

It turns out that fetching the package.json is actually the slowest part so there was an in memory cache added here:

  • https://github.com/styfle/packagephobia/pull/1026
fetchJSON: 627.704ms
findOne (redis): 18.767ms
findAll (redis): 34.463ms

It might be worth investigating if we can improve redis a bit by using a Sorted Set, but a better first step is to improve package.json caching since that is significantly slower.

styfle avatar Aug 12 '24 02:08 styfle