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

Internal and remote actor invocation optimization #7231

Merged
merged 56 commits into from Jan 18, 2024

Conversation

ItalyPaleAle
Copy link
Contributor

@ItalyPaleAle ItalyPaleAle commented Nov 22, 2023

This PR changes the data structures used for actor invocation (direct messaging, reminders, timers), optimizing them for when internal and remote actors are invoked.

  1. When invoking internal actor such as workflow actors, with this PR we do not need to create a "virtual app channel" anymore, which added significant overhead due to data being copied and re-encoded various time, and complexity with routing. When an actor is internal (and local), it is invoked directly.
  2. Currently, the "standard" data structure used in the actors package is pkg/messaging/v1.InvokeMethodRequest, which is optimized for invocations on the app channel. This changes the main data structure to be pkg/proto/internals/v1.InternalInvokeRequest, which is the same that is used for local and remote actor invocation. This avoids unnecessary conversions to/from the messaging data structure, which is meant for a different purpose and optimized for streaming.
  3. Lastly, internal actors have been improved by allowing the actor runtime itself manage each instance of an active actor. This way, implementation of internal actors can save state locally (in the same object) and don't need to maintain a map of states. It simplifies the development and maintenance of internal actors, as well as improving performance by using more efficient state maps and avoid locking (based on haxmap)

All told these changes should improve performance, especially when invoking internal actors, and reduce allocations.

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Copy link

codecov bot commented Nov 23, 2023

Codecov Report

Attention: 366 lines in your changes are missing coverage. Please review.

Comparison is base (aff656e) 62.30% compared to head (bb897da) 62.25%.

Files Patch % Lines
...runtime/wfengine/backends/actors/workflow_actor.go 0.00% 123 Missing ⚠️
pkg/actors/actors.go 49.03% 86 Missing and 20 partials ⚠️
...runtime/wfengine/backends/actors/activity_actor.go 0.00% 80 Missing ⚠️
pkg/runtime/wfengine/backends/actors/backend.go 0.00% 25 Missing ⚠️
pkg/actors/actors_mock.go 0.00% 20 Missing ⚠️
pkg/api/grpc/daprinternal.go 22.22% 7 Missing ⚠️
pkg/api/http/http.go 80.00% 0 Missing and 2 partials ⚠️
pkg/actors/internal_actor.go 87.50% 1 Missing ⚠️
pkg/messaging/v1/invoke_method_request.go 66.66% 1 Missing ⚠️
pkg/messaging/v1/invoke_method_response.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7231      +/-   ##
==========================================
- Coverage   62.30%   62.25%   -0.05%     
==========================================
  Files         240      240              
  Lines       22159    22135      -24     
==========================================
- Hits        13807    13781      -26     
- Misses       7193     7200       +7     
+ Partials     1159     1154       -5     

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

…ctor-messaging

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
@ItalyPaleAle ItalyPaleAle changed the title WIP: Internal and remote actor invocation optimization Internal and remote actor invocation optimization Dec 15, 2023
@ItalyPaleAle ItalyPaleAle marked this pull request as ready for review December 15, 2023 02:31
@ItalyPaleAle ItalyPaleAle requested review from a team as code owners December 15, 2023 02:31
@ItalyPaleAle ItalyPaleAle added the autoupdate DaprBot will keep the Pull Request up to date with master branch label Dec 15, 2023
@ItalyPaleAle
Copy link
Contributor Author

/ok-to-test

@dapr-bot
Copy link
Collaborator

dapr-bot commented Dec 15, 2023

Dapr E2E test

🔗 Link to Action run

Commit ref: f8d0517

✅ Build succeeded for linux/amd64

  • Image tag: dapre2e7fb98d6332l
  • Test image tag: dapre2e7fb98d6332l

✅ Infrastructure deployed

Cluster Resource group name Azure region
Linux Dapr-E2E-dapre2e7fb98d6332l westus3
Windows Dapr-E2E-dapre2e7fb98d6332w westus3
Linux/arm64 Dapr-E2E-dapre2e7fb98d6332la eastus

✅ Build succeeded for windows/amd64

  • Image tag: dapre2e7fb98d6332w
  • Test image tag: dapre2e7fb98d6332w

✅ Tests succeeded on windows/amd64

  • Image tag: dapre2e7fb98d6332w
  • Test image tag: dapre2e7fb98d6332w

