Skip to content

Stream .asts.json to fix autosetup OOM (SIGKILL) on larger trees - #75

Merged
jar-ben merged 4 commits into
masterfrom
jaroslav/ijson-in-autosetup
Jul 15, 2026
Merged

Stream .asts.json to fix autosetup OOM (SIGKILL) on larger trees#75
jar-ben merged 4 commits into
masterfrom
jaroslav/ijson-in-autosetup

Conversation

@jar-ben

@jar-ben jar-ben commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Autosetup json.loaded the whole .asts.json (~2.5GB on a mid-size project) at four sites on the compilation-analysis path, each ballooning to 8-12GB of Python objects and getting OOM-killed.

New stream_ast_files() (utils/file_utils.py) streams the file one source file at a time via ijson; all four loaders (generate_ast_graph, _build_declared_contracts_by_file, _extract_inheritance_and_abstract_from_ast,
auto_munges.detect_and_apply_code_access_patches) route through it. Adds ijson.

@jar-ben
jar-ben requested review from naftali-g and shellygr July 15, 2026 12:36
Comment thread certora_autosetup/setup/setup_prover.py Outdated
Comment on lines +1150 to +1155
contract_defs.append({
"id": node.get("id"),
"name": node.get("name"),
"abstract": node.get("abstract", False),
"contractKind": node.get("contractKind", "contract"),
"linearizedBaseContracts": node.get("linearizedBaseContracts", []),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we want to make this a dataclass?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if we had a pydantic model of the solc ast a lot of our work would be a lot easier... I wonder if such exists

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there might be one for typescript https://github.com/OpenZeppelin/solidity-ast

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Perhaps I leave that for a follow-up PR? and in this one I add a dataclass for this local change

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sounds fine to me

@jar-ben
jar-ben merged commit 33e71c1 into master Jul 15, 2026
4 checks passed
shellygr added a commit that referenced this pull request Jul 16, 2026
…solidity_ast

stream_ast_files's four call sites collapse into the typed layer: new
AstDump.stream_units() (per-compilation-unit typed streaming with unit_filter
and solc_version gates) and stream_raw_units() (raw pairs for the byte-compat
parent-graph pass, which now accepts streamed units). All three consumers
stream instead of whole-file loading; load_cached is gone (the memory win
outweighs the shared parse), stream_ast_files removed with its purpose.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants