What does photolibraryd do whenever I log in to my Mac?
It also matches photos that are on your local library and in iCloud. So for instance, if you have a sync problem, you can toggle iCloud Photo Library in Photos app → Preferences → iCloud and this will cause a complete re-sync of the local and the iCloud photos.

When this happens (at least on my 51K photo library), it takes 24 hours or so of photolibraryd running to match photos and sync the changes.