Skip to content

perf: DDataShardCoordinator stashed GetShardHome handling #32743

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

Merged
merged 6 commits into from
Jul 1, 2025

Conversation

leviramsey
Copy link
Contributor

@leviramsey leviramsey commented Jun 16, 2025

Two optimizations intended to reduce latency for shard allocation dissemination:

  • When a shard gets allocated, try to respond to all stashed GetShardHomes for that shard by unstashing them first
  • When unstashing GetShardHomes, prefer ones that have demand from ShardRegions (and thus buffered messages)

@leviramsey leviramsey changed the title opt: DDataShardCoordinator stashed GetShardHome handling perf: DDataShardCoordinator stashed GetShardHome handling Jun 16, 2025
Copy link
Contributor

@johanandren johanandren left a comment

Choose a reason for hiding this comment

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

Looks good, we can add a mima filter IMO

@@ -1848,13 +1850,29 @@ private[akka] class DDataShardCoordinator(
override protected def unstashOneGetShardHomeRequest(): Unit = {
if (getShardHomeRequests.nonEmpty) {
// unstash one, will continue unstash of next after receive GetShardHome or update completed
val requestTuple = getShardHomeRequests.head
val requestTuple = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could capture both nicely val requestTuple @ (ref, _) = ... instead of having to use the _1 syntax which is less clear.

Copy link
Contributor

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM

@leviramsey
Copy link
Contributor Author

Wondering if it makes sense to make the stash even better prioritized... with this it will probabilistically tend to choose the shard with the greatest demand from the regions, but maybe better to have parallel stashes for self-generated and from-region GetShardHomes?

@leviramsey
Copy link
Contributor Author

Added the refactor to more deterministically choose the next shard to allocate in response to a GetShardHome (deterministic when there is a unique shard with maximum number of regions demanding its home; otherwise it will choose (in iteration order) one of the shards with said maximum).

Iterating through when unstashing should be OK: even if there are many shards with requests with none having requests from multiple shard regions, the time spent iterating pales in comparison to the time waiting for ddata to update, and as soon as we get a second request for an unallocated shard (which it's reasonable to expect is more likely the longer this takes) we can immediately handle all requests for that shard (which is a win).

@leviramsey
Copy link
Contributor Author

relevant to #30315

Copy link
Contributor

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM

@johanandren johanandren merged commit 3f90419 into akka:main Jul 1, 2025
9 checks passed
@johanandren johanandren added this to the 2.10.7 milestone Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants