librariesio / libraries.io

:books: The Open Source Discovery Service
https://libraries.io
GNU Affero General Public License v3.0
1.1k stars 206 forks source link

Speed up Api::Repositories#sync by avoiding callbacks #3390

Closed tiegz closed 1 month ago

tiegz commented 1 month ago

Api::Repositories#sync should be fast because it just kicks off a sidekiq job via Repository#manual_sync, but the traces are very slow (DD is not displaying them for me ATTM).

after kicking off the job, Repository#manual_sync then updates the last_synced_at field so it doesn't get re-synced before it finishes syncing, but that update() kicks off a chain of callbacks in Repository and for all Repository#projects. So I'm minimizing the work done on this endpoint by changing it to a direct column update instead of a full save with callbacks.