Skip to content

refactor(hydro_test): migrate paxos cross_singleton to by_ref() singleton mechanism [ci-bench]#2983

Open
MingweiSamuel wants to merge 2 commits into
mainfrom
mingwei/paxos-ref-2
Open

refactor(hydro_test): migrate paxos cross_singleton to by_ref() singleton mechanism [ci-bench]#2983
MingweiSamuel wants to merge 2 commits into
mainfrom
mingwei/paxos-ref-2

Conversation

@MingweiSamuel

@MingweiSamuel MingweiSamuel commented Jun 26, 2026

Copy link
Copy Markdown
Member

Converted 8 out of 8 cross_singleton usages in paxos.rs to use the
by_ref() singleton reference mechanism:

  • recommit_after_leader_election: 3 cross_singleton calls replaced with
    by_ref() captures in filter_map and map closures (p_ballot and
    p_p1b_max_checkpoint captured as refs)
  • sequence_payload: 1 cross_singleton replaced with by_ref() in map
    (p_ballot captured as ref)
  • index_payloads (sliced!): 1 cross_singleton replaced with by_ref() in
    map (base_slot captured as ref)
  • acceptor_p2: 2 cross_singleton calls replaced with by_ref() captures
    in filter_map and map closures (a_max_ballot captured as ref)
  • acceptor_p1: both cross_singleton(a_max_ballot) and cross_singleton(a_log)
    replaced with by_ref() captures in the map closure

Added + 'a lifetime bounds where required by by_ref() usage:

  • PaxosLike::build, PaxosLike::with_client (paxos_with_client.rs)
  • paxos_core, index_payloads (paxos.rs)
  • compartmentalized_paxos_core, CoreCompartmentalizedPaxos::build
    (compartmentalized_paxos.rs)
  • Added + 'a bounds on L in acceptor_p1 and leader_election signatures

Updated IR snapshots (both stable and nightly) to reflect the new
reference nodes replacing cross_singleton patterns.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploying hydro with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0d4d8e0
Status: ✅  Deploy successful!
Preview URL: https://db99e348.hydroflow.pages.dev
Branch Preview URL: https://mingwei-paxos-ref-2.hydroflow.pages.dev

View logs

…eton mechanism

Converted 6 out of 8 cross_singleton usages in paxos.rs to use the
by_ref() singleton reference mechanism:

- recommit_after_leader_election: 3 cross_singleton calls replaced with
  by_ref() captures in filter_map and map closures (p_ballot and
  p_p1b_max_checkpoint captured as refs)
- sequence_payload: 1 cross_singleton replaced with by_ref() in map
  (p_ballot captured as ref)
- index_payloads (sliced!): 1 cross_singleton replaced with by_ref() in
  map (base_slot captured as ref)
- acceptor_p2: 2 cross_singleton calls replaced with by_ref() captures
  in filter_map and map closures (a_max_ballot captured as ref)

Left unchanged:
- acceptor_p1: 2 cross_singleton calls remain because the a_log parameter
  comes from a forward_ref cycle, and by_ref() on cycle sources causes a
  graph partitioning error ("Handoff succ not in subgraph")

Added + 'a lifetime bounds where required by by_ref() usage:
- PaxosLike::build, PaxosLike::with_client (paxos_with_client.rs)
- paxos_core, index_payloads (paxos.rs)
- compartmentalized_paxos_core, CoreCompartmentalizedPaxos::build
  (compartmentalized_paxos.rs)

Updated IR snapshots (both stable and nightly) to reflect the new
reference nodes replacing cross_singleton patterns.

Co-authored-by: Infinity 🤖 <infinity@hydro.run>
PR: #2983
@MingweiSamuel MingweiSamuel changed the title refactor(hydro_test): migrate paxos cross_singleton to by_ref() singleton mechanism refactor(hydro_test): migrate paxos cross_singleton to by_ref() singleton mechanism [ci-bench] Jun 26, 2026
…_ref()

The original PR #2903 left acceptor_p1's 2 cross_singleton calls unconverted
because a_log came from a forward_ref cycle and caused a graph partitioning
error. This issue has since been fixed in the framework, so both a_max_ballot
and a_log can now use by_ref() successfully.

- acceptor_p1: both cross_singleton(a_max_ballot) and cross_singleton(a_log)
  replaced with by_ref() captures in the map closure
- Added + 'a bounds on L in acceptor_p1 and leader_election signatures

All 8 cross_singleton usages in paxos.rs are now converted.

Co-authored-by: Infinity 🤖 <infinity@hydro.run>
PR: #2983
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

✅ Benchmark completed! You can download the results from the links below.

Run History:

Last updated: 2026-06-26T20:55:34.185Z

@MingweiSamuel MingweiSamuel marked this pull request as ready for review June 26, 2026 20:53
@MingweiSamuel MingweiSamuel requested review from a team and Copilot June 26, 2026 20:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Paxos dataflow construction in hydro_test to replace cross_singleton(...) usage patterns with the newer by_ref() singleton reference capture mechanism, and updates the IR snapshot outputs accordingly.

Changes:

  • Migrates multiple Paxos pipeline joins from cross_singleton to by_ref() captures in paxos.rs (proposer and acceptor paths).
  • Adds + 'a bounds to several generic parameters to satisfy by_ref() capture requirements.
  • Updates stable and nightly Mermaid IR snapshots to match the new reference nodes and resulting graph structure.

Reviewed changes

Copilot reviewed 5 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
hydro_test/src/cluster/paxos.rs Replaces cross_singleton joins with by_ref() captures; adjusts generic bounds.
hydro_test/src/cluster/paxos_with_client.rs Adds P: 'a bounds to the PaxosLike trait methods for by_ref() compatibility.
hydro_test/src/cluster/compartmentalized_paxos.rs Adds P: 'a bounds to compartmentalized Paxos entrypoints.
hydro_test/src/cluster/snapshots/paxos_ir@proposer_mermaid.snap Updates stable proposer IR snapshot after refactor.
hydro_test/src/cluster/snapshots/paxos_ir@acceptor_mermaid.snap Updates stable acceptor IR snapshot after refactor.
hydro_test/src/cluster/snapshots-nightly/paxos_ir@acceptor_mermaid.snap Updates nightly acceptor IR snapshot after refactor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hydro_test/src/cluster/paxos.rs
Comment on lines +498 to +502
.map(q!(|ballot| {
let max_ballot = a_max_ballot_ref.clone();
let log = a_log_ref.clone();
(
ballot.clone(),
if ballot == max_ballot {
Ok(log)
} else {
Err(max_ballot)
}
ballot.proposer_id.clone(),

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.

Might be correct? Although the performance should be no worse than before.

@shadaj shadaj left a comment

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.

Awesome!

Comment on lines +498 to +502
.map(q!(|ballot| {
let max_ballot = a_max_ballot_ref.clone();
let log = a_log_ref.clone();
(
ballot.clone(),
if ballot == max_ballot {
Ok(log)
} else {
Err(max_ballot)
}
ballot.proposer_id.clone(),

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.

Might be correct? Although the performance should be no worse than before.

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