-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix: Reduce RTS calls in the updateLayout flow #37127
Conversation
WalkthroughThe changes involve the removal of a constant from the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Failed server tests
|
- After this change we reduce the RTS calls from 2*N to 2 where N is the no of bindings in the layout.
Failed server tests
|
Failed server tests
|
Failed server tests
|
Failed server tests
|
Failed server tests
|
1 similar comment
Failed server tests
|
Failed server tests
|
Failed server tests
|
1 similar comment
Failed server tests
|
Failed server tests
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
(5 hunks)
🔇 Additional comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (3)
669-669
: LGTM: Parameter type change aligns with batching optimization
The change from Set<String>
to List<String>
supports the PR's objective to optimize RTS calls by enabling batched processing.
702-738
: LGTM: Improved reactive stream handling with batched processing
The changes effectively optimize the processing of widget bindings while maintaining proper reactive stream handling.
1201-1201
: LGTM: Consistent parameter type change
The change to use List
instead of Set
is consistent with the overall optimization strategy.
Failed server tests
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (2)
598-612
: Replace array index tracking with more robust solutionUsing array index for tracking widget paths is error-prone and makes the code harder to maintain. Consider using a more explicit mapping structure.
-Map<Number, String> indexToWidgetPathMap = new HashMap<>(); -int bindingStartIndexInAllBindings = 0; +List<Tuple2<String, List<String>>> widgetPathBindings = new ArrayList<>(); for (Map.Entry<String, Set<String>> entry : widgetDynamicBindingsMap.entrySet()) { String widgetPath = entry.getKey(); Set<String> bindings = entry.getValue(); - allBindings.addAll(bindings); - int numberOfBindingsInPath = bindings.size(); - for (int i = bindingStartIndexInAllBindings; - i < bindingStartIndexInAllBindings + numberOfBindingsInPath; - i++) { - indexToWidgetPathMap.put(i, widgetPath); - } - bindingStartIndexInAllBindings = bindingStartIndexInAllBindings + numberOfBindingsInPath; + widgetPathBindings.add(Tuples.of(widgetPath, new ArrayList<>(bindings))); + allBindings.addAll(bindings); }
669-673
: Add parameter validation for getPossibleEntityParentsMapThe method accepts a List parameter but lacks null/empty validation.
private Mono<Map<String, Set<EntityDependencyNode>>> getPossibleEntityParentsMap( List<String> bindings, int types, int evalVersion) { + if (bindings == null || bindings.isEmpty()) { + return Mono.just(new HashMap<>()); + } Flux<Tuple2<String, Set<String>>> findingToReferencesFlux = astService.getPossibleReferencesFromDynamicBinding(bindings, evalVersion); return MustacheHelper.getPossibleEntityParentsMap(findingToReferencesFlux, types);app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java (1)
939-1001
: Refactor repetitive mock setups in testsConsider refactoring the repeated
Mockito.when()
calls forastService.getPossibleReferencesFromDynamicBinding
into a helper method to improve readability and maintainability.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
(5 hunks)app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java
(2 hunks)
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (1)
1201-1201
: LGTM: Minor optimization to avoid intermediate collection
The change to use ArrayList constructor is a good optimization to avoid creating an intermediate collection.
app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java (1)
527-536
: Verify proper formatting of embedded JavaScript code
Ensure that the embedded JavaScript function within the string is correctly formatted and escaped to avoid runtime errors during execution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (1)
702-735
: Add error handling and documentation for reactive chainThe reactive transformation chain lacks error handling for potential failures in entity reference processing. Consider:
- Adding
.onErrorResume()
handlers for graceful error recovery- Documenting the purpose of each transformation step
- Adding logging for debugging complex scenarios
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
(5 hunks)
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (2)
1201-1201
: LGTM: Consistent with method signature change
The conversion to ArrayList is correctly implemented and maintains consistency with the updated method signature.
669-673
: Consider performance implications of Set to List change
The change from Set<String>
to List<String>
could allow duplicate bindings to be processed. For large collections, this might impact performance. Consider adding a deduplication step or documenting why duplicates are acceptable.
...th-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (2)
669-671
: Method signature change needs documentationThe method signature has been changed from
Set<String>
toList<String>
for the bindings parameter, but lacks documentation explaining the reason for this change.Add Javadoc to explain the change:
+/** + * @param bindings List of bindings to analyze (changed from Set to List to maintain order) + * @param types The types of EntityDependencyNode references to look for + * @param evalVersion Version used for AST parsing + * @return Map of bindings to their possible entity parents + */ private Mono<Map<String, Set<EntityDependencyNode>>> getPossibleEntityParentsMap(
586-657
: New method implements batch processing of bindingsThe implementation correctly handles batch processing of bindings to reduce RTS calls, aligning with the PR objectives.
Consider adding metrics/monitoring to track:
- Average batch size
- Processing time per batch
- Success/failure rates
This will help validate the performance improvements.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
(6 hunks)
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (2)
1221-1221
: Parameter type change matches method signature
The change from Set<String>
to ArrayList<>(widgetBindingEntries.getValue())
aligns with the updated method signature.
Line range hint 702-755
: Verify widget dependency handling
The changes to handle widget dependencies look correct, but we should verify the edge cases.
✅ Verification successful
Widget dependency handling implementation is robust and properly integrated
The implementation correctly:
- Creates widget dependency nodes with proper entity reference type
- Handles widget-to-executable relationships via dependency edges
- Maintains widget bindings in a thread-safe manner using computeIfAbsent
- Properly processes widget paths and dynamic bindings
- Has error boundaries in the layout service implementation
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for potential edge cases in widget dependency handling
rg -A 2 "widgetDependencyNode.*EntityDependencyNode"
# Check for any existing error handling patterns
rg -B 2 -A 2 "catch.*EntityDependencyNode"
Length of output: 99
Script:
#!/bin/bash
# Let's search for the EntityDependencyNode class definition and its usage patterns
ast-grep --pattern 'class EntityDependencyNode {
$$$
}'
# Search for widget dependency handling patterns
rg -B 2 -A 2 "EntityReferenceType.WIDGET"
# Search for any error handling related to widget dependencies
rg -B 2 -A 2 "widgetDynamicBindingsMap"
# Look for related test cases
fd -e java -e ts -e js --exec rg -l "widgetDependencyNode|EntityDependencyNode"
Length of output: 19996
./build-deploy-preview skip-tests=true |
...th-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java
Show resolved
Hide resolved
/build-deploy-preview skip-tests=true |
Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12078659951. |
Deploy-Preview-URL: https://ce-37127.dp.appsmith.com |
Failed server tests
|
Description
In this PR, we update the code to send all the bindings to RTS together instead of calling it for each property binding. It was observed that the calls were earlier around 40k for the test application.
This change leads to optimisation of performance for
Fixes #37055
Tests on DP
Deploy-Preview-URL: https://ce-37127.dp.appsmith.com/
EE PR - https://github.com/appsmithorg/appsmith-ee/pull/5642
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/12082854290
Commit: 07b68d4
Cypress dashboard.
Tags:
@tag.All
Spec:
Fri, 29 Nov 2024 11:44:31 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Tests