packagephobia
packagephobia copied to clipboard
Improve performance
We're currently doing a lot of work to render the top 10 npm version sizes.
- Retrieve npm manifest from registry
- Sort all versions with semver
- Filter down to 5 less than and 5 greater than current version
- 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
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.