chore: using micro diff for js objects instead of deepDiff (#32581)
## Description Using micro diff instead of deepDiff for diffing jsobjects in setupUpdateTree. Have observed a 33% reduction in webworker scripting through this on a customer's application. Fixes #15953 > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8644903634> > Commit: f5e4c0fb7d4ebba7c35f03c1cee079b53712cc3c > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8644903634&attempt=2" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results -->
This commit is contained in:
parent
271dca0296
commit
cfd6cc8fce
|
|
@ -146,6 +146,7 @@
|
|||
"marked": "^4.0.18",
|
||||
"memoize-one": "^6.0.0",
|
||||
"micro-memoize": "^4.0.10",
|
||||
"microdiff": "^1.4.0",
|
||||
"moment": "2.29.4",
|
||||
"moment-timezone": "^0.5.35",
|
||||
"nanoid": "^2.0.4",
|
||||
|
|
|
|||
|
|
@ -992,3 +992,30 @@ export const isNotEntity = (entity: DataTreeEntity) => {
|
|||
export const isEntityAction = (entity: DataTreeEntity) => {
|
||||
return isAction(entity);
|
||||
};
|
||||
export const convertMicroDiffToDeepDiff = (
|
||||
microDiffDifferences: Record<string, any>[],
|
||||
) =>
|
||||
microDiffDifferences.map((v: Record<string, any>) => {
|
||||
const { oldValue, path, type, value } = v;
|
||||
//convert microDiff format to deepDiff format
|
||||
if (type === "CREATE") {
|
||||
return {
|
||||
kind: "N",
|
||||
path,
|
||||
rhs: value,
|
||||
};
|
||||
}
|
||||
if (type === "REMOVE") {
|
||||
return {
|
||||
kind: "D",
|
||||
path,
|
||||
lhs: oldValue,
|
||||
};
|
||||
}
|
||||
return {
|
||||
kind: "E",
|
||||
path,
|
||||
lhs: oldValue,
|
||||
rhs: value,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import type {
|
|||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||
import { ENTITY_TYPE } from "@appsmith/entities/DataTree/types";
|
||||
import type { DataTreeDiff } from "@appsmith/workers/Evaluation/evaluationUtils";
|
||||
import { convertMicroDiffToDeepDiff } from "@appsmith/workers/Evaluation/evaluationUtils";
|
||||
|
||||
import {
|
||||
addDependantsOfNestedPropertyPaths,
|
||||
|
|
@ -127,6 +128,7 @@ import { DependencyMapUtils } from "entities/DependencyMap/DependencyMapUtils";
|
|||
import { isWidgetActionOrJsObject } from "@appsmith/entities/DataTree/utils";
|
||||
import DataStore from "workers/Evaluation/dataStore";
|
||||
import { updateTreeWithData } from "workers/Evaluation/dataStore/utils";
|
||||
import microDiff from "microdiff";
|
||||
import {
|
||||
profileFn,
|
||||
type WebworkerSpanData,
|
||||
|
|
@ -501,7 +503,6 @@ export default class DataTreeEvaluator {
|
|||
//get difference in js collection body to be parsed
|
||||
const oldUnEvalTreeJSCollections = getJSEntities(this.oldUnEvalTree);
|
||||
const localUnEvalTreeJSCollection = getJSEntities(localUnEvalTree);
|
||||
|
||||
const jsDifferences: Diff<
|
||||
Record<string, JSActionEntity>,
|
||||
Record<string, JSActionEntity>
|
||||
|
|
@ -509,12 +510,13 @@ export default class DataTreeEvaluator {
|
|||
"SetupUpdateTree.Diff1",
|
||||
undefined,
|
||||
webworkerTelemetry,
|
||||
() => {
|
||||
return (
|
||||
diff(oldUnEvalTreeJSCollections, localUnEvalTreeJSCollection) || []
|
||||
);
|
||||
},
|
||||
() =>
|
||||
convertMicroDiffToDeepDiff(
|
||||
microDiff(oldUnEvalTreeJSCollections, localUnEvalTreeJSCollection) ||
|
||||
[],
|
||||
),
|
||||
);
|
||||
|
||||
const jsTranslatedDiffs = flatten(
|
||||
jsDifferences.map((diff) =>
|
||||
translateDiffEventToDataTreeDiffEvent(diff, localUnEvalTree),
|
||||
|
|
|
|||
|
|
@ -13314,6 +13314,7 @@ __metadata:
|
|||
marked: ^4.0.18
|
||||
memoize-one: ^6.0.0
|
||||
micro-memoize: ^4.0.10
|
||||
microdiff: ^1.4.0
|
||||
moment: 2.29.4
|
||||
moment-timezone: ^0.5.35
|
||||
msw: ^0.28.0
|
||||
|
|
@ -24707,6 +24708,13 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"microdiff@npm:^1.4.0":
|
||||
version: 1.4.0
|
||||
resolution: "microdiff@npm:1.4.0"
|
||||
checksum: 4cae2ec4d0540b65656837a7c47a17d6428a1be2909d268a579921183c9c21a86e0dfa0c8ade8c60f9127887783a17d54ce7be16d5556708a0e58312bca8803d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"micromatch@npm:4.0.5, micromatch@npm:^4.0.0, micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:^4.0.5":
|
||||
version: 4.0.5
|
||||
resolution: "micromatch@npm:4.0.5"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user