Skip to content

Allow maxSpinWait option - #57

Draft
WebReflection wants to merge 1 commit into
mainfrom
max-spin-wait
Draft

WebReflection wants to merge 1 commit into
mainfrom
max-spin-wait

Conversation

@WebReflection

Copy link
Copy Markdown
Owner

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

Copy link
Copy Markdown
Owner Author

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
WebReflection force-pushed the main branch 15 times, most recently from 3eee89f to 6873806 Compare September 18, 2025 08:04
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.

1 participant