Skip to content

Simplify emscripten_futex_wait on them main thread #15975

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

Closed
wants to merge 1 commit into from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jan 11, 2022

The _emscripten_futex_wait_non_blocking contains a busy loop that and
was calling out to emscripten_main_thread_process_queued_calls on each
iteration. However, all the caller of emscripten_futex_wait already
do their own busy loop calling
emscripten_main_thread_process_queued_calls. See:

  • __wait.c: __wait
  • __timed_wait.c: __timedwait_cp
  • pthread_barrier_wait.c: pthread_barrier_wait
  • pthread_join.c: __pthread_join_internal
  • library_pthread.c: emscripten_thread_sleep

In all these cases emscripten_futex_wait is limited to a max sleep of
1ms when running on the main thread.

There is only one of other user and in this case emscripten_fetch_wait
is only used when not running on the main thread:

  • emscripten_fetch.c: emscripten_fetch_wait

The `_emscripten_futex_wait_non_blocking` contains a busy loop that and
was calling out to `emscripten_main_thread_process_queued_calls` on each
iteration.   However, all the caller of `emscripten_futex_wait` already
do their own busy loop calling
 `emscripten_main_thread_process_queued_calls`.  See:

- __wait.c: __wait
- __timed_wait.c: __timedwait_cp
- pthread_barrier_wait.c: pthread_barrier_wait
- pthread_join.c: __pthread_join_internal
- library_pthread.c: emscripten_thread_sleep

In all these cases `emscripten_futex_wait` is limited to a max sleep of
1ms when running on the main thread.

There is only one of other user and in this case emscripten_fetch_wait
is only used when not running on the main thread:

- emscripten_fetch.c: emscripten_fetch_wait
@sbc100 sbc100 force-pushed the simplify_futex_wait branch from f18ebe5 to 6b52611 Compare January 11, 2022 23:42
@sbc100
Copy link
Collaborator Author

sbc100 commented Jan 12, 2022

I think perhaps we should instead remove all the other time slicing instead and keep this one.

@sbc100 sbc100 closed this Jan 12, 2022
@sbc100 sbc100 deleted the simplify_futex_wait branch January 12, 2022 14:47
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