Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion style/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,21 @@ pub const STYLE_THREAD_STACK_SIZE_KB: usize = 256;

/// The minimum stack size for a thread in the styling pool, in kilobytes.
/// Servo requires a bigger stack in debug builds.
/// We allow configuring the size, since running with ASAN requires an even larger
/// stack size.
#[cfg(feature = "servo")]
pub const STYLE_THREAD_STACK_SIZE_KB: usize = 512;
pub const STYLE_THREAD_STACK_SIZE_KB: usize = const {
let default_stack_size = 512;
if let Some(user_def_size) = option_env!("SERVO_STYLE_THREAD_STACK_SIZE_KB") {
if let Ok(user_def_size) = usize::from_str_radix(user_def_size, 10) {
user_def_size
} else {
panic!("SERVO_STYLE_THREAD_STACK_SIZE_KB must be a valid integer")
}
} else {
default_stack_size
}
};
Comment on lines +40 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to make this a bit simpler and just increase the stack size when ASAN is enabled?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given servo/servo#40814 I would also like to do this for debug builds, if possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer keeping it configurable too, since it allows embedders to adjust the stack size based on their needs.
The code is quite simple, just very verbose since we can't use any traits in const contexts, like and_then() or unwrap_or().


/// The stack margin. If we get this deep in the stack, we will skip recursive
/// optimizations to ensure that there is sufficient room for non-recursive work.
Expand Down