Skip to content

[13.x] Decode job payload once - #61526

Open
jackbayliss wants to merge 2 commits into
laravel:13.xfrom
jackbayliss:13.x-memoize-json_decode
Open

[13.x] Decode job payload once#61526
jackbayliss wants to merge 2 commits into
laravel:13.xfrom
jackbayliss:13.x-memoize-json_decode

Conversation

@jackbayliss

@jackbayliss jackbayliss commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

I was poking and realised payload() is called for figuring out all the job settings like maxTries,retryUntil etc. In the Worker loop, but, it's decoded fresh each time.

RedisJob already decodes once into a decoded property, see #13952 but, of course not all the methods are called that way.

I think this should just be the default.. ie why not just save it to a property as the body never changes.

This helps if you have larger payloads mainly, so for smaller jobs there's no real difference.

SQS supports up to 1 MiB, Database and Redis can take more, so after some basic testing with about 200kb - 900kb its about 20% - 30% faster to finish a job just with this one change, Which of course is more meaningful the more jobs you process.

Sent to 13.x as I don't see how a payload would be expected to give a a different string on the second call, but happy to send to 14.x if you prefer? or refactor?

We could clean up the Redis job in 14.x, but open to whats easier for you 🖖🏻

@github-actions

Copy link
Copy Markdown

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@jackbayliss
jackbayliss marked this pull request as ready for review September 10, 2026 22:12
@taylorotwell

Copy link
Copy Markdown
Member

Think this could change the way jobs serialize in a way we don't want?

@jackbayliss

jackbayliss commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@taylorotwell I don't think so, it's serialized as normal via createPayload , it doesn't call this method

This method is called in the worker loop, so this PR stops the worker constantly calling json_decode on the raw payload which doesnt change. RedisJob does this, but doesn't utilise it fully

Double checked locally and the payload is the same

Happy to send it to master if there's a concern but lmk if im missing something stupid

Ty big dog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants