Skip to content

Commit 9db4e0e

Browse files
committed
Use more reasonable stack sizes and growth factors
1 parent 1308711 commit 9db4e0e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/librustc/middle/recursion_limit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use syntax::ast;
2020

2121
use rustc_data_structures::sync::Once;
2222

23-
const RED_ZONE: usize = 1024*1024; // 1MB
24-
const STACK_PER_RECURSION: usize = 8 * 1024 * 1024; // 8MB
23+
const RED_ZONE: usize = 100*1024; // 100k
24+
const STACK_PER_RECURSION: usize = 1 * 1024 * 1024; // 1MB
2525

2626
/// Grows the stack on demand to prevent stack overflow. Call this in strategic locations
2727
/// to "break up" recursive calls. E.g. almost any call to `visit_expr` or equivalent can benefit

src/librustc_driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn spawn_thread_pool<F: FnOnce(config::Options) -> R + sync::Send, R: sync::
9191
let config = ThreadPoolBuilder::new()
9292
.num_threads(Session::query_threads_from_opts(&opts))
9393
.deadlock_handler(|| unsafe { ty::query::handle_deadlock() })
94-
.stack_size(16 * 1024 * 1024);
94+
.stack_size(::STACK_SIZE);
9595

9696
let with_pool = move |pool: &ThreadPool| {
9797
pool.install(move || f(opts))

src/librustc_driver/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,8 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
14681468
}
14691469
}
14701470

1471+
const STACK_SIZE: usize = 4 * 1024 * 1024; // 4MB
1472+
14711473
/// Runs `f` in a suitable thread for running `rustc`; returns a `Result` with either the return
14721474
/// value of `f` or -- if a panic occurs -- the panic value.
14731475
///
@@ -1477,8 +1479,6 @@ pub fn in_named_rustc_thread<F, R>(name: String, f: F) -> Result<R, Box<dyn Any
14771479
where F: FnOnce() -> R + Send + 'static,
14781480
R: Send + 'static,
14791481
{
1480-
// Temporarily have stack size set to 16MB to deal with nom-using crates failing
1481-
const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB
14821482

14831483
#[cfg(all(unix, not(target_os = "haiku")))]
14841484
let spawn_thread = unsafe {

0 commit comments

Comments
 (0)