Skip to content

FLUID-6395: Initial test case to investigate fan-out relay problems #1078

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/framework/core/js/DataBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@ fluid.relayRecursionBailout = 100;
// is transactional but it does not require the transaction to conclude in order to fire - it may be reused as many times as
// required within the "overall" transaction whilst genuine (external) changes continue to arrive.

fluid.count = 0;

// TODO: Vast overcomplication and generation of closure garbage. SURELY we should be able to convert this into an externalised, arg-ist form
/** Registers a listener operating one leg of a model relay relation, connecting the source and target. Called once or twice from `fluid.connectModelRelay` -
* see the comment there for the three cases involved. Note that in its case iii)B) the applier to bind to is not the one attached to `target` but is instead
Expand Down Expand Up @@ -882,6 +884,9 @@ fluid.registerDirectChangeRelay = function (target, targetSegs, source, sourceSe
}
var transEl = transRec[applierId];
transRec[linkId] = transRec[linkId] || 0;
++fluid.count;
//fluid.log("SourceListener " + fluid.count + " firing with value " + JSON.stringify(newValue, null, 2) + " from source ", source, " to target ", target,
// " sourceSegs ", sourceSegs, " targetSegs ", targetSegs);
// Crude "oscillation prevention" system limits each link to maximum of 2 operations per cycle (presumably in opposite directions)
var relay = true; // TODO: See FLUID-5303 - we currently disable this check entirely to solve FLUID-5293 - perhaps we might remove link counts entirely
if (relay) {
Expand Down
83 changes: 83 additions & 0 deletions tests/framework-tests/core/js/DataBindingTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,89 @@ jqUnit.test("FLUID-6390 V: Updating lensed components as an array", function ()
fluid.tests.fluid6390assertModelValues("Updated model values are correct", that, []);
});

/** FLUID-6395 - Performance in fan-out of relays **/

fluid.tests.fluid6395generate = function (fanOut) {
return fluid.generate(fanOut, function (index) {
return {
value: index
};
}, true);
};

fluid.defaults("fluid.tests.fluid6395root", {
gradeNames: "fluid.modelComponent",
fanOut: 200,
model: {
modelSource: "@expand:fluid.tests.fluid6395generate({that}.options.fanOut)"
},
dynamicComponents: {
child: {
sources: "{that}.model.modelSource",
type: "fluid.modelComponent",
options: {
model: {
value: "{source}.value"
}
}
}
}
});

jqUnit.test("FLUID-6395: Performance of relay rules with increasing fan-out - fine-grained sharing", function () {
var that = fluid.tests.fluid6395root();
var children = fluid.queryIoCSelector(that, "fluid.modelComponent");
jqUnit.assertEquals("Constructed " + that.options.fanOut + " children: ", that.options.fanOut, children.length);
var now = Date.now();
children[0].applier.change("value", 999);
var elapsed = Date.now() - now;
jqUnit.assertEquals("Change relayed to parent model ", 999, that.model.modelSource[0].value);
fluid.log("Applied change in " + elapsed + "ms");
});

fluid.defaults("fluid.tests.fluid6395root2", {
gradeNames: "fluid.modelComponent",
fanOut: 100,
source: "@expand:fluid.tests.fluid6395generate({that}.options.fanOut)",
model: {
focus: {row: 0, col: 0}
},
components: {
midChild: {
type: "fluid.modelComponent",
options: {
model: {
focus: "{fluid6395root2}.model.focus"
}
}
}
},
dynamicComponents: {
child: {
sources: "{that}.options.source",
type: "fluid.modelComponent",
options: {
model: {
focus: "{midChild}.model.focus"
}
}
}
}
});

jqUnit.test("FLUID-6395 II: Performance of relay rules with increasing fan-out - coarse-grained sharing", function () {
var that = fluid.tests.fluid6395root2();
var children = fluid.queryIoCSelector(that, "fluid.modelComponent");
jqUnit.assertEquals("Constructed " + that.options.fanOut + " children: ", that.options.fanOut + 1, children.length);
var now = Date.now();
children[1].applier.change("focus", {row: 7, col: 5});
fluid.count = 0;
// that.applier.change("someValue", 999);
var elapsed = Date.now() - now;
jqUnit.assertEquals("Change relayed to parent model ", 7, that.model.focus.row);
fluid.log("Applied change in " + elapsed + "ms");
});

/** FLUID-6570: Short-form free transforms **/

fluid.defaults("fluid.tests.fluid6570root", {
Expand Down