Sitelet https://github.com/starkware-libs/cairo/pull/9860
Skip to content

fix: include all reachable modules in cache generation via BFS over submodule and macro call edges - #9860

Merged
orizi merged 1 commit into
mainfrom
orizi/04-20-fix_include_all_reachable_modules_in_cache_generation_via_bfs_over_submodule_and_macro_call_edges
Apr 20, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/04-20-fix_include_all_reachable_modules_in_cache_generation_via_bfs_over_submodule_and_macro_call_edges

Conversation

@orizi

@orizi orizi commented Apr 20, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR

Introduced a unified all_crate_modules_for_cache function to replace duplicated module traversal logic in cache generation.

What changed?

A new all_crate_modules_for_cache function was added to cairo-lang-semantic that performs a breadth-first traversal of all modules reachable from a crate root, following both submodule and macro call edges. This replaces the previous pattern of using itertools::chain combined with module_macro_modules calls scattered across generate_crate_def_cache, generate_crate_semantic_cache, and the lowering cache generation. The module_macro_modules import was removed from both the semantic and lowering cache modules in favor of this centralized traversal.

How to test?

Run the existing cache-related tests to verify that crate cache generation still correctly captures all modules, including those nested inside macro call modules.

Why make this change?

The previous approach duplicated the logic for enumerating all relevant modules in multiple places, and relied on module_macro_modules with an inline chain! pattern that was easy to get wrong. Centralizing this traversal into all_crate_modules_for_cache ensures consistent behavior across def, semantic, and lowering cache generation, and makes the intent — following both submodule and macro call edges — explicit and reusable.

orizi commented Apr 20, 2026 •

Copy link
Copy Markdown
Collaborator Author

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@orizi
orizi force-pushed the orizi/04-20-fix_include_all_reachable_modules_in_cache_generation_via_bfs_over_submodule_and_macro_call_edges branch from 6d33896 to fff512d Compare April 20, 2026 09:52
@orizi
orizi changed the base branch from orizi/04-19-feat_add_corelib_benchmarks_and_refactor_to_shared_bench_all_phases_helper to graphite-base/9860 April 20, 2026 09:55
@orizi
orizi force-pushed the orizi/04-20-fix_include_all_reachable_modules_in_cache_generation_via_bfs_over_submodule_and_macro_call_edges branch from fff512d to dacf45d Compare April 20, 2026 09:56
@orizi
orizi force-pushed the graphite-base/9860 branch from 2a75dee to cb089a7 Compare April 20, 2026 09:56
@orizi
orizi changed the base branch from graphite-base/9860 to main April 20, 2026 09:56
@orizi
orizi requested a review from TomerStarkware April 20, 2026 09:56
@orizi
orizi marked this pull request as ready for review April 20, 2026 09:56
@cursor

cursor Bot commented Apr 20, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes which modules are included in serialized caches, which can affect cache contents/size and downstream compilation behavior; traversal is simple but touches core caching paths.

Overview
Cache generation now enumerates modules via a shared reachability traversal rather than crate_modules + module_macro_modules chaining.

A new all_crate_modules_for_cache (BFS over submodule and macro-call edges) is added in cairo-lang-semantic and used by generate_crate_def_cache, generate_crate_semantic_cache, and lowering’s generate_crate_cache, ensuring caches include modules nested under macro expansions and removing duplicated traversal logic/imports.

Reviewed by Cursor Bugbot for commit dacf45d. Bugbot is set up for automated code reviews on this repo. Configure here.

@TomerStarkware TomerStarkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on orizi).

@orizi
orizi added this pull request to the merge queue Apr 20, 2026
Merged via the queue into main with commit 3e3edda Apr 20, 2026
105 checks passed
@orizi
orizi deleted the orizi/04-20-fix_include_all_reachable_modules_in_cache_generation_via_bfs_over_submodule_and_macro_call_edges branch April 20, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants