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

Disable delta computation on code block node #7282

Merged
merged 18 commits into from
Oct 20, 2016

Conversation

ke-yu
Copy link
Contributor

@ke-yu ke-yu commented Oct 20, 2016

Purpose

This PR disables delta computation on code block node.

Delta computation

Delta computation is a VM feature which takes a series of AST nodes compiled by a Dynamo UI node in an execution session, and computes delta AST nodes of these nodes and cached nodes that it executes in last session, and only executes delta nodes.

For example, the VM initially runs a code block node:

+--------------+
|  a = 1;      |
|  b = 2;      |
|  c = a + b;  |
+--------------+

Then this code block node is modified to

+--------------+
|  a = 1;      |
|  b = 3;      |
|  c = a + b;  |
+--------------+

Though this code block node sends all AST nodes to the VM, the VM will do delta computation and only executes b = 3;. The value of c will be updated.

Issues

Though delta computation looks avoids to do unnecessary computation, it fails in some cases. The fundamental issue is delta computation is temporal : it depends on both the last and current states; whereas the whole graph execution is not temporal: the output of the graph should is determined by current state without referring to the previous state.

Here we show three failure cases.

  • Case 1: Self modification

    Code block node below is modified from state 1 to state 2. Delta AST nodes of these two states will be a[1] = "foo". But after execution the value of a will be {"foo", "foo", 3}, instead of being {1, "foo", 3}.

        state 1                            state 2
    +-----------------+             +-----------------+
    |  a = {1, 2, 3}; |    ====>    |  a = {1, 2, 3}; | 
    |  a[0] = "foo";  |             |  a[1] = "foo";  |
    +-----------------+             +-----------------+
    
  • Case 2: Multiple assignment to a variable
    Code block node below is modified from state 1 to state 2. Delta AST nodes are empty, so the value a will still be 2 instead of being 1.

      state 1                   state 2
    +----------+             +----------+
    |  a = 1;  |    ====>    |  a = 1;  | 
    |  a = 2;  |             |          |
    +----------+             +----------+
    
  • Case 3: Change order
    Code block node below is modified from state 1 to state 2. Delta AST nodes are empty, so the value a will still be 2 instead of being 1.

      state 1                   state 2
    +----------+             +----------+
    |  a = 1;  |    ====>    |  a = 2;  | 
    |  a = 2;  |             |  a = 1;  |
    +----------+             +----------+
    

To make delta computation work correctly, the VM should be able to undo changes. E.g., undoing a = 2 in case 3 and including this undo operation in delta AST nodes, but it is impossible in current VM implementation, not to mention if some execution incur side-effects on external world (like deleting a file).

In all, delta computation on code block node should be disabled. In the long term, we might disable delta computation completely.

Note disabling delta computation doesn't fix all issues. It could still fail at the following case where change comes from other node:

+----------+         +----------------------+
|  x = 1;  +-------->| x  | a = {1, 2, 3};  | 
|          |         |    | a[x] = "foo";   | 
+----------+         +----------------------+

In this case we have to do force re-execution of code block node if any upstream node is modified.

Declarations

Check these if you believe they are true

  • The code base is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Follows Semantic Versioning standards (No change of public methods or types etc..)

FYIs

@monikaprabhu @riteshchandawar @Benglin @sharadkjaiswal @aparajit-pratap

@ke-yu ke-yu merged commit b59d6d7 into DynamoDS:master Oct 20, 2016
@ke-yu ke-yu deleted the cbn-force-execution branch October 21, 2016 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant