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

[discussion] deterministic execution in turns #85

Open
caridy opened this issue Sep 24, 2015 · 7 comments
Open

[discussion] deterministic execution in turns #85

caridy opened this issue Sep 24, 2015 · 7 comments
Labels

Comments

@caridy
Copy link
Contributor

caridy commented Sep 24, 2015

notes:

  • during the loading process, we might have clusters of dependencies that are ready to be executed.
  • order is important for deterministic reasons.
  • running in multiple turns seems to be ok (if the order is deterministic).
  • top level await should be taken into consideration.
@caridy caridy added the question label Dec 1, 2015
@dglazkov
Copy link

dglazkov commented Jan 4, 2016

Indeed. We had to figure this out for HTML Imports. In realistic network condition, waiting until everything loads is unlikely to result acceptable performance characteristics.

@domenic
Copy link
Member

domenic commented Jan 4, 2016

For modules I don't think we have a choice. You simply cannot execute a module before its dependencies have been executed. So you cannot execute any part of the module tree before all its children have been executed.

@caridy
Copy link
Contributor Author

caridy commented Jan 4, 2016

@domenic this discussion is not really about the "imported" module, it is about parts of the dependency tree that can be executed in turns. E.g.:

while doing import A:

A -> B -> C, while B -> D and C -> E

If B and D are in "link" stage, and the pipeline is just waiting for C, and E to be fetched, we could, theoretically, evaluate B and C, get them to "ready" stage, without any observable difference in the runtime while maintaining the deterministic aspect of the module graph since this is equivalent to:

import B, then import A;

Today, this is not the case since we need to get every module in the graph in link stage before proceeding to the evaluation phase.

Note: -> means "depends on".

@domenic
Copy link
Member

domenic commented Jan 4, 2016

Ah, I see. The execution model for whatwg/html#443 does not have that problem; it executes everything as soon as its dependencies are ready.

@caridy
Copy link
Contributor Author

caridy commented Jan 4, 2016

that is correct!

@domenic
Copy link
Member

domenic commented Jan 5, 2016

It's a bit more complicated than my above comment implied sadly. See whatwg/html#443 (comment). Basically my above comment is correct about the current whatwg/html#443 PR, but that state of affairs is actually due to a bug that gives us semantics that are something like "defer except execution order is not preserved".

If you preserve execution order (per normal defer semantics) than you get a problem similar to the one described in this bug where large/slow trees that are earlier in the source order can block small/fast trees later in the source order.

If you want the kind of incremental as-soon-as-it-loads tree execution style then you want something more like async.

Anyway, more discussion over there, I just wanted to update this thread since my above comment was incorrect.

@caridy
Copy link
Contributor Author

caridy commented Jan 5, 2016

I don't think this is related to whatwg/html#443. We will be able to introduce execution in turn for any dependency of a top level module imported via script tags without changing the way you interact with the loader (from what I can read in whatwg/html#443). It is really all about the loader, and when it invokes evaluation in certain module records.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants