three changes to speed up PackageManager::Base.save_dependencies:
across all versions, cache the lookup of dep platform/name to project_id, so we don't make repetitive calls to Project.find_best! for the same projects (since most versions are likely to have similar deps as other versions)
for each version, extract a single list of existing dep names instead of iterating over the entire version.dependencies association for each dep
for each version, aggregate all the deps into a single array, and insert them via insert_all instead of doing single inserts for each one
three changes to speed up
PackageManager::Base.save_dependencies
:Project.find_best!
for the same projects (since most versions are likely to have similar deps as other versions)insert_all
instead of doing single inserts for each onelocally, these changes take a cold update of:
npm/@docus/app
from ~25sec to ~1.5sec.npm/gatsby
from 83min to 67 sec