Limit max. sleep duration per loop iteration#42
Limit max. sleep duration per loop iteration#42mvorisek wants to merge 2 commits intophp-lock:masterfrom mvorisek:better_sleep_time
Conversation
|
Sorry, it is not really clear to me what you are trying to achieve. Can you elaborate in your initial comment? |
|
@willemstuursma if you set timeout to some "interactive time" like 30 seconds, we should not wait between next retry too much. On the other side, this PR increases the retry time up to 25 seconds for long timeouts/processes. In other words, this PR improves interactivity for interactive applications and save resources when lock takes a lot of time to aquire (and is allowed to - never more than timeout / 120). |
|
@willemstuursma please review this PR with my explanation and either merge or concretize your feedback I can address, thanks |
|
Hi @mvorisek. Thank you for explaining what your code does. However, I am missing any clear advantages backed up by numbers (or even anecdotes). You change is highly arbitrary, I feel that the goals it aims to achieve are already achieved by the existing exponential back off. I cannot really phantom a situation where you would have so many competing threads that a polling interval > 500ms is required. IMHO, the underlying storage engines (Redis, memcached) can easily handle existing situations. |
max. sleep duration should be based on timeout, as for shorter timeouts, we should loop more often (like for web/API) vs. some long timeouts (for CLI/crons)