Skip to content

chore: Skip unnecessary RTS calls to optimise performance#37949

Merged
subrata71 merged 5 commits intoreleasefrom
chore/skip-unnecessary-rts-calls
Dec 5, 2024
Merged

chore: Skip unnecessary RTS calls to optimise performance#37949
subrata71 merged 5 commits intoreleasefrom
chore/skip-unnecessary-rts-calls

Conversation

@subrata71
Copy link
Collaborator

@subrata71 subrata71 commented Dec 4, 2024

Description

Motivation came from this PoC

Fixes #37948

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/12181005719
Commit: d1f53e2
Cypress dashboard.
Tags: @tag.All
Spec:


Thu, 05 Dec 2024 15:10:54 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling in the binding refactoring process to ensure smoother operation.
  • Refactor

    • Enhanced efficiency of the binding refactoring method by adding a conditional check to reduce unnecessary server calls.
  • Tests

    • Introduced a new test suite for the binding refactoring method, validating various scenarios to ensure correct functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Warning

Rate limit exceeded

@subrata71 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 58 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 5631c65 and d1f53e2.

Walkthrough

The changes made to the AstServiceCEImpl class focus on the refactorNameInDynamicBindings method. A new conditional check has been added to return the original bindingValue when the oldName is not present, avoiding unnecessary calls to the RTS server. The error handling has been clarified, maintaining the existing behavior of ignoring errors during the refactoring process. Overall, these modifications enhance the method's efficiency without altering the public method signatures.

Changes

File Change Summary
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AstServiceCEImpl.java Refactored refactorNameInDynamicBindings method to add a conditional check and clarify error handling.
app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ASTServiceCETest.java Added unit tests for refactorNameInDynamicBindings, covering various scenarios including null bindings, unchanged bindings, valid bindings, JS object requests, and no matching old names.

Assessment against linked issues

Objective Addressed Explanation
Skip unnecessary RTS calls to optimise performance during refactoring (#37948)

Suggested labels

Test

Suggested reviewers

  • sharat87
  • abhvsn

Poem

In the code where bindings play,
A check was added, brightening the day.
With fewer calls to the server's might,
Refactoring now feels just right!
Errors ignored, the flow stays smooth,
Optimized paths, we find our groove! 🎉


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.

@github-actions github-actions bot added AST-backend Backend issues related to AST parsing Backend This marks the issue or pull request to reference server code Javascript Product Issues related to users writing javascript in appsmith Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod Query & JS Pod Issues related to the query & JS Pod Task A simple Todo skip-changelog Adding this label to a PR prevents it from being listed in the changelog labels Dec 4, 2024
@subrata71 subrata71 added the ok-to-test Required label for CI label Dec 4, 2024
@subrata71 subrata71 self-assigned this Dec 4, 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 and nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AstServiceCEImpl.java (1)

146-156: Consider adding performance metrics for skipped calls.

While we have monitoring for slow RTS calls, it would be valuable to track how many calls we're avoiding with this optimization.

Add metrics before the early return:

     if (!bindingValue.getValue().contains(oldName)) {
+        log.debug("Skipping RTS call for binding: {}", bindingValue);
         return Mono.just(Tuples.of(bindingValue, bindingValue.getValue()));
     }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9c669dd and 847bc62.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AstServiceCEImpl.java (1 hunks)
🔇 Additional comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/AstServiceCEImpl.java (1)

147-155: Optimization looks good and aligns with PR objectives.

The early return for bindings that don't contain the oldName is a good optimization that will reduce unnecessary RTS calls. The example in the comments clearly illustrates the use case.

Let's verify the impact of this optimization:

@subrata71
Copy link
Collaborator Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

github-actions bot commented Dec 4, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12164120141.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 37949.
recreate: .

@github-actions
Copy link

github-actions bot commented Dec 4, 2024

Deploy-Preview-URL: https://ce-37949.dp.appsmith.com

@subrata71 subrata71 requested a review from nidhi-nair December 5, 2024 08:49
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 and nitpick comments (3)
app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ASTServiceCETest.java (3)

24-34: Consider adding descriptive assertions for better test documentation.

While the test correctly verifies empty results, adding assertNext with descriptive assertions would make the test's intent clearer.

- StepVerifier.create(result).verifyComplete();
+ StepVerifier.create(result)
+   .expectNextCount(0)
+   .verifyComplete();

69-69: Fix misleading comment.

The comment "Only one binding refactored" is incorrect as both bindings are being refactored in this test case.

- assertThat(map).hasSize(2); // Only one binding refactored
+ assertThat(map).hasSize(2); // Both bindings should be refactored

76-101: Consider extracting test strings as constants.

For better maintainability and reusability, consider extracting the input and expected output scripts as private static constants.

+ private static final String INPUT_JS_SCRIPT = "export default { myFun1() { Api1.run(); return Api1.data;}}";
+ private static final String EXPECTED_JS_SCRIPT = "export default { myFun1() { GetUsers.run(); return GetUsers.data;}}";
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 847bc62 and 83a3a83.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ASTServiceCETest.java (1 hunks)
🔇 Additional comments (3)
app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ASTServiceCETest.java (3)

1-23: LGTM! Well-structured test class setup.

The class is properly configured with Spring Boot test annotations and has all necessary dependencies.


36-54: LGTM! Test validates optimization for unchanged bindings.

This test case effectively validates the PR's objective of skipping unnecessary RTS calls when the oldName is not present in bindings.


103-127: LGTM! Critical test for optimization scenario.

This test effectively validates that the service returns the original script without processing when no matches are found, which is crucial for the performance optimization goal.

@github-actions
Copy link

github-actions bot commented Dec 5, 2024

Failed server tests

  • com.appsmith.server.services.ce.ASTServiceCETest#refactorNameInDynamicBindings_whenValidJSObjectRequest_thenReturnUpdatedScript

@subrata71 subrata71 requested a review from nidhi-nair December 5, 2024 13:45
@github-actions
Copy link

github-actions bot commented Dec 5, 2024

Failed server tests

  • com.appsmith.server.git.ServerSchemaMigrationEnforcerTest#saveGitRepo_ImportAndThenExport_diffOccurs

@subrata71 subrata71 merged commit 6d41e77 into release Dec 5, 2024
@subrata71 subrata71 deleted the chore/skip-unnecessary-rts-calls branch December 5, 2024 15:14
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Dec 9, 2024
…g#37949)

## Description
Motivation came from this
[PoC](https://www.notion.so/appsmith/Evaluating-Performance-Bottlenecks-in-Pull-Based-Upgrades-Challenges-with-New-Relic-Telemetry-14bfe271b0e28063b9fdc08515ab3014)


Fixes appsmithorg#37948

## 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/12181005719>
> Commit: d1f53e2
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12181005719&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Thu, 05 Dec 2024 15:10:54 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **Bug Fixes**
- Improved error handling in the binding refactoring process to ensure
smoother operation.

- **Refactor**
- Enhanced efficiency of the binding refactoring method by adding a
conditional check to reduce unnecessary server calls.

- **Tests**
- Introduced a new test suite for the binding refactoring method,
validating various scenarios to ensure correct 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

AST-backend Backend issues related to AST parsing Backend This marks the issue or pull request to reference server code Javascript Product Issues related to users writing javascript in appsmith ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git Packages Pod issues that belong to the packages pod Query & JS Pod Issues related to the query & JS Pod skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Skip unnecessary RTS calls to optimise performance during refactoring

2 participants