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: debounce handle action updates #38396

Merged
merged 1 commit into from
Dec 30, 2024
Merged

chore: debounce handle action updates #38396

merged 1 commit into from
Dec 30, 2024

Conversation

vsvamsi1
Copy link
Contributor

@vsvamsi1 vsvamsi1 commented Dec 30, 2024

Description

Debounced handleActionUpdate actions together with bufferedActions, this has reduced the webworker scripting and LCP by about 25-30% on a windows machine.

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/12542044958
Commit: 834a437
Cypress dashboard.
Tags: @tag.All
Spec:


Mon, 30 Dec 2024 06:24:18 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced action data handling and evaluation mechanisms
    • Improved Redux action processing for more efficient updates
  • Refactor

    • Streamlined saga logic for action data management
    • Updated type definitions to improve code clarity and type safety
  • Tests

    • Added comprehensive test cases for action data buffering and consolidation

Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

Walkthrough

This pull request introduces modifications to the action data handling mechanism in the application. The changes primarily involve updating type definitions, modifying Redux action types, and refactoring the evaluation saga to handle action data updates more efficiently. The modifications aim to streamline the process of updating and evaluating action data across different components of the application.

Changes

File Change Summary
app/client/src/actions/pluginActionActions.ts Exported actionDataPayload type for broader accessibility
app/client/src/ce/actions/evaluationActionsList.ts Added ReduxActionTypes.UPDATE_ACTION_DATA to EVALUATE_REDUX_ACTIONS
app/client/src/sagas/ActionExecution/PluginActionSaga.ts Removed handleUpdateActionData function and related takeEvery effect
app/client/src/sagas/EvaluationsSaga.ts Updated evalQueueBuffer with new BUFFERED_ACTION interface and refined action handling logic
app/client/src/sagas/EvaluationsSaga.test.ts Added new test cases for UPDATE_ACTION_DATA actions and buffer behavior

Sequence Diagram

sequenceDiagram
    participant Client
    participant Redux Store
    participant EvaluationSaga
    participant EvalWorker

    Client->>Redux Store: Dispatch UPDATE_ACTION_DATA
    Redux Store->>EvaluationSaga: Trigger Action
    EvaluationSaga->>EvalWorker: Update Action Data
    EvalWorker-->>EvaluationSaga: Evaluation Complete
Loading

Possibly related PRs

Suggested Labels

Performance Pod, Bug, Task, ok-to-test

Suggested Reviewers

  • ayushpahwa
  • hetunandu
  • sagar-qa007

Poem

🚀 Code flows like a river's might,
Actions dance in Redux's light,
Sagas weave their magic spell,
Refactoring stories to tell!
Efficiency blooms, clean and bright 🌟

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@vsvamsi1 vsvamsi1 added the ok-to-test Required label for CI label Dec 30, 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 30, 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

🧹 Nitpick comments (1)
app/client/src/sagas/EvaluationsSaga.ts (1)

600-616: Optional chaining suggestion.
Consider using if (actionDataPayload?.length) to simplify the null check.

- if (actionDataPayload && actionDataPayload.length) {
+ if (actionDataPayload?.length) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 604-604: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cf53494 and 834a437.

📒 Files selected for processing (5)
  • app/client/src/actions/pluginActionActions.ts (1 hunks)
  • app/client/src/ce/actions/evaluationActionsList.ts (1 hunks)
  • app/client/src/sagas/ActionExecution/PluginActionSaga.ts (0 hunks)
  • app/client/src/sagas/EvaluationsSaga.test.ts (6 hunks)
  • app/client/src/sagas/EvaluationsSaga.ts (5 hunks)
💤 Files with no reviewable changes (1)
  • app/client/src/sagas/ActionExecution/PluginActionSaga.ts
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/sagas/EvaluationsSaga.ts

[error] 604-604: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (18)
app/client/src/sagas/EvaluationsSaga.ts (8)

97-101: Properly imported new types.
These imports look correctly declared.


543-547: New BUFFERED_ACTION interface is coherent.
No issues observed with the structure or property definitions.


550-553: Initialization logic is clear.
These variables and their initial states are appropriate for buffering.


568-575: State reset approach is valid.
Resetting the consolidated values ensures correct handling of subsequent actions.


578-583: Consolidated return structure is well-defined.
No issues with the final object structure containing the necessary props.


617-619: Minimal overhead approach.
Marking hasBufferedAction and canTake is straightforward with no apparent pitfalls.


804-826: Separate handling for UPDATE_ACTION_DATA.
The new condition ensures the worker receives the updated data properly.


827-853: Buffered action logic is well-structured.
Delegating UPDATE_ACTION_DATA and falling back to existing flow is consistent.

app/client/src/ce/actions/evaluationActionsList.ts (1)

111-111: Adding UPDATE_ACTION_DATA is consistent.
Its inclusion in EVALUATE_REDUX_ACTIONS aligns with the saga’s handling logic.

app/client/src/actions/pluginActionActions.ts (1)

391-391: Exported type improves reusability.
Exposing actionDataPayload fosters clarity and consistency across modules.

app/client/src/sagas/EvaluationsSaga.test.ts (8)

29-29: New import used in tests.
Importing updateActionData sets the stage for saga buffer coverage.


194-196: Correct initialization of actionDataPayloadConsolidated.
Defaults properly to an empty array for subsequent checks.


214-216: Accumulated action data remains consistent.
The final state includes all changes to JS objects.


238-240: Flagging isAllAffected if any action triggers broad changes.
Merging logic for JS objects is properly handled.


256-258: Ensures a clean slate for subsequent buffers.
Resetting collected objects prevents accidental carryover.


271-273: Default fallback is correct.
If no affected objects exist, the default empties are used.


279-330: UPDATE_ACTION_DATA debouncing.
The consolidation of multiple payloads into a single array is correct and improves efficiency.


331-386: Combined buffering.
Handling both UPDATE_ACTION_DATA and other actions together is logically sound and well-tested.

@vsvamsi1 vsvamsi1 merged commit f9664a3 into release Dec 30, 2024
87 checks passed
@vsvamsi1 vsvamsi1 deleted the test59 branch December 30, 2024 06:48
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