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

Performance optimization for start child workflow task #1397

Merged
merged 2 commits into from
Mar 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions service/history/transferQueueActiveTaskExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,10 @@ func (t *transferQueueActiveTaskExecutor) processStartChildExecution(
WorkflowId: childInfo.StartedWorkflowId,
RunId: childInfo.StartedRunId,
}
// NOTE: do not access anything related mutable state after this lock release
// release the context lock since we no longer need mutable state builder and
// the rest of logic is making RPC call, which takes time.
release(nil)
return t.createFirstWorkflowTask(task.GetTargetNamespaceId(), childExecution)
}

Expand Down Expand Up @@ -631,11 +635,14 @@ func (t *transferQueueActiveTaskExecutor) processStartChildExecution(

// Child execution is successfully started, record ChildExecutionStartedEvent in parent execution
err = t.recordChildExecutionStarted(task, context, attributes, childRunID)

if err != nil {
return err
}
// Finally create first workflow task for Child execution so it is really started

// NOTE: do not access anything related mutable state after this lock release
// release the context lock since we no longer need mutable state builder and
// the rest of logic is making RPC call, which takes time.
release(nil)
Copy link
Member

Choose a reason for hiding this comment

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

It is safe to call release multiply times, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, release function within has an atomic int for status tracking:
https://github.com/temporalio/temporal/blob/v1.8.0/service/history/historyCache.go#L262

return t.createFirstWorkflowTask(task.GetTargetNamespaceId(), &commonpb.WorkflowExecution{
WorkflowId: task.GetTargetWorkflowId(),
RunId: childRunID,
Expand Down