Optimize webhook execution
## Summary We have many places in our codebase where we call hooks/services, and build the data payload beforehand. This can be expensive if we need to fetch associations, and redundant if we don't actually have any hooks/services to call. ## Why are we doing this? As a maintenance/optimization task this can improve performance of our overall webhook infrastructure. We anticipate an overall performance improvement across each of our webhook event types (with a potential average reduction of 150k queries per event type weekly by our estimation). | Hook event | Webhook executions (7d) | Est. Triggered:Executed | Old Queries per triggered only | Old Queries per triggered with execution | New Queries per triggered only | New Queries per triggered with execution | Est. Old total query count (7d) | Est. New total query count (7d) | Est. Query count delta (7d) | |------------|-------------------------|-------------------------|--------------------------------|------------------------------------------|--------------------------------|------------------------------------------|---------------------------------|---------------------------------|-----------------------------| | Merge requests | [3,360,458](https://log.gprd.gitlab.net/goto/5d8b21f0-4521-11ed-8d37-e9a2f393ea2a) | 7:1 | 13 | 13 | 4 | 10 | 349,487,632 | 127,697,404 | -221,790,228 | | Jobs | [23,611,565](https://log.gprd.gitlab.net/goto/71ae0260-4521-11ed-b0ec-930003e0679c) | 7:1 | 4 | 12 | 4 | 9 | 944,462,600 | 873,627,905 | -70,834,695 | ## Risks * If a payload changes unexpectedly, this could result in failures. ## Impacts * Potential performance improvements to all webhook users. * [Self-managed instances](https://app.periscopedata.com/app/gitlab/822206/Ecosystem:Integrations-Usage?widget=15442185&udv=0) using Webhooks * [Webhook usage per product tier](https://app.periscopedata.com/app/gitlab/822206/Ecosystem:Integrations-Usage?widget=15440479&udv=0) * No interface changes - no visible impacts to users beyond potential performance gains. ## Effort / Timeline This will require 2-3 milestones to complete due to gradual rollouts across event types, with an estimated `6` weight total.
epic