Skip to content

Commit dc3d989

Browse files
stepanchegfacebook-github-bot
authored andcommitted
MAX_CALLSTACK_RECURSION doc
Summary: Better descriptions and TODO about `MAX_CALLSTACK_RECURSION` constants. Reviewed By: bobyangyf Differential Revision: D38712857 fbshipit-source-id: cfa47a92d04eb7b02a7ac429693234251e90636d
1 parent 894e97f commit dc3d989

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

starlark/src/eval/runtime/call_stack.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,18 @@ impl<'v> Default for CheapCallStack<'v> {
179179
}
180180
}
181181

182-
/// At 50 we see the C stack overflowing, so limit to 40 (which seems quite low...).
183-
///
184-
/// Note some calls may be inlined (special functions like `len`
185-
/// or simple functions like `def f(): return 1`), so effectively call stack
186-
/// may be larger depending on what optimizations applied.
182+
// Currently, each frame typically allocates about 1K of native stack size (see `test_frame_size`),
183+
// but it is a bit more complicated:
184+
// * each for loop in a frame allocates more native stack
185+
// * inlined functions do not allocate native stack
186+
// Practically max call stack depends on native stack size,
187+
// and depending on environment, it may be configured differently, for example:
188+
// * macOS default stack size is 512KB
189+
// * Linux default stack size is 8MB
190+
// * [tokio default stack size is 2MB][1]
191+
// [1] https://docs.rs/tokio/0.2.1/tokio/runtime/struct.Builder.html#method.thread_stack_size
192+
// TODO(nga): count loops in call stack size.
193+
// TODO(nga): make it configurable.
187194
const MAX_CALLSTACK_RECURSION: usize = 40;
188195

189196
unsafe impl<'v> Trace<'v> for CheapCallStack<'v> {

0 commit comments

Comments
 (0)