Constant style::parallel::STACK_SAFETY_MARGIN_KB

source ยท
pub const STACK_SAFETY_MARGIN_KB: usize = 168;
Expand description

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.

We allocate large safety margins because certain OS calls can use very large amounts of stack space [1]. Reserving a larger-than-necessary stack costs us address space, but if we keep our safety margin big, we will generally avoid committing those extra pages, and only use them in edge cases that would otherwise cause crashes.

When measured with 128KB stacks and 40KB margin, we could support 53 levels of recursion before the limiter kicks in, on x86_64-Linux [2]. When we doubled the stack size, we added it all to the safety margin, so we should be able to get the same amount of recursion.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1395708#c15 [2] See Gecko bug 1376883 for more discussion on the measurements.