Skip to content

chore: makeParentDependedOnChildren optimisation only affected nodes in the graph is computed#36161

Merged
vsvamsi1 merged 2 commits intoreleasefrom
perf1
Sep 11, 2024
Merged

chore: makeParentDependedOnChildren optimisation only affected nodes in the graph is computed#36161
vsvamsi1 merged 2 commits intoreleasefrom
perf1

Conversation

@vsvamsi1
Copy link
Contributor

@vsvamsi1 vsvamsi1 commented Sep 6, 2024

Description

Optimising makeParentDependedOnChildren function by executing makeParentsDependOnChild for only affected nodes in the dependencyMap graph. This has brought down the cumulative latency of execution by about 90% when testing it against a customer's app during page load.

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/10791040934
Commit: 902f465
Cypress dashboard.
Tags: @tag.All
Spec:


Tue, 10 Sep 2024 12:20:44 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a method for linking child nodes to parent nodes in the dependency graph, allowing for more precise management of affected nodes.
    • Added new helper functions to streamline the addition of affected nodes and dependencies within the dependency map.
  • Bug Fixes

    • Enhanced testing coverage for the dependency linking logic, ensuring accurate representation of hierarchical relationships between nodes.
  • Documentation

    • Improved comments in existing methods to clarify functionality and enhance code readability.

@vsvamsi1 vsvamsi1 self-assigned this Sep 6, 2024
@vsvamsi1 vsvamsi1 added the ok-to-test Required label for CI label Sep 6, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 6, 2024

Walkthrough

The recent changes introduce a new static method in the DependencyMapUtils class to enhance dependency management by linking affected child nodes to their parent nodes. Additionally, helper functions have been added to streamline the addition of affected nodes within the createDependencyMap and updateDependencyMap functions. The modifications also include new test cases to validate the functionality of the new method and improve overall code readability and maintainability.

Changes

Files Change Summary
app/client/src/entities/DependencyMap/DependencyMapUtils.ts Added linkAffectedChildNodesToParent method; clarified existing method with a comment.
app/client/src/entities/DependencyMap/__tests__/index.test.ts Introduced a new test suite for linkAffectedChildNodesToParent with multiple test cases.
app/client/src/workers/common/DependencyMap/index.ts Enhanced createDependencyMap and updateDependencyMap functions with new helper functions for managing dependencies.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DependencyMapUtils
    participant DependencyMap

    User->>DependencyMap: Update Dependency Map
    DependencyMap->>DependencyMapUtils: linkAffectedChildNodesToParent(affectedNodes)
    DependencyMapUtils->>DependencyMap: Link affected child nodes to parents
    DependencyMap-->>User: Dependency Map Updated
Loading

🌟 In the code where dependencies lay,
New methods and tests now brighten the way.
Affected nodes find their place,
In a structured and orderly space.
With clarity and care, the map's now refined,
A dance of dependencies, beautifully aligned! 🌟

Tip

Announcements
  • The review status is no longer posted as a separate comment when there are no actionable or nitpick comments. In such cases, the review status is included in the walkthrough comment.
  • We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs: Walkthrough comment now includes a list of potentially related PRs to help you recall past context. Please share any feedback in the discussion post on our Discord.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs in the walkthrough comment. You can also provide custom labeling instructions in the UI or configuration file.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f9c49e1 and 902f465.

Files selected for processing (3)
  • app/client/src/entities/DependencyMap/DependencyMapUtils.ts (2 hunks)
  • app/client/src/entities/DependencyMap/tests/index.test.ts (1 hunks)
  • app/client/src/workers/common/DependencyMap/index.ts (8 hunks)
Files skipped from review as they are similar to previous changes (3)
  • app/client/src/entities/DependencyMap/DependencyMapUtils.ts
  • app/client/src/entities/DependencyMap/tests/index.test.ts
  • app/client/src/workers/common/DependencyMap/index.ts

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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 Sep 6, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
app/client/src/workers/common/DependencyMap/index.ts (1)

76-81: Helper Function for Affected Nodes Approved

The function addingAffectedNodesToList is correctly implemented to add nodes to the set of affected nodes. It uses a straightforward approach which is efficient for its purpose.

Consider using a more performant iteration method if the number of nodes is large.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 58b07dd and f9c49e1.

Files selected for processing (3)
  • app/client/src/entities/DependencyMap/DependencyMapUtils.ts (2 hunks)
  • app/client/src/entities/DependencyMap/tests/index.test.ts (1 hunks)
  • app/client/src/workers/common/DependencyMap/index.ts (8 hunks)
Additional comments not posted (5)
app/client/src/entities/DependencyMap/DependencyMapUtils.ts (2)

40-40: Comment Clarification Approved

The added comment clarifies the purpose of the method, enhancing code readability and maintainability.


52-69: New Method for Affected Nodes Approved

The method linkChildToItsParentNodeForAffectedChildNodes is well-implemented, focusing on affected nodes to optimize performance. It correctly checks the affectedSet before linking, which should significantly reduce unnecessary computations.

Consider verifying the performance impact of this change with larger datasets to ensure scalability.

app/client/src/workers/common/DependencyMap/index.ts (2)

83-91: Encapsulation of Dependency Map Updates Approved

The function addNodesToDependencyMap correctly encapsulates the logic for adding nodes to the dependency map and updating the affected nodes set. This improves maintainability and reduces duplication.

Verify the handling of the strict parameter in different scenarios to ensure it behaves as expected.


93-99: Setting Dependencies and Updating Affected Nodes Approved

The function setDependenciesToDependencyMap correctly sets dependencies for a node and updates the affected nodes set. This separation of concerns enhances code clarity and maintainability.

Consider checking the performance impact when handling a large number of dependencies to ensure scalability.

app/client/src/entities/DependencyMap/__tests__/index.test.ts (1)

2711-2773: Review of New Test Suite: linkChildToItsParentNodeForAffectedChildNodes

The new test suite introduced in this PR is well-structured and covers several important scenarios:

  1. Linking a child node to its parent node when the child node is affected: This test ensures that the parent node is correctly linked to the affected child node, which is crucial for maintaining the integrity of the dependency graph.
  2. Handling cases where no child nodes are affected: It's important to verify that no unnecessary links are created when there are no affected nodes, which this test successfully checks.
  3. Extending the linking logic to grandparent nodes: This test is particularly valuable as it ensures that the dependency linking is not just superficial but extends throughout the hierarchy, which is essential for complex dependency graphs.

Overall, these tests are crucial for ensuring that the new functionality works as expected and maintains the integrity of the dependency graph in various scenarios. The use of Set for affected nodes and the direct manipulation of dependencies within the DependencyMap are appropriate and align with the objectives of the PR.

@vsvamsi1 vsvamsi1 removed the ok-to-test Required label for CI label Sep 10, 2024
Copy link
Contributor

@rishabhrathod01 rishabhrathod01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than above nit pick, code looks good to me

@vsvamsi1 vsvamsi1 merged commit a77d608 into release Sep 11, 2024
@vsvamsi1 vsvamsi1 deleted the perf1 branch September 11, 2024 04:37
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Sep 26, 2024
…in the graph is computed (appsmithorg#36161)

## Description
Optimising `makeParentDependedOnChildren` function by executing
`makeParentsDependOnChild` for only affected nodes in the dependencyMap
graph. This has brought down the cumulative latency of execution by
about 90% when testing it against a customer's app during page load.

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/10791040934>
> Commit: 902f465
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10791040934&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Tue, 10 Sep 2024 12:20:44 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

- **New Features**
- Introduced a method for linking child nodes to parent nodes in the
dependency graph, allowing for more precise management of affected
nodes.
- Added new helper functions to streamline the addition of affected
nodes and dependencies within the dependency map.

- **Bug Fixes**
- Enhanced testing coverage for the dependency linking logic, ensuring
accurate representation of hierarchical relationships between nodes.

- **Documentation**
- Improved comments in existing methods to clarify functionality and
enhance code readability.
<!-- 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.

2 participants