Skip to content

fix(pb): optimize actor key allocation#4610

Merged
MasterPtato merged 1 commit intomainfrom
04-12-fix_pb_optimize_actor_key_allocation
Apr 13, 2026
Merged

fix(pb): optimize actor key allocation#4610
MasterPtato merged 1 commit intomainfrom
04-12-fix_pb_optimize_actor_key_allocation

Conversation

@MasterPtato
Copy link
Copy Markdown
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Contributor Author

MasterPtato commented Apr 12, 2026

@claude
Copy link
Copy Markdown

claude bot commented Apr 12, 2026

PR Review: fix(pb): optimize actor key allocation

NOTE: This PR is already merged. Feedback is provided for future reference.

SUMMARY

This PR eliminates two separate workflow activities (GenerateReservationId and ResolveTargetReplicas) by folding their work into a single LookupKeyOptimistic activity. The optimization is sound -- the target replicas are needed to scope the optimistic read anyway, so fetching them there (and generating the reservation ID in the same pass) removes two unnecessary round trips. The supporting refactor moving resolve_quorum_members to a shared util is clean.


POSITIVES

Utility extraction (utils.rs): resolve_active_quorum_members is the right place for this logic. Both epoxy_propose and epoxy_kv_get_optimistic now share the same validated quorum resolution path, and the rename from resolve_quorum_members to resolve_active_quorum_members is more descriptive.

Test migration: All 6 unit tests were correctly moved and renamed alongside the function. No coverage was lost.

Documentation comment on target_replicas: The doc comment clearly explains the caller-side scope stability invariant, which is important for a subtle correctness property.

Enum output design: LookupKeyOptimisticOutput with serde rename_all snake_case is idiomatic and the serialized form is stable.


CONCERNS

In-flight workflow compatibility: GenerateReservationId and ResolveTargetReplicas are removed entirely without a version guard. Workflows that already completed LookupKeyOptimistic (returning Option) but have not yet replayed through GenerateReservationId or ResolveTargetReplicas will fail on replay after deployment. The old ResolveTargetReplicas was added behind .v(2), so there is prior art for using version gates here. Worth confirming this codepath had no in-flight workflows at deploy time, or that the workflow engine handles missing activity types gracefully.

Minor - observability loss: The removed ResolveTargetReplicas activity included timing instrumentation (tracing::debug! with op_duration_ms). The inlined replica fetch in lookup_key_optimistic has no equivalent timing. If this op is slow in production it will be invisible in traces.

Minor - into_iter().next() vs .first().copied(): The forwarding branch now uses target_replicas.into_iter().next() where the old code used target_replicas.first().copied(). Both are correct here (the Vec is consumed before the early return), but .first().copied() reads more clearly as "get the first element" without the ownership implication. Not a bug, just a style note.


OVERALL

Clean optimization. The two activity round trips removed represent real distributed latency savings for every key reservation. The in-flight compatibility question is the only thing worth double-checking on a future similar change.

@MasterPtato MasterPtato force-pushed the 04-12-fix_pb_optimize_actor_key_allocation branch from c8e4e6b to f31092e Compare April 12, 2026 19:48
@MasterPtato MasterPtato force-pushed the 04-10-fix_move_runner_configs_to_epoxy branch from 94f4263 to 4064862 Compare April 12, 2026 19:48
@MasterPtato MasterPtato force-pushed the 04-12-fix_pb_optimize_actor_key_allocation branch from f31092e to 0351bf4 Compare April 12, 2026 19:59
@MasterPtato MasterPtato force-pushed the 04-10-fix_move_runner_configs_to_epoxy branch 2 times, most recently from 39d337d to 9198ffc Compare April 12, 2026 20:39
@MasterPtato MasterPtato force-pushed the 04-12-fix_pb_optimize_actor_key_allocation branch from 0351bf4 to ccfb97a Compare April 12, 2026 20:39
@MasterPtato MasterPtato force-pushed the 04-10-fix_move_runner_configs_to_epoxy branch from 9198ffc to bd6ef15 Compare April 12, 2026 21:03
@MasterPtato MasterPtato force-pushed the 04-12-fix_pb_optimize_actor_key_allocation branch from ccfb97a to 4573f6b Compare April 12, 2026 21:03
@MasterPtato MasterPtato force-pushed the 04-10-fix_move_runner_configs_to_epoxy branch from bd6ef15 to e2a69f1 Compare April 12, 2026 21:21
@MasterPtato MasterPtato force-pushed the 04-12-fix_pb_optimize_actor_key_allocation branch from 4573f6b to 2efef31 Compare April 12, 2026 21:21
.collect()
}

/// Returns the quorum members to use for this proposal. This supports scoped proposals because
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

outdated

@MasterPtato MasterPtato force-pushed the 04-12-fix_pb_optimize_actor_key_allocation branch 2 times, most recently from c0cc63d to d4d4a75 Compare April 12, 2026 23:38
@MasterPtato MasterPtato force-pushed the 04-10-fix_move_runner_configs_to_epoxy branch from e2a69f1 to 40e5746 Compare April 12, 2026 23:38
@MasterPtato MasterPtato force-pushed the 04-10-fix_move_runner_configs_to_epoxy branch from 40e5746 to be5f01c Compare April 13, 2026 00:20
@MasterPtato MasterPtato force-pushed the 04-12-fix_pb_optimize_actor_key_allocation branch from d4d4a75 to 079bc44 Compare April 13, 2026 00:20
Copy link
Copy Markdown
Contributor Author

MasterPtato commented Apr 13, 2026

Merge activity

  • Apr 13, 12:21 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 13, 12:36 AM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 13, 12:36 AM UTC: @MasterPtato merged this pull request with Graphite.

@MasterPtato MasterPtato changed the base branch from 04-10-fix_move_runner_configs_to_epoxy to graphite-base/4610 April 13, 2026 00:33
@MasterPtato MasterPtato changed the base branch from graphite-base/4610 to main April 13, 2026 00:34
@MasterPtato MasterPtato force-pushed the 04-12-fix_pb_optimize_actor_key_allocation branch from 079bc44 to bebc8ac Compare April 13, 2026 00:35
@MasterPtato MasterPtato merged commit 605261e into main Apr 13, 2026
5 of 7 checks passed
@MasterPtato MasterPtato deleted the 04-12-fix_pb_optimize_actor_key_allocation branch April 13, 2026 00:36
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.

2 participants