Skip to content

Doc comment for Isolate.spawn is incorrect #35143

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
natebosch opened this issue Nov 13, 2018 · 6 comments
Closed

Doc comment for Isolate.spawn is incorrect #35143

natebosch opened this issue Nov 13, 2018 · 6 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@natebosch
Copy link
Member

The comment says "Creates and spawns an isolate that shares the same code as the current isolate."

This isn't true. What it should say (at least in the case with the VM, I have not tried AOT) is "Creates and spawns an isolate that rereads the same entrypoint as the current isolate."

If I write a Dart script that overwrites itself while running and then calls Isolate.spawn I can see it running the new version of the file I wrote, which is not the same code as the calling isolate is running.

Am I correct to assume this is a memory optimization to avoid keeping parse state that we don't need and therefore needing to reread the original file? This does incur a heavy performance penalty when running the original script from source.

@natebosch natebosch added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Nov 13, 2018
@nex3
Copy link
Member

nex3 commented Nov 13, 2018

See also #19228 and #6610

@a-siva
Copy link
Contributor

a-siva commented Nov 15, 2018

The documentation is correct, the implementation is not correct. This has been an old bug against the VM that has not been addressed (see the issues that @nex3 points to above).

"In the special circumstances when two isolates share the same code and are running in the same process (e.g. isolates created via Isolate.spawn), it is also possible to send object instances (which would be copied in the process). This is currently only supported by the dartvm. For now, the dart2js compiler only supports the restricted messages described above"

This dictates that isolates spawned using Isolate.spawn should share the same code.

@natebosch
Copy link
Member Author

@a-siva - will we have the resources to fix the implementation soon? If not, should we add a note to the doc calling out the bug on the VM? As it stands with the documentation it's very confusing.

@natebosch
Copy link
Member Author

This also came up in #31698

@liamappelbe
Copy link
Contributor

I'm working on fixing this right now.

@liamappelbe
Copy link
Contributor

https://dart-review.googlesource.com/c/sdk/+/85724

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

4 participants