Skip to content
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

Relax Send constraints #979

Merged
merged 1 commit into from
Apr 14, 2023
Merged

Relax Send constraints #979

merged 1 commit into from
Apr 14, 2023

Conversation

kjvalencik
Copy link
Member

Currently, Neon pessimistically assumes that JavaScript runtimes may choose to execute from different threads. The specification only defines serial execution and not necessarily single threaded execution.

In practice, this will always be one thread. V8 makes heavy usage of TLS and it would be a large lift to start doing things differently.

This PR changes Neon to optimistically assume the runtime will always execute from the same thread. As a small level of protection, I added SendWrapper when debug_assertions are enabled. This will panic if the single-thread invariant is violated.

@kjvalencik kjvalencik force-pushed the kv/unnecessary-send branch 2 times, most recently from e18e73a to c921014 Compare April 14, 2023 16:26
Copy link
Collaborator

@dherman dherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I found it slightly confusing that the debug-only version of send_wrapper is also called send_wrapper, but I don't feel too strongly about it.

crates/neon/src/sys/send_wrapper.rs Outdated Show resolved Hide resolved
@kjvalencik kjvalencik merged commit a40c012 into main Apr 14, 2023
@kjvalencik kjvalencik deleted the kv/unnecessary-send branch April 14, 2023 17:00
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.

None yet

2 participants