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

scheduler forward packets #898

Merged
merged 14 commits into from
Apr 26, 2024

Conversation

apfitzge
Copy link

@apfitzge apfitzge commented Apr 19, 2024

Problem

  • swqos was built with the assumption that transactions are forwarded by validator nodes
  • without swqos being used, forwarding was in process of being deprecated since behavior (without swqow stuff) was useless
  • major push in past weeks has led to operators adopting swqos forwarding side-deals
  • the new scheduler does not support forwarding for above reasons
  • the lack of support would make operators need to make a choice between swqos side deals and the new scheduler, which is less than ideal under the current circumstances

Summary of Changes

  • Add support for forwarding transactions in the new scheduler

Fixes #

@@ -130,6 +134,10 @@ impl ForwardPacketBatchesByAccounts {
pub fn iter_batches(&self) -> impl Iterator<Item = &ForwardBatch> {
self.forward_batches.iter()
}

pub fn take_iter_batches(self) -> impl Iterator<Item = ForwardBatch> {
Copy link
Author

Choose a reason for hiding this comment

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

I send the packets from these ForwardBatch, created by scheduler, to workers. Instead of cloning the packets, just take ownership.

@apfitzge apfitzge force-pushed the scheduler-support-forwarding branch from cc74da9 to 512de3e Compare April 19, 2024 16:04
@apfitzge apfitzge force-pushed the scheduler-support-forwarding branch from 512de3e to 225da20 Compare April 19, 2024 19:44
@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2024

Codecov Report

Attention: Patch coverage is 63.63636% with 64 lines in your changes are missing coverage. Please review.

Project coverage is 81.8%. Comparing base (f121f73) to head (97a2645).
Report is 57 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master     #898     +/-   ##
=========================================
- Coverage    81.9%    81.8%   -0.1%     
=========================================
  Files         853      853             
  Lines      231779   231938    +159     
=========================================
+ Hits       189829   189914     +85     
- Misses      41950    42024     +74     

@apfitzge
Copy link
Author

Local cluster summary looks fine:

mean_tps: 17282
max_tps: 52559
mean_confirmation_ms: 2978
max_confirmation_ms: 13360
99th_percentile_confirmation_ms: 11896
max_tower_distance: 32
last_tower_distance: 31
slots_per_second: 2.705

@apfitzge apfitzge marked this pull request as ready for review April 22, 2024 17:45
should_forward: bool,
},
/// Only used during transition.
Transitioning,

Choose a reason for hiding this comment

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

a necessary hack for take, only wish it is entirely internal

core/src/banking_stage.rs Outdated Show resolved Hide resolved
core/src/banking_stage.rs Outdated Show resolved Hide resolved
core/src/banking_stage.rs Outdated Show resolved Hide resolved
// If we hit the time limit. Drop everything that was not checked/processed.
// If we cannot run these simple checks in time, then we cannot run them during
// leader slot.
if max_time_reached {

Choose a reason for hiding this comment

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

how's that 100 ms determined?

Copy link
Author

Choose a reason for hiding this comment

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

Just did 1/4 of a block time; the checks done in this should be really quick, and if we cannot do these within 100ms we won't get to these packets in a scheduling loop which does more complex checks than these (currently).

Choose a reason for hiding this comment

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

The logic of "we will do up to 100ms forwarding work, if there are still packets in container after that, they will be dropped" sounds a bit arbitrary. When I benching it, I have to change MAX_FORWARDING_DURATION to MAX. What do you think to stop processing forwarding when CU limit is hit (it already does that somewhat, just not perfect).

In any case, for this PR we worry about sending too many to next leader more than not sending enough. I think it is OK for now. Maybe keep an eye on number of forwarded packets vs dropped packets.

Copy link

@tao-stones tao-stones left a comment

Choose a reason for hiding this comment

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

lgtm - offline benchmarking on new forwarding function are inline with original scheduler's forwarder. It adds the needed functionality to new scheduler.

I made a note on small implementation detail, which is the part I am looking at to optimize, for both original scheduler and new one. We can merge this PR, then refactor Forwarder afterwards

// If we hit the time limit. Drop everything that was not checked/processed.
// If we cannot run these simple checks in time, then we cannot run them during
// leader slot.
if max_time_reached {

Choose a reason for hiding this comment

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

The logic of "we will do up to 100ms forwarding work, if there are still packets in container after that, they will be dropped" sounds a bit arbitrary. When I benching it, I have to change MAX_FORWARDING_DURATION to MAX. What do you think to stop processing forwarding when CU limit is hit (it already does that somewhat, just not perfect).

In any case, for this PR we worry about sending too many to next leader more than not sending enough. I think it is OK for now. Maybe keep an eye on number of forwarded packets vs dropped packets.

@apfitzge apfitzge merged commit fb35f19 into anza-xyz:master Apr 26, 2024
38 checks passed
@apfitzge apfitzge deleted the scheduler-support-forwarding branch April 26, 2024 17:18
@apfitzge apfitzge added the v1.18 label Jun 10, 2024
Copy link

mergify bot commented Jun 10, 2024

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

mergify bot pushed a commit that referenced this pull request Jun 10, 2024
(cherry picked from commit fb35f19)

# Conflicts:
#	core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs
#	core/src/banking_stage/transaction_scheduler/scheduler_controller.rs
#	core/src/banking_stage/transaction_scheduler/scheduler_metrics.rs
#	core/src/banking_stage/transaction_scheduler/transaction_state.rs
#	core/src/banking_stage/transaction_scheduler/transaction_state_container.rs
#	core/src/validator.rs
apfitzge added a commit that referenced this pull request Jun 11, 2024
(cherry picked from commit fb35f19)

# Conflicts:
#	core/src/banking_stage/transaction_scheduler/prio_graph_scheduler.rs
#	core/src/banking_stage/transaction_scheduler/scheduler_controller.rs
#	core/src/banking_stage/transaction_scheduler/scheduler_metrics.rs
#	core/src/banking_stage/transaction_scheduler/transaction_state.rs
#	core/src/banking_stage/transaction_scheduler/transaction_state_container.rs
#	core/src/validator.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants