From 361b4f523509389ff74081fe8105ee40e29d35c1 Mon Sep 17 00:00:00 2001 From: Vemparala Surya Vamsi Date: Tue, 17 Dec 2024 17:08:07 +0530 Subject: [PATCH 1/3] small fix --- app/client/src/sagas/EvaluationsSaga.ts | 50 +++++++++++++++++++------ 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index d1dc2dfe075d..841e8f4e79a1 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -6,6 +6,7 @@ import { delay, fork, put, + race, select, spawn, take, @@ -753,21 +754,48 @@ function* evaluationChangeListenerSaga(): any { EVAL_AND_LINT_REDUX_ACTIONS, evalQueueBuffer(), ); + let hasTriggerAction = false; while (true) { - const action: EvaluationReduxAction = - yield take(evtActionChannel); + const { action, timeout } = yield race({ + action: take(evtActionChannel), + timeout: delay(1000), + }); - // We are dequing actions from the buffer and inferring the JS actions affected by each - // action. Through this we know ahead the nodes we need to specifically diff, thereby improving performance. - const affectedJSObjects = getAffectedJSObjectIdsFromAction(action); + if (action?.type === ReduxActionTypes.TRIGGER_EVAL) { + hasTriggerAction = true; + continue; + } - yield call(evalAndLintingHandler, true, action, { - shouldReplay: get(action, "payload.shouldReplay"), - forceEvaluation: shouldForceEval(action), - requiresLogging: shouldLog(action), - affectedJSObjects, - }); + if (timeout) { + if (hasTriggerAction) { + const action = { + type: ReduxActionTypes.TRIGGER_EVAL, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any; + const affectedJSObjects = getAffectedJSObjectIdsFromAction(action); + + yield call(evalAndLintingHandler, true, action, { + shouldReplay: get(action, "payload.shouldReplay"), + forceEvaluation: shouldForceEval(action), + requiresLogging: shouldLog(action), + affectedJSObjects, + }); + } + } else { + // We are dequing actions from the buffer and inferring the JS actions affected by each + // action. Through this we know ahead the nodes we need to specifically diff, thereby improving performance. + const affectedJSObjects = getAffectedJSObjectIdsFromAction(action); + + yield call(evalAndLintingHandler, true, action, { + shouldReplay: get(action, "payload.shouldReplay"), + forceEvaluation: shouldForceEval(action), + requiresLogging: shouldLog(action), + affectedJSObjects, + }); + } + + hasTriggerAction = false; } } From 0bcb2a685065d84c89862117a00fb02c3f302e26 Mon Sep 17 00:00:00 2001 From: Vemparala Surya Vamsi Date: Wed, 18 Dec 2024 00:00:14 +0530 Subject: [PATCH 2/3] batching buffered and evalTrigger --- app/client/src/sagas/EvaluationsSaga.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index 841e8f4e79a1..38c2faa04449 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -59,7 +59,7 @@ import { import type { JSAction, JSCollection } from "entities/JSCollection"; import { getAppMode } from "ee/selectors/applicationSelectors"; import { APP_MODE } from "entities/App"; -import { get, isEmpty } from "lodash"; +import { get, isEmpty, isEqual } from "lodash"; import type { TriggerMeta } from "ee/sagas/ActionExecution/ActionExecutionSagas"; import { executeActionTriggers } from "ee/sagas/ActionExecution/ActionExecutionSagas"; import { @@ -762,17 +762,18 @@ function* evaluationChangeListenerSaga(): any { timeout: delay(1000), }); - if (action?.type === ReduxActionTypes.TRIGGER_EVAL) { + if ( + action?.type === ReduxActionTypes.TRIGGER_EVAL || + isEqual(action, bufferedAction) + ) { hasTriggerAction = true; continue; } if (timeout) { if (hasTriggerAction) { - const action = { - type: ReduxActionTypes.TRIGGER_EVAL, - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } as any; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const action = bufferedAction as any; const affectedJSObjects = getAffectedJSObjectIdsFromAction(action); yield call(evalAndLintingHandler, true, action, { @@ -799,6 +800,15 @@ function* evaluationChangeListenerSaga(): any { } } +const bufferedAction = { + postEvalActions: [], + affectedJSObjects: { + isAllAffected: false, + ids: [], + }, + type: "BUFFERED_ACTION", +}; + // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any export function* evaluateActionSelectorFieldSaga(action: any) { From b01a1b88cdd46be551ea09f6bf655ea914d07054 Mon Sep 17 00:00:00 2001 From: Vemparala Surya Vamsi Date: Wed, 18 Dec 2024 01:21:41 +0530 Subject: [PATCH 3/3] batching updateSuccess --- app/client/src/sagas/EvaluationsSaga.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/client/src/sagas/EvaluationsSaga.ts b/app/client/src/sagas/EvaluationsSaga.ts index 38c2faa04449..74d1701ecfd4 100644 --- a/app/client/src/sagas/EvaluationsSaga.ts +++ b/app/client/src/sagas/EvaluationsSaga.ts @@ -764,7 +764,8 @@ function* evaluationChangeListenerSaga(): any { if ( action?.type === ReduxActionTypes.TRIGGER_EVAL || - isEqual(action, bufferedAction) + isEqual(action, bufferedAction) || + isEqual(action, batchUpdateSuccess) ) { hasTriggerAction = true; continue; @@ -808,6 +809,15 @@ const bufferedAction = { }, type: "BUFFERED_ACTION", }; +const batchUpdateSuccess = { + type: "BATCH_UPDATES_SUCCESS", + payload: [ + { + type: "META_UPDATE_DEBOUNCED_EVAL", + payload: {}, + }, + ], +}; // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any