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 formal concepts of agents, and agents cluster - spec changes #23306

Open
gterzian opened this issue May 2, 2019 · 1 comment
Open

Implement formal concepts of agents, and agents cluster - spec changes #23306

gterzian opened this issue May 2, 2019 · 1 comment

Comments

@gterzian
Copy link
Member

@gterzian gterzian commented May 2, 2019

The HTML spec introduced two new concepts to integrate with concepts from Javascript, those are

  1. Agent clusters: https://html.spec.whatwg.org/#integration-with-the-javascript-agent-cluster-formalism
  2. Agents: https://html.spec.whatwg.org/#integration-with-the-javascript-agent-formalism

Agents are basically independent threads of executions, pretty close to what we have as a ScriptThread, although the spec defines specific agent types:

  1. Similar Origin Window Agent, fairly equivalent to a script-thread running one or several similar origin windows.
  2. Specific "worker" agents for each type of worker, and for worklets. (for example https://html.spec.whatwg.org/#dedicated-worker-agent)

The spec then maps event-loop types to agents, in the form of Window event-loops(used by Similar Origin Window Agent, and possibly shared across those), and Worker and Worklet event-loops, used by their respective type of agents.

===

I don't really have specific actionable things to suggest, other than just being aware of those changes.

It seems to me the formal concepts of "Agent clusters" could influence our approach to process isolation. @asajeffrey

I also have a vague feeling we should probably add those concepts to the constellation, to track the various "agents", as well as their event-loops and the "clusters" to which they belong.

For example, the constellation currently keeps track of EventLoop, and an EventLoop is essentially the constellation view of a ScriptThread, which would map to a Similar Origin Window Agent in the spec.

I don't think the constellation is aware of worker threads/event-loops, which are spawned on a "ad-hoc" basis from withhin a ScriptThread, see for example

It might be a good idea to make our current EventLoop an enum, and perhaps rename it to Agent and make the constellation track all such "agents", including those for workers, and start grouping them by "agent clusters".

This wouldn't fit with how EventLoop are shared between pipelines(since we wouldn't want a window sharing an event-loop with a worker), but that's something that probably should change as well based on another change to the spec, see #23307

@gterzian
Copy link
Member Author

@gterzian gterzian commented May 3, 2019

Here is one more potential reason to track the agent/agent-clusters concept at the level of the constellation: whatwg/html#4339

At least as I understand it, shared workers could live in their own agent clusters, and be "shared" with agents inside other clusters(processes). Having the constellation retain a global view of clusters could facilitate such a setup(versus our current approach which is to keep workers "hidden" inside a script-thread and potentially the process it is running in).

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.

None yet
1 participant
You can’t perform that action at this time.