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

Formalise use of Agent-cluster #24159

Open
gterzian opened this issue Sep 8, 2019 · 1 comment
Open

Formalise use of Agent-cluster #24159

gterzian opened this issue Sep 8, 2019 · 1 comment

Comments

@gterzian
Copy link
Member

@gterzian gterzian commented Sep 8, 2019

This comment provides a very good overview of the "agent/agent-cluster" model emerging in the HTML standard.

This sums it up nicely:

A user agent:

  • Holds a set of browsing context groups.
  • Holds a shared worker map of origin to agent clusters.
  • Holds a service worker map of origin to agent clusters.

and "A browsing context group: Holds a map of similar-origin window keys to agent clusters. (...)"


The good news is that Servo's current architecture pretty much already follows that model, with the exception, in my opinion, of Service Worker.

We currently already have

struct BrowsingContextGroup {

which contains a

event_loops: HashMap<Host, Weak<EventLoop>>,

It's not really accurate to call our EventLoop an "event-loop", since it actually contains, potentially, several event-loops, or should we say "agents", in the form of a single window agent, and potentially multiple dedicated worker agents.

An EventLoop can also potentially contain several worklet agents.

So, its really not an "event-loop", and in fact is fits the definition of agent-cluster very well.

So basically, we're lucky, because we pretty much already have "agent-cluster" right, and we could just rename EventLoop -> AgentCluster.


Now, note that service-worker-agent
and shared-worker-agent, on the other hand, are never part of the same "agent-cluster" as a window/worklet/dedicated-worker agent.

We don't have shared-worker yet, and service-workers currently run inside an EventLoop.

So, we could move service worker to it's own "agent-cluster", kept in a map on the constellation. It's discussed at #19302


On a related note, I think the "agent-cluster" concept could influence other architectural choices. A good example is media, since an audio worklet would have to run in the agent-cluster used by a window/dedicated worker agents, yet the audio backend probably needs to run in a different process.

So there it's not so much about where "media" runs, it's rather about splitting up media so that some part(the "audio rendering thread") runs in a agent-cluster(the same one as the window agent using media), and another part runs in another process(perhaps the "main" process, or a separate one). This is a change that is discussed as part of #23807

@gterzian
Copy link
Member Author

@gterzian gterzian commented Sep 17, 2019

Also just seeing the spec now also defines the allocation and re-use of agent-cluster for similiar-origin window agents, like obtain-agent-cluster-key, and this matches our operation at the constellation such as

So here some renaming and linking to the spec would be useful.

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.