Skip to content

Commit

Permalink
Resolve Stack Overflow (#1103)
Browse files Browse the repository at this point in the history
* rayon configs

* see how big these badbois are

* print max and min len

* fix min

* div by 0

* with_min_len(10)

* local threadpool

* with_min_len(cpus)

* dbg prints remove

* clippy

* lazy statis num cpus, and expect

* use globalthreadpool
  • Loading branch information
ec2 authored May 19, 2021
1 parent bd90aa6 commit f87d0ba
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 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 forest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ paramfetch = { path = "../utils/paramfetch" }
encoding = { package = "forest_encoding", version = "0.2.1" }
networks = { path = "../types/networks" }
rpassword = "0.0.4"
rayon = "1.5"
prometheus = { version = "0.12.0", default-features = false }

[dependencies.jsonrpc-v2]
Expand Down
6 changes: 6 additions & 0 deletions forest/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ pub(super) async fn start(config: Config) {
.set(address::Network::Mainnet)
.unwrap();

// Configure the Rayon Threadpool
rayon::ThreadPoolBuilder::new()
.thread_name(|n| format!("rayon-thread-{}", n))
.build_global()
.expect("Failed to create global Rayon ThreadPool");

info!("Starting Forest daemon");
let net_keypair = get_keypair(&format!("{}{}", &config.data_dir, "/libp2p/keypair"))
.unwrap_or_else(|| {
Expand Down
1 change: 1 addition & 0 deletions vm/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ahash = "0.6"
lazy_static = "1.4"
rayon = "1.3"
networks = { path = "../../types/networks" }
num_cpus = "1.13"

[dev-dependencies]
ipld_hamt = "1.0"
Expand Down
5 changes: 5 additions & 0 deletions vm/interpreter/src/default_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ use vm::{
EMPTY_ARR_CID, METHOD_SEND,
};

lazy_static! {
static ref NUM_CPUS: usize = num_cpus::get();
}

/// Max runtime call depth
const MAX_CALL_DEPTH: u64 = 4096;

Expand Down Expand Up @@ -987,6 +991,7 @@ where

let out = vis
.par_iter()
.with_min_len(vis.len() / *NUM_CPUS)
.map(|(&addr, seals)| {
let results = seals
.par_iter()
Expand Down

0 comments on commit f87d0ba

Please sign in to comment.