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

Clear inputs from dynamic closure to avoid bloating the event message #6234

Conversation

pmahindrakar-oss
Copy link
Contributor

@pmahindrakar-oss pmahindrakar-oss commented Feb 9, 2025

Tracking issue

Upstream changes from union

Why are the changes needed?

The dynamic closure contains inputs for all dynamic nodes. However, these inputs are included when constructing node events sent to the admin, despite not being used by any clients. A comparison of Flyte Console and FlyteKit confirms this redundancy as they use GetNodeExecutionData to fetch this data along with for outputs.

Sending such large inputs in the dynamic closure occasionally exceeds gRPC limits, causing execution failures. Even when the payload remains within the limit, its large size (in MBs) results in sluggish UI performance, as clients must process and render unnecessary data.

What changes were proposed in this pull request?

We remove node inputs before sending the event to the admin, enhancing UI performance when fetching the dynamic closure for the node view. This also prevents cases where exceeding gRPC limits would cause dynamic node execution to fail.

How was this patch tested?

Verified by running a large dynamic workflow which contained large inputs and verified the page loads sped up which called the dynamic workflow api.

Notice before and after number of bytes loaded

Before the change (3.9 MB)

Screenshot 2025-02-04 at 5 41 36 PM

After the change

Screenshot 2025-02-04 at 6 02 34 PM

Labels

Please add one or more of the following labels to categorize your PR:

  • added: For new features.
  • changed: For changes in existing functionality.
  • deprecated: For soon-to-be-removed features.
  • removed: For features being removed.
  • fixed: For any bug fixed.
  • security: In case of vulnerabilities

This is important to improve the readability of release notes.

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Summary by Bito

Implementation of a new clearNodeInputs function to optimize dynamic node event messages by removing input data from regular and array nodes. This optimization reduces payload size, prevents gRPC limit issues, and enhances UI performance. Changes include refactoring to use getter methods instead of direct field access for node inputs and targets. The implementation ensures proper handling of dynamic workflow closures before sending events to admin.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 1

* Clear inputs for the dynamic workflow to avoid bloating the event message

Signed-off-by: pmahindrakar-oss <prafulla.mahindrakar@gmail.com>

* Clear inputs for the dynamic workflow to avoid bloating the event message

Signed-off-by: pmahindrakar-oss <prafulla.mahindrakar@gmail.com>

---------

Signed-off-by: pmahindrakar-oss <prafulla.mahindrakar@gmail.com>
@pmahindrakar-oss pmahindrakar-oss added fixed For any bug fixes changed For changes in existing functionality labels Feb 9, 2025
@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 9, 2025

Code Review Agent Run #24d5dc

Actionable Suggestions - 1
  • flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow.go - 1
Review Details
  • Files reviewed - 2 · Commit Range: e3c6d85..e3c6d85
    • flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow.go
    • flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow_test.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 9, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Dynamic Workflow Event Optimization

dynamic_workflow.go - Added clearNodeInputs function to remove input data from dynamic workflow nodes

dynamic_workflow_test.go - Added unit tests to verify input clearing functionality for regular and array nodes

Comment on lines 226 to 237
// This function is used to clear the inputs of the nodes in the dynamic workflow. This is done to avoid bloating the node event.
func clearNodeInputs(ctx context.Context, nodes []*core.Node) {
for _, node := range nodes {
node.Inputs = nil
switch node.Target.(type) {
case *core.Node_ArrayNode:
node.Target.(*core.Node_ArrayNode).ArrayNode.Node.Inputs = nil
default:
logger.Debugf(ctx, "node type %T not supported for clearing inputs", node.Target)
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding nil check for node.Target

Consider adding error handling for the case when node.Target is nil. Currently, the code assumes node.Target is always non-nil which could lead to a panic.

Code suggestion
Check the AI-generated fix before applying
 @@ -227,11 +227,14 @@ func clearNodeInputs(ctx context.Context, nodes []*core.Node) {
 	for _, node := range nodes {
 		node.Inputs = nil
 		if node.Target == nil {
 			logger.Debugf(ctx, "node target is nil for node %v", node.Id)
 			continue
 		}
 		switch node.Target.(type) {
 		case *core.Node_ArrayNode:
 			node.Target.(*core.Node_ArrayNode).ArrayNode.Node.Inputs = nil
 		default:
 			logger.Debugf(ctx, "node type %T not supported for clearing inputs", node.Target)
 		}
 	}

Code Review Run #24d5dc


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

Copy link

codecov bot commented Feb 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.87%. Comparing base (34205dd) to head (18ab5b3).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6234   +/-   ##
=======================================
  Coverage   36.87%   36.87%           
=======================================
  Files        1318     1318           
  Lines      134647   134656    +9     
=======================================
+ Hits        49647    49657   +10     
+ Misses      80679    80678    -1     
  Partials     4321     4321           
Flag Coverage Δ
unittests-datacatalog 51.58% <ø> (ø)
unittests-flyteadmin 51.96% <ø> (ø)
unittests-flytecopilot 30.99% <ø> (ø)
unittests-flytectl 62.29% <ø> (ø)
unittests-flyteidl 7.22% <ø> (ø)
unittests-flyteplugins 54.02% <ø> (ø)
unittests-flytepropeller 42.80% <100.00%> (+0.01%) ⬆️
unittests-flytestdlib 55.35% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: pmahindrakar-oss <prafulla.mahindrakar@gmail.com>
@flyte-bot
Copy link
Collaborator

flyte-bot commented Feb 9, 2025

Code Review Agent Run #2eb337

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: e3c6d85..18ab5b3
    • flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow.go
    • flytepropeller/pkg/controller/nodes/dynamic/dynamic_workflow_test.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changed For changes in existing functionality fixed For any bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants