Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently set 8 MiB stack sizes on all platforms #1490

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal class AndroidTreehouseDispatchers : TreehouseDispatchers {

/** The single thread that runs all JavaScript. We only have one QuickJS instance at a time. */
private val executorService = Executors.newSingleThreadExecutor { runnable ->
Thread(runnable, "Treehouse")
Thread(null, runnable, "Treehouse", ZIPLINE_THREAD_STACK_SIZE.toLong())
.also { ziplineThread = it }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ public interface TreehouseDispatchers {
*/
public fun close()
}

/**
* We configure an 8 MiB thread size because we've experimentally found that's sufficient for our
* guest programs.
*/
internal val ZIPLINE_THREAD_STACK_SIZE = 8 * 1024 * 1024
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ private class SingleThreadCoroutineDispatcher : CloseableCoroutineDispatcher() {
/**
* On Apple platforms we need to explicitly set the stack size for background threads; otherwise
* we get the default of 512 KiB which isn't sufficient for our QuickJS programs.
*
* 8 MiB is more than sufficient.
*/
private val stackSize = 8 * 1024 * 1024
private val stackSize = ZIPLINE_THREAD_STACK_SIZE
private val channel = Channel<Runnable>(capacity = Channel.UNLIMITED)

val thread = NSThread {
Expand Down