-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Adjustable stack size for EVM #2483
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,19 @@ use crossbeam::sync::chase_lev; | |
use service::{HandlerId, IoChannel, IoContext}; | ||
use IoHandler; | ||
use panics::*; | ||
use std::cell::Cell; | ||
|
||
use std::sync::{Condvar as SCondvar, Mutex as SMutex}; | ||
|
||
const STACK_SIZE: usize = 16*1024*1024; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like with 8kb frame the stack of 8mb should be enough There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this might be so, but previously we used 32kb |
||
|
||
thread_local! { | ||
/// Stack size | ||
/// Should be modified if it is changed in Rust since it is no way | ||
/// to know or get it | ||
pub static LOCAL_STACK_SIZE: Cell<usize> = Cell::new(::std::env::var("RUST_MIN_STACK").ok().and_then(|s| s.parse().ok()).unwrap_or(2 * 1024 * 1024)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minimum should be 512k, that's the default on OS X There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 512k must be default for the main thread only this expression exactly the same value which rust uses for spawned threads: |
||
} | ||
|
||
pub enum WorkType<Message> { | ||
Readable, | ||
Writable, | ||
|
@@ -66,8 +76,9 @@ impl Worker { | |
deleting: deleting.clone(), | ||
wait_mutex: wait_mutex.clone(), | ||
}; | ||
worker.thread = Some(thread::Builder::new().name(format!("IO Worker #{}", index)).spawn( | ||
worker.thread = Some(thread::Builder::new().stack_size(STACK_SIZE).name(format!("IO Worker #{}", index)).spawn( | ||
move || { | ||
LOCAL_STACK_SIZE.with(|val| val.set(STACK_SIZE)); | ||
panic_handler.catch_panic(move || { | ||
Worker::work_loop(stealer, channel.clone(), wait, wait_mutex.clone(), deleting) | ||
}).unwrap() | ||
|
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.
256kb per recursion frame? That's too much. Before the change it was 512k / 64 = 8kb
512k is the minimum stack size that we supported
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.
before change it was 2MB/64 = 32kb
i just used 16MB/64 instead, my bad