-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Executor work #53
Merged
Merged
Executor work #53
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
116c81f
Initial executor design
vertexclique 4ffe7d5
Cargo fix
vertexclique b3d8e8f
Cargo format
vertexclique 8902488
Stack representation
vertexclique e41926a
Stack copy implementation
vertexclique 2cb4ae3
Run queue size
vertexclique 8301043
Load balancer schedule timing
vertexclique b747429
LoadBalancer
vertexclique cc4fbbb
Global allocator
vertexclique 1590cd3
cargo fix & format
vertexclique 056a455
Stat struct
vertexclique b825af1
Reduce allocator dependencies
vertexclique 1ea3cb9
Spawn async problems
vertexclique 089e3f2
Scheduler complete
vertexclique 92c4ca8
Fix panic example
vertexclique 77fa780
Remove debug points
vertexclique 7438669
Run queue docs
vertexclique 0ebcbf3
Cargo fix for all
vertexclique 960fee6
Code format
vertexclique a748b8c
Better messages for example
vertexclique c9bc705
Allocator implementation ordeR
vertexclique cc3547f
Cleaning the tests
vertexclique 566c408
Add benchmarks
vertexclique d1d7062
Enable numa-aware allocator
vertexclique 7078d0b
Lightproc data
vertexclique 53e5654
(cargo-release) version 0.3.0
vertexclique 845ea8c
Fill missing fields for Cargo.toml
vertexclique c4cb935
(cargo-release) version 0.3.1
vertexclique 324c2af
Add readmes
vertexclique 4d478f0
(cargo-release) version 0.3.2
vertexclique 5dc3ebc
(cargo-release) start next development iteration 0.3.2
vertexclique 46081af
Fix dep order
vertexclique 3e665b6
Change description of executor
vertexclique 5628389
Load balancer wait for it
vertexclique c8792a9
Address comments
vertexclique 04ad717
Remove feature enablers
vertexclique 2cca130
Add features back
vertexclique 44f744b
Select SMP core fix
vertexclique 7e9a938
Rework on the scheduler
vertexclique c4cd383
Remove old scheduler
vertexclique caa6b02
Use unstable feature gate for NUMA allocator
vertexclique File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,33 @@ | ||
[package] | ||
name = "bastion-executor" | ||
version = "0.2.1-alpha.0" | ||
description = "Fault-tolerant Runtime for Rust applications" | ||
description = "Cache affine NUMA-aware executor for Rust" | ||
authors = ["Mahmut Bulut <vertexclique@gmail.com>"] | ||
keywords = ["fault-tolerant", "runtime", "actor", "system"] | ||
categories = [] | ||
categories = ["concurrency", "asynchronous"] | ||
homepage = "https://github.com/bastion-rs/bastion" | ||
repository = "https://github.com/bastion-rs/bastion" | ||
documentation = "https://docs.rs/bastion" | ||
readme = "README.md" | ||
license = "Apache-2.0/MIT" | ||
edition = "2018" | ||
|
||
[features] | ||
unstable = ["numanji", "allocator-suite"] | ||
|
||
[dependencies] | ||
crossbeam-utils = "0.6" | ||
crossbeam-epoch = "0.7" | ||
lazy_static = "1.4" | ||
libc = "0.2" | ||
num_cpus = "1.10" | ||
rustc-hash = "1.0.1" | ||
pin-utils = "0.1.0-alpha.4" | ||
lightproc = { "path" = "../lightproc" } | ||
|
||
# Allocator | ||
numanji = { version = "^0.1", optional = true, default-features = false} | ||
allocator-suite = { version = "^0.1", optional = true, default-features = false} | ||
|
||
[target.'cfg(not(any(target_os = "android", target_os = "linux")))'.dependencies] | ||
jemallocator = "^0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Bastion Executor | ||
|
||
SMP enabled NUMA-aware executor for Rust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![feature(test)] | ||
|
||
extern crate test; | ||
|
||
use bastion_executor::prelude::*; | ||
use test::{black_box, Bencher}; | ||
use lightproc::proc_stack::ProcStack; | ||
|
||
#[bench] | ||
fn increment(b: &mut Bencher) { | ||
let mut sum = 0; | ||
|
||
b.iter( || { | ||
run(async { | ||
(0..10_000_000).for_each(|_| { sum += 1; }); | ||
}, ProcStack::default()); | ||
}); | ||
|
||
black_box(sum); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use bastion_executor::prelude::*; | ||
use lightproc::proc_stack::ProcStack; | ||
|
||
fn main() { | ||
run( | ||
async { | ||
println!("Example execution"); | ||
panic!("fault"); | ||
}, | ||
ProcStack::default().with_after_panic(|| println!("after panic")), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use bastion_executor::prelude::*; | ||
use lightproc::proc_stack::ProcStack; | ||
|
||
fn main() { | ||
let pid = 1; | ||
let stack = ProcStack::default() | ||
.with_pid(pid) | ||
.with_after_panic(move || println!("after panic {}", pid.clone())); | ||
|
||
let handle = spawn( | ||
async { | ||
panic!("test"); | ||
}, | ||
stack, | ||
); | ||
|
||
let pid = 2; | ||
let stack = ProcStack::default().with_pid(pid); | ||
|
||
run( | ||
async { | ||
handle.await; | ||
}, | ||
stack.clone(), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
unstable_api! { | ||
// Allocation selector import | ||
use numanji::*; | ||
|
||
// Drive selection of allocator here | ||
autoselect!(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// FIXME: Blocking pool implementation goes here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use super::placement; | ||
use super::placement::CoreId; | ||
use super::run_queue::{Stealer, Worker}; | ||
|
||
use lightproc::prelude::*; | ||
|
||
use crate::worker; | ||
use std::thread; | ||
|
||
pub(crate) struct Distributor { | ||
pub round: usize, | ||
pub last_dead: usize, | ||
pub cores: Vec<CoreId>, | ||
} | ||
|
||
impl Distributor { | ||
pub fn new() -> Self { | ||
Distributor { | ||
round: 0_usize, | ||
last_dead: usize::max_value(), | ||
cores: placement::get_core_ids().expect("Core mapping couldn't be fetched"), | ||
} | ||
} | ||
|
||
pub fn assign(mut self) -> Vec<Stealer<LightProc>> { | ||
let mut stealers = Vec::<Stealer<LightProc>>::new(); | ||
|
||
for core in self.cores { | ||
self.round = core.id; | ||
|
||
let wrk = Worker::new_fifo(); | ||
stealers.push(wrk.stealer()); | ||
|
||
thread::Builder::new() | ||
.name("bastion-async-thread".to_string()) | ||
.spawn(move || { | ||
// affinity assignment | ||
placement::set_for_current(core); | ||
|
||
// actual execution | ||
worker::main_loop(core.id.clone(), wrk); | ||
}) | ||
.expect("cannot start the thread for running proc"); | ||
} | ||
|
||
stealers | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
mod pool; | ||
mod blocking_pool; | ||
//! | ||
//! | ||
//! | ||
//! NUMA-aware SMP based Fault-tolerant Executor | ||
//! | ||
//! | ||
|
||
// Force missing implementations | ||
#![warn(missing_docs)] | ||
#![warn(missing_debug_implementations)] | ||
|
||
#[macro_use] | ||
mod macros; | ||
|
||
pub mod allocator; | ||
pub mod blocking_pool; | ||
pub mod distributor; | ||
pub mod load_balancer; | ||
pub mod placement; | ||
pub mod pool; | ||
pub mod run; | ||
pub mod run_queue; | ||
pub mod sleepers; | ||
pub mod thread_recovery; | ||
pub mod worker; | ||
|
||
pub mod prelude { | ||
pub use crate::pool::*; | ||
pub use crate::run::*; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use super::placement; | ||
use lazy_static::*; | ||
|
||
use std::thread; | ||
|
||
use super::load_balancer; | ||
use crossbeam_utils::sync::ShardedLock; | ||
use rustc_hash::FxHashMap; | ||
|
||
pub struct LoadBalancer(); | ||
|
||
impl LoadBalancer { | ||
pub fn sample() { | ||
thread::Builder::new() | ||
.name("load-balancer-thread".to_string()) | ||
.spawn(move || { | ||
loop { | ||
let mut m = 0_usize; | ||
if let Ok(stats) = load_balancer::stats().try_read() { | ||
m = stats | ||
.smp_queues | ||
.values() | ||
.sum::<usize>() | ||
.wrapping_div(placement::get_core_ids().unwrap().len()); | ||
} | ||
|
||
if let Ok(mut stats) = load_balancer::stats().try_write() { | ||
stats.mean_level = m; | ||
} | ||
} | ||
}) | ||
.expect("load-balancer couldn't start"); | ||
} | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct Stats { | ||
pub(crate) global_run_queue: usize, | ||
pub(crate) mean_level: usize, | ||
pub(crate) smp_queues: FxHashMap<usize, usize>, | ||
} | ||
|
||
unsafe impl Send for Stats {} | ||
unsafe impl Sync for Stats {} | ||
|
||
#[inline] | ||
pub fn stats() -> &'static ShardedLock<Stats> { | ||
lazy_static! { | ||
static ref LB_STATS: ShardedLock<Stats> = { | ||
let stats = Stats { | ||
global_run_queue: 0, | ||
mean_level: 0, | ||
smp_queues: FxHashMap::with_capacity_and_hasher( | ||
placement::get_core_ids().unwrap().len(), | ||
Default::default() | ||
) | ||
}; | ||
|
||
// Start sampler | ||
LoadBalancer::sample(); | ||
|
||
// Return stats | ||
ShardedLock::new(stats) | ||
}; | ||
} | ||
&*LB_STATS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[doc(hidden)] | ||
macro_rules! unstable_api { | ||
($($block:item)*) => { | ||
$( | ||
#[cfg(feature = "unstable")] | ||
$block | ||
)* | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Distributor.round
doesn't seem to be used anywhere else