Remove SerializesModels
for performance gains
#196
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi 👋
This PR removes the
SerializesModels
trait from the baseProcessWebhookJob
class.Please allow me to explain the reasoning behind this change proposal. The documentation states (verbatim):
While this behavior is fine for the vast majority of use cases out there, I think that free performance gains are left on the table by utilizing this trait within this particular context of webhooks. As you may already know, incoming webhooks are essentially events dispatched over Http, and by definition events are always immutable because they represent things that happened in the past. This immutable nature of events guarantees us that no changes to the serialized
WebhookCall
are going to occur by the time a queue worker picks up the job and starts processing it. Consequently, each processed job is no longer going to make an additional database query to retrieve the serialized model thus resulting in performance improvements.I don't think that
Job
payload is going to be an issue, as most webhook payloads have a small footprint anyway.This is definitely a breaking change, and I'm targeting
main
right now because there was no other option. I'm definitely glad to close and re-open the PR if anext
orv4
branch is made.Thanks 🙌