✅ Tests succeeded on linux/amd64

  • Image tag: dapre2e7fb98d6332l
  • Test image tag: dapre2e7fb98d6332l

@ItalyPaleAle ItalyPaleAle mentioned this pull request Dec 19, 2023
13 tasks
@ItalyPaleAle ItalyPaleAle added this to the v1.13 milestone Dec 19, 2023
@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 16, 2024

Dapr SDK Python test

🔗 Link to Action run

Commit ref: 853c705

✅ Python SDK tests passed

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 16, 2024

Dapr SDK Java test

🔗 Link to Action run

Commit ref: 853c705

❌ Java SDK tests failed

Please check the logs for details on the error.

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 16, 2024

Dapr SDK Go test

🔗 Link to Action run

Commit ref: 853c705

✅ Go SDK tests passed

@dapr-bot
Copy link
Collaborator

dapr-bot commented Jan 16, 2024

Dapr SDK JS test

🔗 Link to Action run

Commit ref: 853c705

✅ JS SDK tests passed

ItalyPaleAle and others added 2 commits January 16, 2024 18:08
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
@daixiang0
Copy link
Member

Please fix conflicts.

Codes looks good to me.

…leAle/dapr; branch 'master' of https://github.com/dapr/dapr into internal-actor-messaging

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
@ItalyPaleAle
Copy link
Contributor Author

Please fix conflicts.

Codes looks good to me.

Fixed

daixiang0
daixiang0 previously approved these changes Jan 17, 2024
Copy link
Member

@daixiang0 daixiang0 left a comment

Choose a reason for hiding this comment

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

LGTM

@yaron2 yaron2 merged commit db53617 into dapr:master Jan 18, 2024
20 of 22 checks passed
whytem pushed a commit to whytem/dapr that referenced this pull request Jan 22, 2024
* WIP

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Bunch of fixes in tests

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More tweaks

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Fixes and improvements to code legibility

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Use a lock around internalActors property

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* 💄

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Fixed last test

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Changed per review feedback: use a single struct for reminders and timers

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* WIP: use factory for internal actors

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Improve APIs for internal actors

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Updated comment

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

---------

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Co-authored-by: Loong Dai <long.dai@intel.com>
elena-kolevska pushed a commit to elena-kolevska/dapr that referenced this pull request Jan 24, 2024
* WIP

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Bunch of fixes in tests

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More tweaks

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Fixes and improvements to code legibility

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Use a lock around internalActors property

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* 💄

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Fixed last test

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Changed per review feedback: use a single struct for reminders and timers

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* WIP: use factory for internal actors

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Improve APIs for internal actors

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Updated comment

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

---------

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Co-authored-by: Loong Dai <long.dai@intel.com>
elena-kolevska added a commit to elena-kolevska/dapr that referenced this pull request Jan 24, 2024
elena-kolevska pushed a commit to elena-kolevska/dapr that referenced this pull request Jan 25, 2024
* WIP

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Bunch of fixes in tests

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More tweaks

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Fixes and improvements to code legibility

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Use a lock around internalActors property

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* 💄

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Fixed last test

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Changed per review feedback: use a single struct for reminders and timers

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* WIP: use factory for internal actors

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Improve APIs for internal actors

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Updated comment

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

---------

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Co-authored-by: Loong Dai <long.dai@intel.com>
Signed-off-by: Elena Kolevska <elena@kolevska.com>
elena-kolevska added a commit to elena-kolevska/dapr that referenced this pull request Jan 25, 2024
This reverts commit e45de2c.

Signed-off-by: Elena Kolevska <elena@kolevska.com>
elena-kolevska pushed a commit to elena-kolevska/dapr that referenced this pull request Jan 25, 2024
* WIP

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Bunch of fixes in tests

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More tweaks

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* More test fixes

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Fixes and improvements to code legibility

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Use a lock around internalActors property

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* 💄

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Fixed last test

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Changed per review feedback: use a single struct for reminders and timers

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* WIP: use factory for internal actors

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Improve APIs for internal actors

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

* Updated comment

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>

---------

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Co-authored-by: Loong Dai <long.dai@intel.com>
@ItalyPaleAle ItalyPaleAle deleted the internal-actor-messaging branch February 26, 2024 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autoupdate DaprBot will keep the Pull Request up to date with master branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants