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

DYN1198- Heterogeneous list update gives infinite loop #9408

Merged
merged 39 commits into from
Jan 12, 2019

Conversation

reddyashish
Copy link
Contributor

@reddyashish reddyashish commented Jan 10, 2019

Purpose

This PR is to fix the Heterogeneous list crash that was reported. The infinite loop happens when more than 2 different data types of inputs are used in a list (like String, Int, Double) and that list is passed to some function.
When calculating replication combinations for a function, there is a "for" loop in Replicator.cs(Lines 217-245) that has a complexity in exponential order. The "reducedParams" list will be containing more than 10^10 possible combinations, which I think is redundant as they are being duplicated. So removed the "for" loop from there and then calculate the value of "arrayStats" (excluding duplicates) from each of the targets in the "targets" list. "arrayStats" will generally have all the distinct types of data that are passed into the function.

The graph "test_hetereogenous_list.dyn" in this PR demonstrates the case which was running into infinite loop before. The infinite loop crash and the regressions that were caught last time(on Dynamo master) are fixed here. However there is one particular case that is failing, as demonstrated in "TestTryGetValuesFromDictionary09" test with the nested dictionaries. This used to fail before but we dint catch it until now.
I have added that test with the "Category : Failure" attribute so that we can revisit this.

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.
  • Changes to the API follow Semantic Versioning, and are documented in the API Changes document.

Reviewers

@aparajit-pratap @QilongTang @mjkkirschner

Use Polysurface.ByJoinedSurfaces node instead.
@mjkkirschner
Copy link
Member

@reddyashish thanks for the write up! 😄

@reddyashish
Copy link
Contributor Author

@aparajit-pratap I have added that failing test now.

@mjkkirschner
Copy link
Member

looks good to me

@mjkkirschner
Copy link
Member

@Racel @aparajit-pratap @reddyashish do we have a general workaround that we can add to the release notes?

@reddyashish
Copy link
Contributor Author

My thought would be to suggest, not using more than one level of nesting for heterogenous lists that are passed to any function.

@@ -117,25 +118,43 @@ public static ClassNode GetGreatestCommonSubclassForArray(StackValue array, Runt
return runtimeCore.DSExecutable.classTable.ClassNodes[orderedTypes.First()];
}

public static Dictionary<int, StackValue> GetTypeExamplesForLayer(StackValue array, RuntimeCore runtimeCore)
public static IEnumerable<StackValue> GetTypeExamplesForLayer(StackValue array, RuntimeCore runtimeCore)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an API break I believe.

Copy link
Member

@mjkkirschner mjkkirschner Jan 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a Dictionary is an System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> not general Ienumerable of T> I don't think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would really appreciate a summary for this method too 😈

Copy link
Contributor

@aparajit-pratap aparajit-pratap Jan 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjkkirschner the problem with GetTypeExamplesForLayer was that it returned with only 1 ArrayPtr even if there were [ArrayPtr, ArrayPtr] but the 2 array pointers can be different. It would always return with the first one.

So it would fail for such cases: [[1,2,3], [{dict}]] and for [[dict], [[dict]]] for the same reason, where dict is any dictionary. The fix is to add all ArrayPtr as unique items in the dictionary and return them.


return usageFreq;
// return flattened list of unique values
return usageFreq.Values.SelectMany(x => x.Select(y => y));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question about selectMany

@mjkkirschner
Copy link
Member

@aparajit-pratap looks good except for the API break and couple questions - can you now remove the failure category from the tests?

@reddyashish
Copy link
Contributor Author

Removed the failure category from the tests and started the self serve.

@aparajit-pratap
Copy link
Contributor

aparajit-pratap commented Jan 12, 2019

@reddyashish I think the self-serve has passed other than the excel tests (which fail all the time). I'm merging this into master for now.

@aparajit-pratap aparajit-pratap merged commit 0559802 into DynamoDS:master Jan 12, 2019
@mjkkirschner
Copy link
Member

@aparajit-pratap are you intending to cherry pick this today?

aparajit-pratap pushed a commit to aparajit-pratap/Dynamo that referenced this pull request Jan 13, 2019
* Heterogenous list crash fix

* Adding test case for heterogeneous list crash

* Adding tests

* Adding new test

* fix remaining edge cases

* revert assemblysharedinfo file

* Updating failing tests

* add new method to prevent API break

* simplify SelectMany
@aparajit-pratap
Copy link
Contributor

@mjkkirschner cherry-picked here: #9415

@reddyashish
Copy link
Contributor Author

Thanks Aparajit.

QilongTang pushed a commit that referenced this pull request Jan 14, 2019
* Heterogenous list crash fix

* Adding test case for heterogeneous list crash

* Adding tests

* Adding new test

* fix remaining edge cases

* revert assemblysharedinfo file

* Updating failing tests

* add new method to prevent API break

* simplify SelectMany
reddyashish added a commit that referenced this pull request Jan 14, 2019
reddyashish added a commit to reddyashish/Dynamo that referenced this pull request May 23, 2019
QilongTang pushed a commit that referenced this pull request May 28, 2019
* Cherry-picking #9388 into 2.0.3

* Cherry-picking #9559 into 2.0.3

* Cherry-picking #9578 into 2.0.3

* cherry-picking #9632 into 2.0.3

* cherry-picking #9408 into 2.0.3

* cherry-picking #9441 into 2.0.3

* Adding gradient.png for the Test_PerforationsByImage test.

This was missed while cherrypicking #9441

* Removing DSCoreDataTests.cs as this was the test fixture was introduced in a different commit and is not needed here.
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.

4 participants