coincident icon indicating copy to clipboard operation
coincident copied to clipboard

Allow maxSpinWait option

Open WebReflection opened this issue 7 months ago • 1 comments

This MR is a ready-to-land amend for the current main branch in case somebody will bring up a compelling reason to actually fallback on Atomics.wait(view, index) when most use cases expect nearly instant resolution from the main thread.

It's true that some task on main could take long time but if it's too long then something is wrong anyway because long tasks, or heavy one, should actually happen in the worker anyway so ... I think we're good the way we are now but ... hey, maybe somebody will find a good reason to have slower waiting logic.

WebReflection avatar May 07 '25 11:05 WebReflection

TBD should this logic be based on ms instead? would a call to Date.now() in the while loop affect performance? I feel like that would be better for DX, where 100 ms might be reasonable enough, as example, but I am not sure if that would degrade performance a lot compared to a single int to int comparison for the spin lock value 🤔

TODO use PyScript tests to measure the impact before landing anything in here

WebReflection avatar May 07 '25 11:05 WebReflection