-
Notifications
You must be signed in to change notification settings - Fork 635
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
Conversation
@reddyashish thanks for the write up! 😄 |
@aparajit-pratap I have added that failing test now. |
looks good to me |
@Racel @aparajit-pratap @reddyashish do we have a general workaround that we can add to the release notes? |
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😈
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question about selectMany
@aparajit-pratap looks good except for the API break and couple questions - can you now remove the failure category from the tests? |
Removed the failure category from the tests and started the self serve. |
@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 are you intending to cherry pick this today? |
* 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
@mjkkirschner cherry-picked here: #9415 |
Thanks Aparajit. |
* 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
* 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.
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
*.resx
filesReviewers
@aparajit-pratap @QilongTang @mjkkirschner