Skip to content

feat: increase default stack size from 8MB to 1GB#12971

Merged
Kha merged 3 commits intoleanprover:masterfrom
Kha:push-nrrmpwwqxwpz
Mar 20, 2026
Merged

feat: increase default stack size from 8MB to 1GB#12971
Kha merged 3 commits intoleanprover:masterfrom
Kha:push-nrrmpwwqxwpz

Conversation

@Kha
Copy link
Copy Markdown
Member

@Kha Kha commented Mar 18, 2026

This PR increases Lean's default stack size, including for the main thread of Lean executables, to 1GB.

As stack pages are allocated dynamically, this should not change the memory usage of programs but can prevent them from stack overflowing.

The stack size (of any Lean thread) can now be customized via the LEAN_STACK_SIZE_KB environment variable. main can be prevented from running on a new thread by setting LEAN_MAIN_USE_THREAD=0, in which case the default OS stack size management applies to the main thread again.

@Kha Kha requested review from hargoniX and leodemoura as code owners March 18, 2026 17:02
@Kha
Copy link
Copy Markdown
Member Author

Kha commented Mar 18, 2026

!bench

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Mar 18, 2026

Benchmark results for 938bb81 against 61a3443 are in. Significant changes detected! @Kha

  • 🟥 build//instructions: +4.6G (+0.04%)

Large changes (5🟥)

  • 🟥 compiled/liasolver//instructions: +232.5M (+5.63%)
  • 🟥 compiled/nat_repr//instructions: +674.7M (+20.85%)
  • 🟥 compiled/qsort//instructions: +1.9G (+11.24%)
  • 🟥 compiled/unionfind//instructions: +4.3G (+17.25%)
  • 🟥 compiled/workspaceSymbolsNewRanges//instructions: +30.5M (+4.11%)

Medium changes (1✅, 2🟥)

  • 🟥 compiled/binarytrees.st//instructions: +45.9M (+0.07%)
  • compiled/const_fold//instructions: -229.8M (-2.61%)
  • 🟥 compiled/iterators//instructions: +6.1M (+1.07%)

Small changes (2✅, 4🟥)

  • compiled/hashmap//instructions: -2.1M (-0.06%)
  • 🟥 compiled/qsort//task-clock: +66ms (+5.90%)
  • 🟥 compiled/qsort//wall-clock: +66ms (+5.88%)
  • compiled/treemap//instructions: -2.5M (-0.01%)
  • 🟥 lake/inundation/config import//task-clock: +8ms (+5.36%)
  • 🟥 lake/inundation/config import//wall-clock: +8ms (+5.42%)

Kha added 2 commits March 18, 2026 17:10
As stack pages are allocated dynamically, this should not change the memory usage of programs but can prevent them from stack overflowing.
@Kha Kha force-pushed the push-nrrmpwwqxwpz branch from 938bb81 to 608e51e Compare March 18, 2026 17:10
@Kha Kha added changelog-compiler Compiler, runtime, and FFI release-ci Enable all CI checks for a PR, like is done for releases labels Mar 18, 2026
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Mar 18, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-03-18 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-03-18 21:36:17)

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Mar 18, 2026
@github-actions github-actions bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Mar 18, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 18, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Mar 18, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Mar 19, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 19, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

@Kha
Copy link
Copy Markdown
Member Author

Kha commented Mar 19, 2026

!bench mathlib

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Mar 19, 2026

Benchmark results for leanprover-community/mathlib4-nightly-testing@0458de3 against leanprover-community/mathlib4-nightly-testing@a0c49ce are in. Significant changes detected! @Kha

  • 🟥 build//instructions: +6.0G (+0.00%)

Large changes (1✅)

  • build/profile/C code generation//wall-clock: -161ms (-1.41%)

Small changes (2✅, 2🟥)

  • 🟥 build/module/Mathlib.RingTheory.Polynomial.ShiftedLegendre//instructions: +1.3G (+10.64%)
  • 🟥 build/module/Mathlib.Tactic.CategoryTheory.Monoidal.PureCoherence//instructions: +595.1M (+3.28%)
  • build/profile/import//wall-clock: -1m 28s (-1.36%)
  • build/profile/interpretation//wall-clock: -2m 47s (-1.78%)

@Kha Kha enabled auto-merge March 20, 2026 10:49
@Kha Kha force-pushed the push-nrrmpwwqxwpz branch from a224abc to 3c91ec2 Compare March 20, 2026 12:18
mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Mar 20, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 20, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Mar 20, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 20, 2026
@Kha Kha force-pushed the push-nrrmpwwqxwpz branch from 3c91ec2 to 27559eb Compare March 20, 2026 14:21
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

@Kha Kha added this pull request to the merge queue Mar 20, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Mar 20, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Mar 20, 2026
Merged via the queue into leanprover:master with commit 609a05a Mar 20, 2026
47 checks passed
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

@Kha Kha deleted the push-nrrmpwwqxwpz branch March 24, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-compiler Compiler, runtime, and FFI mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN release-ci Enable all CI checks for a PR, like is done for releases toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants