fix: improve performance of updateDependency flow (#26391)
### Cause of issue Previously, dependencyMap.addNode() had a O(n^2) complexity. #### PR fixes following issue(s) Fixes https://github.com/appsmithorg/appsmith/issues/26400 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
This commit is contained in:
parent
ff4f4faee3
commit
d78b709c12
|
|
@ -99,6 +99,7 @@
|
||||||
"downloadjs": "^1.4.7",
|
"downloadjs": "^1.4.7",
|
||||||
"echarts": "^5.4.2",
|
"echarts": "^5.4.2",
|
||||||
"fast-deep-equal": "^3.1.3",
|
"fast-deep-equal": "^3.1.3",
|
||||||
|
"fast-sort": "^3.4.0",
|
||||||
"fast-xml-parser": "^3.17.5",
|
"fast-xml-parser": "^3.17.5",
|
||||||
"fastdom": "^1.0.11",
|
"fastdom": "^1.0.11",
|
||||||
"focus-trap-react": "^8.9.2",
|
"focus-trap-react": "^8.9.2",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { difference, some } from "lodash";
|
import { difference } from "lodash";
|
||||||
import { isChildPropertyPath } from "utils/DynamicBindingUtils";
|
import { isChildPropertyPath } from "utils/DynamicBindingUtils";
|
||||||
|
import { sort } from "fast-sort";
|
||||||
|
|
||||||
export type TDependencies = Map<string, Set<string>>;
|
export type TDependencies = Map<string, Set<string>>;
|
||||||
export default class DependencyMap {
|
export default class DependencyMap {
|
||||||
|
|
@ -150,7 +151,10 @@ export default class DependencyMap {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addNodes = (nodes: Record<string, true>, strict = true) => {
|
addNodes = (nodes: Record<string, true>, strict = true) => {
|
||||||
const nodesToAdd = Object.keys(nodes);
|
const nodesToAdd = strict
|
||||||
|
? Object.keys(nodes)
|
||||||
|
: sort(Object.keys(nodes)).desc((node) => node.split(".").length);
|
||||||
|
|
||||||
let didUpdateGraph = false;
|
let didUpdateGraph = false;
|
||||||
for (const newNode of nodesToAdd) {
|
for (const newNode of nodesToAdd) {
|
||||||
if (this.#nodes.has(newNode)) continue;
|
if (this.#nodes.has(newNode)) continue;
|
||||||
|
|
@ -168,14 +172,8 @@ export default class DependencyMap {
|
||||||
for (const [invalidNode, dependants] of this
|
for (const [invalidNode, dependants] of this
|
||||||
.#invalidDependenciesInverse) {
|
.#invalidDependenciesInverse) {
|
||||||
if (
|
if (
|
||||||
!nodesToAdd.includes(invalidNode) &&
|
!nodes.hasOwnProperty(invalidNode) &&
|
||||||
isChildPropertyPath(newNode, invalidNode, true) &&
|
isChildPropertyPath(newNode, invalidNode, true)
|
||||||
!some(
|
|
||||||
nodesToAdd,
|
|
||||||
(node) =>
|
|
||||||
isChildPropertyPath(newNode, node, true) &&
|
|
||||||
isChildPropertyPath(node, invalidNode, true),
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
dependants.forEach((dependant) => {
|
dependants.forEach((dependant) => {
|
||||||
nodesThatAlreadyDependedOnThis.add(dependant);
|
nodesThatAlreadyDependedOnThis.add(dependant);
|
||||||
|
|
|
||||||
|
|
@ -9492,6 +9492,7 @@ __metadata:
|
||||||
esm: ^3.2.25
|
esm: ^3.2.25
|
||||||
factory.ts: ^0.5.1
|
factory.ts: ^0.5.1
|
||||||
fast-deep-equal: ^3.1.3
|
fast-deep-equal: ^3.1.3
|
||||||
|
fast-sort: ^3.4.0
|
||||||
fast-xml-parser: ^3.17.5
|
fast-xml-parser: ^3.17.5
|
||||||
fastdom: ^1.0.11
|
fastdom: ^1.0.11
|
||||||
focus-trap-react: ^8.9.2
|
focus-trap-react: ^8.9.2
|
||||||
|
|
@ -15263,6 +15264,13 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"fast-sort@npm:^3.4.0":
|
||||||
|
version: 3.4.0
|
||||||
|
resolution: "fast-sort@npm:3.4.0"
|
||||||
|
checksum: b925d68438629b7176dc52c6f5bb88162675e88286b6e06041c6fb1095ec44af6aac3edd5b7e09ada044b90bced078a013683d2d75337ae6f5e7224f7e073019
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"fast-xml-parser@npm:^3.17.5":
|
"fast-xml-parser@npm:^3.17.5":
|
||||||
version: 3.17.5
|
version: 3.17.5
|
||||||
resolution: "fast-xml-parser@npm:3.17.5"
|
resolution: "fast-xml-parser@npm:3.17.5"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user