-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some of this is unavoidable due to each actor having 3 bounded and 1 …
…unbounded messaging channels, but the supervision logic alone had 3 dashmaps inside it. The monitoring functionality is pretty limited at-best, and we have no active use-cases for it, so dropping it and moving to a simple locked HashMap has allowed us to drop the heap space per actor to a little over 9KB Additionally in running benchmarks against `main` we see large perf wins on actor creation time ``` Running benches/actor.rs (target/release/deps/actor-464b0ad86c94b02f) Gnuplot not found, using plotters backend Creation of 100 actors time: [269.21 µs 282.84 µs 298.29 µs] change: [-66.867% -64.514% -61.953%] (p = 0.00 < 0.05) Performance has improved. Found 15 outliers among 100 measurements (15.00%) 9 (9.00%) high mild 6 (6.00%) high severe Creation of 10000 actors time: [25.273 ms 25.862 ms 26.484 ms] change: [-55.663% -53.735% -51.795%] (p = 0.00 < 0.05) Performance has improved. Found 1 outliers among 100 measurements (1.00%) 1 (1.00%) high mild ```
- Loading branch information
Showing
12 changed files
with
115 additions
and
233 deletions.
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
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,86 @@ | ||
// Copyright (c) Sean Lawlor | ||
// | ||
// This source code is licensed under both the MIT license found in the | ||
// LICENSE-MIT file in the root directory of this source tree. | ||
|
||
//! Just creates a LOT of actors. Useful for measuring max memory util | ||
//! | ||
//! Execute with | ||
//! | ||
//! ```text | ||
//! cargo run --example a_whole_lotta | ||
//! ``` | ||
#![allow(clippy::incompatible_msrv)] | ||
|
||
extern crate ractor; | ||
|
||
use ractor::{Actor, ActorProcessingErr, ActorRef}; | ||
|
||
struct Counter; | ||
|
||
#[cfg_attr(feature = "async-trait", ractor::async_trait)] | ||
impl Actor for Counter { | ||
type Msg = (); | ||
type State = (); | ||
type Arguments = (); | ||
|
||
async fn pre_start( | ||
&self, | ||
_myself: ActorRef<Self::Msg>, | ||
_: (), | ||
) -> Result<Self::State, ActorProcessingErr> { | ||
tracing::info!("Starting the actor"); | ||
// create the initial state | ||
Ok(()) | ||
} | ||
} | ||
|
||
fn init_logging() { | ||
let dir = tracing_subscriber::filter::Directive::from(tracing::Level::DEBUG); | ||
|
||
use std::io::stderr; | ||
use std::io::IsTerminal; | ||
use tracing_glog::Glog; | ||
use tracing_glog::GlogFields; | ||
use tracing_subscriber::filter::EnvFilter; | ||
use tracing_subscriber::layer::SubscriberExt; | ||
use tracing_subscriber::Registry; | ||
|
||
let fmt = tracing_subscriber::fmt::Layer::default() | ||
.with_ansi(stderr().is_terminal()) | ||
.with_writer(std::io::stderr) | ||
.event_format(Glog::default().with_timer(tracing_glog::LocalTime::default())) | ||
.fmt_fields(GlogFields::default().compact()); | ||
|
||
let filter = vec![dir] | ||
.into_iter() | ||
.fold(EnvFilter::from_default_env(), |filter, directive| { | ||
filter.add_directive(directive) | ||
}); | ||
|
||
let subscriber = Registry::default().with(filter).with(fmt); | ||
tracing::subscriber::set_global_default(subscriber).expect("to set global subscriber"); | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
init_logging(); | ||
|
||
let mut actors = Vec::new(); | ||
|
||
for _ in 0..100000 { | ||
actors.push( | ||
Actor::spawn(None, Counter, ()) | ||
.await | ||
.expect("Failed to start actor!"), | ||
); | ||
} | ||
|
||
for act in actors.iter() { | ||
act.0.stop(None); | ||
} | ||
for (_, h) in actors.into_iter() { | ||
h.await.expect("Failed to wait for actor shutdown"); | ||
} | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.