Skip to content

Commit

Permalink
Box NewTaskPayload to reduce size greatly (#2881)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun authored Sep 10, 2024
1 parent c7e44c1 commit 6bd5d38
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions unified-scheduler-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ solana-runtime = { workspace = true }
solana-sdk = { workspace = true }
solana-timings = { workspace = true }
solana-unified-scheduler-logic = { workspace = true }
static_assertions = { workspace = true }
vec_extract_if_polyfill = { workspace = true }

[dev-dependencies]
Expand Down
15 changes: 8 additions & 7 deletions unified-scheduler-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use {
},
solana_timings::ExecuteTimings,
solana_unified_scheduler_logic::{SchedulingStateMachine, Task, UsageQueue},
static_assertions::const_assert_eq,
std::{
fmt::Debug,
marker::PhantomData,
Expand Down Expand Up @@ -475,7 +476,8 @@ enum SubchanneledPayload<P1, P2> {
CloseSubchannel,
}

type NewTaskPayload = SubchanneledPayload<Task, (SchedulingContext, ResultWithTimings)>;
type NewTaskPayload = SubchanneledPayload<Task, Box<(SchedulingContext, ResultWithTimings)>>;
const_assert_eq!(mem::size_of::<NewTaskPayload>(), 16);

// A tiny generic message type to synchronize multiple threads everytime some contextual data needs
// to be switched (ie. SchedulingContext), just using a single communication channel.
Expand Down Expand Up @@ -1092,10 +1094,9 @@ impl<S: SpawnableScheduler<TH>, TH: TaskHandler> ThreadManager<S, TH> {

// Prepare for the new session.
match new_task_receiver.recv() {
Ok(NewTaskPayload::OpenSubchannel((
new_context,
new_result_with_timings,
))) => {
Ok(NewTaskPayload::OpenSubchannel(context_and_result_with_timings)) => {
let (new_context, new_result_with_timings) =
*context_and_result_with_timings;
// We just received subsequent (= not initial) session and about to
// enter into the preceding `while(!is_finished) {...}` loop again.
// Before that, propagate new SchedulingContext to handler threads
Expand Down Expand Up @@ -1332,10 +1333,10 @@ impl<S: SpawnableScheduler<TH>, TH: TaskHandler> ThreadManager<S, TH> {
assert!(!self.are_threads_joined());
assert_matches!(self.session_result_with_timings, None);
self.new_task_sender
.send(NewTaskPayload::OpenSubchannel((
.send(NewTaskPayload::OpenSubchannel(Box::new((
context,
result_with_timings,
)))
))))
.expect("no new session after aborted");
}
}
Expand Down

0 comments on commit 6bd5d38

Please sign in to comment.