Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: converted isNewEntity lookup to use a set #38264

Merged
merged 1 commit into from
Dec 20, 2024
Merged

chore: converted isNewEntity lookup to use a set #38264

merged 1 commit into from
Dec 20, 2024

Conversation

vsvamsi1
Copy link
Contributor

@vsvamsi1 vsvamsi1 commented Dec 19, 2024

Description

Converted the lookup the in isNewEntity to use a Set, this has reduced the cost of webworker scripting by about 5%.

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/12415891373
Commit: 5dfc7a0
Cypress dashboard.
Tags: @tag.All
Spec:


Thu, 19 Dec 2024 16:55:57 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced evaluation logic for newly created entities.
    • Improved error handling for dynamic bindings during evaluations.
  • Bug Fixes

    • Refined error tracking for property evaluations.
  • Documentation

    • Minor updates to comments and formatting for clarity.

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

coderabbitai bot commented Dec 19, 2024

Walkthrough

The pull request introduces modifications to the evaluation utilities in the CodeRabbit application, focusing on entity tracking and evaluation processes. The changes primarily affect how new entities are identified and processed during tree evaluations. The modifications streamline the logic for detecting new entities by switching from array-based to set-based lookups and enhance error handling in dynamic binding evaluations.

Changes

File Change Summary
app/client/src/ce/workers/Evaluation/evaluationUtils.ts - Updated isNewEntity function signature from array to set-based lookup
- Removed lodash find method import
app/client/src/workers/common/DataTreeEvaluator/index.ts - Added allNewEntityDiffSet to track new entity paths
- Enhanced error handling for dynamic binding evaluations
- Updated evaluateTree, generateJSObjectUpdates, and setupUpdateTree methods

Possibly related PRs

Suggested labels

skip-changelog

Suggested reviewers

  • rajatagrawal
  • ApekshaBhosale
  • dvj1988

Poem

🌟 Code transforms, set takes flight
Arrays bow down to efficiency's might
Evaluation dances, nimble and bright
New entities sparkle with algorithmic delight
Performance sings its elegant song! 🚀


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>, 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 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.

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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e22dbd1 and 5dfc7a0.

📒 Files selected for processing (2)
  • app/client/src/ce/workers/Evaluation/evaluationUtils.ts (2 hunks)
  • app/client/src/workers/common/DataTreeEvaluator/index.ts (2 hunks)
🔇 Additional comments (1)
app/client/src/workers/common/DataTreeEvaluator/index.ts (1)

1206-1206: Consider verifying the behavior of "isNewEntity".
Because isNewEntity uses updates.has(entityName), it will never match unless the set contains the exact entity name. If the set instead stores “Table1.someProp”, the check for “Table1” will fail.

Comment on lines +1095 to +1099
const allNewEntityDiffSet = new Set(
unevalUpdates
.filter((v) => v.event === DataTreeDiffEvent.NEW)
.map((v) => v.payload.propertyPath),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential mismatch when storing entity property paths in a set.
Currently, this code stores the entire property path (e.g., "Table1.selectedRow") in allNewEntityDiffSet, then checks for membership with just the entity name (e.g., "Table1"). This will fail if the property path includes anything more than the entity name.

A possible fix is to store just the entity names in the set, for example:

-const allNewEntityDiffSet = new Set(
-  unevalUpdates
-    .filter((v) => v.event === DataTreeDiffEvent.NEW)
-    .map((v) => v.payload.propertyPath),
-);
+const allNewEntityDiffSet = new Set(
+  unevalUpdates
+    .filter((v) => v.event === DataTreeDiffEvent.NEW)
+    .map((v) => getEntityNameAndPropertyPath(v.payload.propertyPath).entityName),
+);

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +990 to +991
export const isNewEntity = (updates: Set<string>, entityName: string) => {
return updates.has(entityName);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Entity path vs. entity name mismatch.
This function only checks updates.has(entityName), but the set is populated with full property paths in index.ts unless corrected. Ensure that the stored values and this membership check are aligned.

If the goal is to confirm a new entity by name, consider storing only the entity name in the set or changing the membership check to parse out the entity name from the stored path.

@vsvamsi1 vsvamsi1 changed the title converted lookup to set reduces scipting by 0.5 second chore: converted lookup isNewEntity to set Dec 19, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Dec 19, 2024
@vsvamsi1 vsvamsi1 changed the title chore: converted lookup isNewEntity to set chore: converted isNewEntity lookup to use a set Dec 19, 2024
@vsvamsi1 vsvamsi1 requested review from rajatagrawal and removed request for ApekshaBhosale December 19, 2024 17:16
@vsvamsi1 vsvamsi1 merged commit 71c5171 into release Dec 20, 2024
93 checks passed
@vsvamsi1 vsvamsi1 deleted the test56 branch December 20, 2024 05:07
NandanAnantharamu pushed a commit that referenced this pull request Dec 27, 2024
## Description
Converted the lookup the in isNewEntity to use a Set, this has reduced
the cost of webworker scripting by about 5%.

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/12415891373>
> Commit: 5dfc7a0
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12415891373&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Thu, 19 Dec 2024 16:55:57 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**
	- Enhanced evaluation logic for newly created entities.
	- Improved error handling for dynamic bindings during evaluations.

- **Bug Fixes**
	- Refined error tracking for property evaluations.

- **Documentation**
	- Minor updates to comments and formatting for clarity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Feb 7, 2025
## Description
Converted the lookup the in isNewEntity to use a Set, this has reduced
the cost of webworker scripting by about 5%.

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/12415891373>
> Commit: 5dfc7a0
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12415891373&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Thu, 19 Dec 2024 16:55:57 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**
	- Enhanced evaluation logic for newly created entities.
	- Improved error handling for dynamic bindings during evaluations.

- **Bug Fixes**
	- Refined error tracking for property evaluations.

- **Documentation**
	- Minor updates to comments and formatting for clarity.

<!-- 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