-
-
Notifications
You must be signed in to change notification settings - Fork 193
Include sleep option in queue config #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include sleep option in queue config #564
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for your first contribution!
Could you perhaps also propose a documentation update on the nativephp.com
repo for this?
I'm requesting review from other core team members to make sure this aligns with expectation. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I don't think this has any negative impact on existing apps
…in nativephp config file
Hi @PeteBishwhip, thanks! I've created a PR for the docs here: NativePHP/nativephp.com#125 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tell me what the CPU usage is when you set it to 0? I'm concerned that it will result in high CPU usage. Also, this is currently using SQLite as a driver, which may result in locking your database.
I would like to set a better default for nativephp, maybe 1? I'll try after this PR is merged.
Hi @SRWieZ great points, I actually ended up using sleep=0.1 to avoid the tight polling loop, and in my project noticed no difference in responsiveness between 0 and 0.1. It starts to become noticeable at 2-3 seconds. Agree a good default would be 1. Re. the CPU usage, sleep=0 caused a rise of around 10-20% on my M1 Mac, compared to setting it to 1. |
Thanks for the feedback. 0.1 works ? It's declared as an int in this PR. |
Good catch. I tested float sleep outside of native, and only in more recent tests realized that Laravel's Worker::sleep() implementation actually supports sub second granularity. Happy to open a new PR to fix the type hint. Update: PR created #583 |
This PR exposes the sleep argument for the
queue:work
command. The motivation behind this change is to reduce the delay between dispatching an asynchronous job and a worker picking it up. This delay can create a noticeable lag in the UI, which I'm currently experiencing. In my case, setting sleep=0 resolves the issue.