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

Implement CSS Houdini Worklets #16206

Closed
asajeffrey opened this issue Mar 31, 2017 · 9 comments
Closed

Implement CSS Houdini Worklets #16206

asajeffrey opened this issue Mar 31, 2017 · 9 comments

Comments

@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Mar 31, 2017

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 31, 2017

This came up in the context of discussions about the embedding API, as a standards-aligned way to provide strong consistency guarantees between embedding JS code, layout and webrender.

@tschneidereit
Copy link
Contributor

@tschneidereit tschneidereit commented Mar 31, 2017

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 31, 2017

On irc, @tschneidereit pointed out the code idempotence requirement: https://drafts.css-houdini.org/worklets/#code-idempotency, which is not actually statelessness, but is very close. In particular, a UA is allowed to generate a fresh global for each execution. Not sure what this would do for efficiency though, as scripts might assume that fresh globals aren't allocated very often, e.g. to perform some script initialization.

@metajack
Copy link
Contributor

@metajack metajack commented Mar 31, 2017

Fresh globals are reportedly too expensive to actually do this, so there is language about modified designs (ie, rotating two pre-allocated globals) added. If the implementation does nothing to preserve idempotency, we are likely to lose it, and any potential for parallelism along with it.

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 31, 2017

My current thinking of how to implement this is to provide a per-process thread pool for executing worklets. The main challenge would be to try to avoid GC during worklet execution, which we could do by monitoring their memory use, and removing high-memory-usage executors from the pool while they gc.

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 31, 2017

@metajack yes, generating a fresh global on every execution might be too expensive, but possibly we could freshen the global periodically, e.g. when the executor is GC'ing?

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Mar 31, 2017

IRC chat with @tschneidereit and @metajack: http://logs.glob.uno/?c=mozilla%23servo&s=31+Mar+2017&e=31+Mar+2017#c643173

TL;DR we'd like to get to an API where there's an explicit initialization phase, during which script has r/w access to the realm, followed by execution, which is in a frozen realm (https://github.com/FUDCo/proposal-frozen-realms). But we can't block worklets on frozen realms, so we're left with just spec language, which doesn't help if webcompat ends up just being everyone assumes stateful worklets.

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Apr 3, 2017

IRC chat with @jdm: http://logs.glob.uno/?c=mozilla%23servo&s=3+Apr+2017&e=3+Apr+2017#c644051

TL;DR: worklets are based on ES6 modules, which aren't in SM yet.

@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Apr 5, 2017

IRC chat with @SimonSapin: http://logs.glob.uno/?c=mozilla%23servo&s=5+Apr+2017&e=5+Apr+2017#c645966

TL;DR: stylo shouldn't be a big factor.

bors-servo added a commit that referenced this issue May 17, 2017
Implement Houdini worklets

<!-- Please describe your changes on the following line: -->

This PR implements the current draft Houdini Worklets specification (https://drafts.css-houdini.org/worklets/).

The implementation is intended to provide a responsive environment for worklet execution, and in particular to ensure that the primary worklet executor does not garbage collect, and does not block loading module code. The implementation does this by providing a thread pool, and performing GC and module loading in a backup thread, not in the primary thread.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #16206
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16814)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue May 17, 2017
Implement Houdini worklets

<!-- Please describe your changes on the following line: -->

This PR implements the current draft Houdini Worklets specification (https://drafts.css-houdini.org/worklets/).

The implementation is intended to provide a responsive environment for worklet execution, and in particular to ensure that the primary worklet executor does not garbage collect, and does not block loading module code. The implementation does this by providing a thread pool, and performing GC and module loading in a backup thread, not in the primary thread.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #16206
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16814)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.