Skip to content

chore: removed klona completely in setupUpdateTree#40021

Merged
vsvamsi1 merged 1 commit intoreleasefrom
test71
Apr 3, 2025
Merged

chore: removed klona completely in setupUpdateTree#40021
vsvamsi1 merged 1 commit intoreleasefrom
test71

Conversation

@vsvamsi1
Copy link
Contributor

@vsvamsi1 vsvamsi1 commented Apr 1, 2025

Description

We earlier had an issue where the oldUnEvalTree was getting mutated, it happened because of some properties of updatedUnevalTree were getting tied to evalTree in the getEvaluationOrder function. So any mutation on evalTree which definitely will happen in the subsequent steps in the evalAndValidateSubTree function would affect oldUnEvalTree. To prevent this mutation we previously performed a deepClone which had a cost in performance and this executed in evalTreeWithChanges and evalTree further exacerbating performance.
To fix it we performed a deepClone on specific paths of updatedUnevalTree to evalTree thereby when make an assignment of updatedUnevalTree to oldUnvalTree these deepClones isolate mutations.
This has led to a 0.3 seconds in LCP and reduces the overall webworker scripting by 9-10%.

Fixes #Issue Number
or
Fixes Issue URL

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

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/14223540588
Commit: c1006f7
Cypress dashboard.
Tags: @tag.All
Spec:


Wed, 02 Apr 2025 16:44:05 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • Tests
    • Updated evaluation test assertions to focus on performance expectations rather than strict operation counts.
  • New Features
    • Introduced a method to directly set historical evaluation data, improving clarity and functionality in the evaluation workflow.
    • Renamed and modified the evaluation order method to enhance clarity regarding its functionality.

@vsvamsi1 vsvamsi1 added the ok-to-test Required label for CI label Apr 1, 2025
@vsvamsi1 vsvamsi1 requested a review from rajatagrawal April 1, 2025 20:24
@vsvamsi1 vsvamsi1 self-assigned this Apr 1, 2025
@vsvamsi1 vsvamsi1 requested a review from ApekshaBhosale as a code owner April 1, 2025 20:24
@vsvamsi1 vsvamsi1 marked this pull request as draft April 1, 2025 20:24
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 1, 2025

Walkthrough

The changes update both test and production code within the DataTreeEvaluator module. In the test file, the strict assertion on the call count for klonaFullSpy has been replaced with a comment noting its performance-related nature, along with a TODO for future improvement. In the production module, a new method setOldUnevalTree has been added, and the existing method getEvaluationOrder has been renamed to getEvaluationOrderAndSetEvalTreeWithNewUnevalTreeValues to reflect its enhanced functionality. The setupTree method has also been updated to accommodate these changes.

Changes

File(s) Change Summary
app/client/.../Evaluation/tests/evaluation.test.ts Modified test case: Removed explicit assertion for klonaFullSpy call count, added a comment and TODO regarding performance considerations; klonaJsonSpy assertion remains unchanged.
app/client/.../DataTreeEvaluator/index.ts Added new method setOldUnevalTree(oldUnEvalTree: UnEvalTree), renamed getEvaluationOrder to getEvaluationOrderAndSetEvalTreeWithNewUnevalTreeValues, and updated setupTree to use the new flow without cloning the updated evaluation tree.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant DataTreeEvaluator

    Caller->>DataTreeEvaluator: setupTree()
    DataTreeEvaluator->>DataTreeEvaluator: getEvaluationOrderAndSetEvalTreeWithNewUnevalTreeValues(...)
    DataTreeEvaluator->>DataTreeEvaluator: setOldUnevalTree(newUnEvalTree)
    Note right of DataTreeEvaluator: Evaluation order set with updated unevaluated tree values
Loading

Possibly related PRs

Suggested labels

Task

Suggested reviewers

  • ApekshaBhosale
  • rajatagrawal
  • dvj1988

Poem

In code we dance with changes light,
New methods spark the code so bright,
Tests evolve with thoughtful care,
As functions flow with flair and dare,
Cheers to developers for their might!
🚀✨ Happy coding!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 790c135 and c1006f7.

📒 Files selected for processing (2)
  • app/client/src/workers/Evaluation/__tests__/evaluation.test.ts (1 hunks)
  • app/client/src/workers/common/DataTreeEvaluator/index.ts (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/workers/Evaluation/tests/evaluation.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
🔇 Additional comments (7)
app/client/src/workers/common/DataTreeEvaluator/index.ts (7)

248-250: Well-structured accessor for oldUnEvalTree property.

Adding this dedicated setter method improves code organization and provides a clear entry point for modifying the oldUnEvalTree property.


595-596: Good clarifying comment about parameter immutability.

The comment effectively explains why this approach is safe, noting that getDataTreeContext declares the parameter as Readonly, preventing mutation.


615-616: Clear documentation about immutability guarantees.

These comments provide important context about why these variables don't cause mutation issues, which is critical for understanding the code's behavior and maintaining it in the future.

Also applies to: 622-623


782-812: Improved method name reflects dual responsibility.

The renamed method now clearly communicates that it both retrieves evaluation order and updates evalTree with values from unEvalTree. The implementation properly clones unEvalPropValue before assignment to prevent reference sharing between trees.


814-814: Good documentation of immutability expectations.

This comment establishes an important invariant that setupTree should treat updatedUnEvalTree as immutable, which helps prevent accidental mutations in this method or by future developers.


843-848: Updated method call to use descriptive name.

The code properly uses the renamed method with appropriately updated parameter structure.


864-867: Performance optimization by removing unnecessary deep cloning.

This change effectively addresses the goal of the PR by eliminating the deep clone operation. The comments above explain the previous issue and how the new approach addresses it by maintaining independence between trees.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Apr 1, 2025
@vsvamsi1 vsvamsi1 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 2, 2025
@vsvamsi1 vsvamsi1 marked this pull request as ready for review April 2, 2025 14:39
@vsvamsi1 vsvamsi1 requested review from dvj1988 and removed request for ApekshaBhosale April 2, 2025 14:39
@vsvamsi1 vsvamsi1 force-pushed the test71 branch 2 times, most recently from 8e9b8ef to 790c135 Compare April 2, 2025 15:14
@vsvamsi1 vsvamsi1 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 2, 2025
@vsvamsi1 vsvamsi1 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Apr 2, 2025
@vsvamsi1 vsvamsi1 merged commit 4429589 into release Apr 3, 2025
89 checks passed
@vsvamsi1 vsvamsi1 deleted the test71 branch April 3, 2025 09:57
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
## Description
We earlier had an issue where the oldUnEvalTree was getting mutated, it
happened because of some properties of updatedUnevalTree were getting
tied to evalTree in the getEvaluationOrder function. So any mutation on
evalTree which definitely will happen in the subsequent steps in the
evalAndValidateSubTree function would affect oldUnEvalTree. To prevent
this mutation we previously performed a deepClone which had a cost in
performance and this executed in evalTreeWithChanges and evalTree
further exacerbating performance.
To fix it we performed a deepClone on specific paths of
updatedUnevalTree to evalTree thereby when make an assignment of
updatedUnevalTree to oldUnvalTree these deepClones isolate mutations.
This has led to a 0.3 seconds reduction in LCP and reduces the overall webworker
scripting by 9-10%.

Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!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/14223540588>
> Commit: c1006f7
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=14223540588&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Wed, 02 Apr 2025 16:44:05 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **Tests**
- Updated evaluation test assertions to focus on performance
expectations rather than strict operation counts.
- **New Features**
- Introduced a method to directly set historical evaluation data,
improving clarity and functionality in the evaluation workflow.
- Renamed and modified the evaluation order method to enhance clarity
regarding its functionality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants