-
Notifications
You must be signed in to change notification settings - Fork 577
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
added precompilation for lowering #7199
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 8 of 19 files at r1, all commit messages.
Reviewable status: 8 of 19 files reviewed, 5 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-defs/src/diagnostic_utils.rs
line 14 at r1 (raw file):
/// A stable location of a real, concrete syntax. #[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)] pub struct StableLocation(pub SyntaxStablePtrId);
add a getter instead.
Cargo.toml
line 130 at r1 (raw file):
serde_json = "1.0.138" bincode = "1.3.3" sha2 = "0.10.8"
sort in toml.
Code quote:
serde = { version = "1.0.217", default-features = false, features = ["derive"] }
serde_json = "1.0.138"
bincode = "1.3.3"
sha2 = "0.10.8"
crates/cairo-lang-lowering/Cargo.toml
line 28 at r1 (raw file):
bincode.workspace = true serde = { workspace = true, default-features = true } smol_str.workspace = true
sort in toml.
move to dev dependencies assuming only used in tests.
Code quote:
bincode.workspace = true
serde = { workspace = true, default-features = true }
smol_str.workspace = true
crates/bin/get-lowering/Cargo.toml
line 22 at r1 (raw file):
cairo-lang-semantic = { path = "../../cairo-lang-semantic", version = "~2.9.2" } cairo-lang-utils = { path = "../../cairo-lang-utils", version = "~2.9.2" } bincode.workspace = true
sort in toml.
Code quote:
bincode.workspace = true
crates/cairo-lang-filesystem/src/ids.rs
line 220 at r1 (raw file):
#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub enum BlobLongId {
doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 8 of 19 files reviewed, 5 unresolved discussions (waiting on @orizi)
Cargo.toml
line 130 at r1 (raw file):
Previously, orizi wrote…
sort in toml.
Done.
crates/bin/get-lowering/Cargo.toml
line 22 at r1 (raw file):
Previously, orizi wrote…
sort in toml.
Done.
crates/cairo-lang-defs/src/diagnostic_utils.rs
line 14 at r1 (raw file):
Previously, orizi wrote…
add a getter instead.
Done.
crates/cairo-lang-filesystem/src/ids.rs
line 220 at r1 (raw file):
Previously, orizi wrote…
doc
Done.
crates/cairo-lang-lowering/Cargo.toml
line 28 at r1 (raw file):
Previously, orizi wrote…
sort in toml.
move to dev dependencies assuming only used in tests.
Done.
46690f6
to
597483f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 7 files at r2, all commit messages.
Reviewable status: 10 of 19 files reviewed, 2 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/db.rs
line 71 at r2 (raw file):
) -> Maybe<Arc<MultiLowering>>; fn load_serielized_multi_lowerings(
cached
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 19 files at r1, 2 of 7 files at r2.
Reviewable status: 15 of 19 files reviewed, 2 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/precompute/test.rs
line 104 at r2 (raw file):
} // TestRunnerResult::success(OrderedHashMap::from([
?
0bd0e33
to
ca1afcc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 14 of 19 files reviewed, 2 unresolved discussions (waiting on @orizi)
crates/cairo-lang-lowering/src/db.rs
line 71 at r2 (raw file):
Previously, orizi wrote…
cached
Done.
crates/cairo-lang-lowering/src/precompute/test.rs
line 104 at r2 (raw file):
Previously, orizi wrote…
?
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 19 files at r1, all commit messages.
Reviewable status: 15 of 19 files reviewed, 2 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/db.rs
line 71 at r2 (raw file):
Previously, TomerStarkware wrote…
Done.
not here at least.
ca1afcc
to
62eed75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 14 of 19 files reviewed, 2 unresolved discussions (waiting on @orizi)
crates/cairo-lang-lowering/src/db.rs
line 71 at r2 (raw file):
Previously, orizi wrote…
not here at least.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: 14 of 19 files reviewed, 4 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/db.rs
line 421 at r4 (raw file):
Vec<(DefsFunctionWithBodyIdCached, MultiLoweringCached)>, ) = bincode::deserialize(&content).unwrap_or_default(); let mut ctx = CacheLoadingContext::new(db, lookups, semantic_lookups, self_crate_id);
Suggestion:
) = bincode::deserialize(&content).unwrap_or_default();
// TODO(tomer): Fail on version, cfg, and dependencies mismatch.
let mut ctx = CacheLoadingContext::new(db, lookups, semantic_lookups, self_crate_id);
crates/cairo-lang-lowering/src/precompute/mod.rs
line 1 at r4 (raw file):
#[cfg(test)]
rename precompute to cache here as well.
crates/cairo-lang-lowering/src/precompute/mod.rs
line 75 at r4 (raw file):
}; pub struct CacheLoadingContext<'db> {
doc everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 19 files at r1, 1 of 2 files at r4.
Reviewable status: 16 of 19 files reviewed, 3 unresolved discussions (waiting on @TomerStarkware)
62eed75
to
c2f8267
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 9 files at r5, all commit messages.
Reviewable status: 11 of 19 files reviewed, 5 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-compiler/src/project.rs
line 88 at r5 (raw file):
db.set_crate_config( crate_id, Some(CrateConfiguration { root, settings: crate_settings.clone(), cached_file: None }),
Suggestion:
Some(CrateConfiguration { root, settings: crate_settings.clone(), cache_file: None }),
crates/cairo-lang-filesystem/src/db.rs
line 311 at r5 (raw file):
match crt.lookup_intern(db) { CrateLongId::Real { .. } => db.crate_configs().get(&crt).cloned(), CrateLongId::Virtual { name: _, file_id, settings, cahced_file: cached_file } => {
Suggestion:
CrateLongId::Virtual { name: _, file_id, settings, cache_file: cached_file } => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 11 of 19 files reviewed, 7 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/precompute/mod.rs
line 1 at r4 (raw file):
Previously, orizi wrote…
rename precompute to cache here as well.
the structure and the context is cache
.
the specific ids are cached
.
crates/cairo-lang-lowering/src/db.rs
line 71 at r5 (raw file):
) -> Maybe<Arc<MultiLowering>>; fn load_cached_multi_lowerings(
doc
crates/cairo-lang-lowering/src/db.rs
line 408 at r5 (raw file):
Ok(Arc::new(multi_lowering)) } fn load_cached_multi_lowerings(
Suggestion:
}
fn load_cached_multi_lowerings(
crates/cairo-lang-lowering/src/lib.rs
line 6 at r5 (raw file):
pub mod add_withdraw_gas; pub mod borrow_check; pub mod cached;
Suggestion:
pub mod cache;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 9 files at r5.
Reviewable status: 16 of 19 files reviewed, 9 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-semantic/src/test_utils.rs
line 134 at r5 (raw file):
content: &str, crate_settings: Option<&str>, cahced_file: Option<BlobId>,
Suggestion:
cache_file: Option<BlobId>,
crates/cairo-lang-lowering/src/cached/test_data/precompute
line 1 at r5 (raw file):
//! > Basic borrow checking valid.
fix test name.
probably change to a non-very specific test.
c2f8267
to
8105976
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 16 of 19 files reviewed, 9 unresolved discussions (waiting on @orizi)
crates/cairo-lang-lowering/src/db.rs
line 71 at r5 (raw file):
Previously, orizi wrote…
doc
Done.
crates/cairo-lang-lowering/src/cached/test_data/precompute
line 1 at r5 (raw file):
Previously, orizi wrote…
fix test name.
probably change to a non-very specific test.
Done.
crates/cairo-lang-lowering/src/precompute/mod.rs
line 1 at r4 (raw file):
Previously, orizi wrote…
rename precompute to cache here as well.
Done.
crates/cairo-lang-lowering/src/lib.rs
line 6 at r5 (raw file):
pub mod add_withdraw_gas; pub mod borrow_check; pub mod cached;
Done.
crates/cairo-lang-filesystem/src/db.rs
line 311 at r5 (raw file):
match crt.lookup_intern(db) { CrateLongId::Real { .. } => db.crate_configs().get(&crt).cloned(), CrateLongId::Virtual { name: _, file_id, settings, cahced_file: cached_file } => {
Done.
crates/cairo-lang-lowering/src/db.rs
line 408 at r5 (raw file):
Ok(Arc::new(multi_lowering)) } fn load_cached_multi_lowerings(
Done.
crates/cairo-lang-compiler/src/project.rs
line 88 at r5 (raw file):
db.set_crate_config( crate_id, Some(CrateConfiguration { root, settings: crate_settings.clone(), cached_file: None }),
Done.
crates/cairo-lang-semantic/src/test_utils.rs
line 134 at r5 (raw file):
content: &str, crate_settings: Option<&str>, cahced_file: Option<BlobId>,
Done.
crates/cairo-lang-lowering/src/db.rs
line 421 at r4 (raw file):
Vec<(DefsFunctionWithBodyIdCached, MultiLoweringCached)>, ) = bincode::deserialize(&content).unwrap_or_default(); let mut ctx = CacheLoadingContext::new(db, lookups, semantic_lookups, self_crate_id);
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 10 of 10 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/db.rs
line 75 at r6 (raw file):
&self, self_crate_id: cairo_lang_filesystem::ids::CrateId, ) -> Option<Arc<OrderedHashMap<defs::ids::FunctionWithBodyId, MultiLowering>>>;
Suggestion:
/// Returns a mapping from function ids to their multi-lowerings for the given loaded from a cache for the given crate.
fn cached_multi_lowerings(
&self,
crate_id: cairo_lang_filesystem::ids::CrateId,
) -> Option<Arc<OrderedHashMap<defs::ids::FunctionWithBodyId, MultiLowering>>>;
8105976
to
7ef6b57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 16 of 22 files reviewed, 1 unresolved discussion (waiting on @orizi)
crates/cairo-lang-lowering/src/precompute/mod.rs
line 75 at r4 (raw file):
Previously, orizi wrote…
doc everywhere.
Done.
crates/cairo-lang-lowering/src/db.rs
line 75 at r6 (raw file):
&self, self_crate_id: cairo_lang_filesystem::ids::CrateId, ) -> Option<Arc<OrderedHashMap<defs::ids::FunctionWithBodyId, MultiLowering>>>;
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r7, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/db.rs
line 75 at r6 (raw file):
Previously, TomerStarkware wrote…
Done.
remove the word load
from the query.
crates/cairo-lang-lowering/src/cache/mod.rs
line 77 at r7 (raw file):
/// Context for loading cache into the database. pub struct CacheLoadingContext<'db> { pub variables_id: Vec<VariableId>,
doc fields and group them better.
6f7ff12
to
15a3e9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 20 of 25 files reviewed, 2 unresolved discussions (waiting on @orizi)
crates/cairo-lang-lowering/src/db.rs
line 75 at r6 (raw file):
Previously, orizi wrote…
remove the word
load
from the query.
Done.
crates/cairo-lang-lowering/src/cache/mod.rs
line 77 at r7 (raw file):
Previously, orizi wrote…
doc fields and group them better.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r8, 4 of 4 files at r9, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/cache/mod.rs
line 77 at r8 (raw file):
/// Context for loading cache into the database. pub struct CacheLoadingContext<'db> { // The variable ids of the flat lowered that is currently being loaded.
Suggestion:
/// The variable ids of the flat lowered that is currently being loaded.
15a3e9f
to
150965a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi)
crates/cairo-lang-lowering/src/cache/mod.rs
line 77 at r8 (raw file):
/// Context for loading cache into the database. pub struct CacheLoadingContext<'db> { // The variable ids of the flat lowered that is currently being loaded.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r10, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/db.rs
line 438 at r10 (raw file):
.collect::<OrderedHashMap<_, _>>() .into(), )
move this into cache.rs
and have only 2 pub
functions there.
Code quote:
let (lookups, semantic_lookups, lowerings): (
CacheLookups,
SemanticCacheLookups,
Vec<(DefsFunctionWithBodyIdCached, MultiLoweringCached)>,
) = bincode::deserialize(&content).unwrap_or_default();
// TODO(tomer): Fail on version, cfg, and dependencies mismatch.
let mut ctx = CacheLoadingContext::new(db, lookups, semantic_lookups, crate_id);
Some(
lowerings
.into_iter()
.map(|(function_id, lowering)| {
let function_id = function_id.embed(&mut ctx.semantic_ctx);
let lowering = lowering.embed(&mut ctx);
(function_id, lowering)
})
.collect::<OrderedHashMap<_, _>>()
.into(),
)
150965a
to
5c9a238
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 20 of 25 files reviewed, 1 unresolved discussion (waiting on @orizi)
crates/cairo-lang-lowering/src/db.rs
line 438 at r10 (raw file):
Previously, orizi wrote…
move this into
cache.rs
and have only 2pub
functions there.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r11, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/db.rs
line 412 at r11 (raw file):
crate_id: cairo_lang_filesystem::ids::CrateId, ) -> Option<Arc<OrderedHashMap<defs::ids::FunctionWithBodyId, MultiLowering>>> { load_cache(db, crate_id)
bad name - not specific enough.
crates/cairo-lang-lowering/src/cache/mod.rs
line 76 at r11 (raw file):
}; pub fn load_cache<'de>(
doc
5c9a238
to
e05e81c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 18 of 25 files reviewed, 2 unresolved discussions (waiting on @orizi)
crates/cairo-lang-lowering/src/db.rs
line 412 at r11 (raw file):
Previously, orizi wrote…
bad name - not specific enough.
Done.
crates/cairo-lang-lowering/src/cache/mod.rs
line 76 at r11 (raw file):
Previously, orizi wrote…
doc
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 7 files at r12, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/db.rs
line 412 at r12 (raw file):
crate_id: cairo_lang_filesystem::ids::CrateId, ) -> Option<Arc<OrderedHashMap<defs::ids::FunctionWithBodyId, MultiLowering>>> { load_cached_crate(db, crate_id)
Suggestion:
oad_cached_crate_functions(db, crate_id)
crates/cairo-lang-lowering/src/cache/mod.rs
line 107 at r12 (raw file):
/// Cache the lowering of a crate. pub fn cache_crate(
Suggestion:
pub fn generate_crate_cache(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-lowering/src/cache/mod.rs
line 106 at r12 (raw file):
} /// Cache the lowering of a crate.
extended function doc a bit.
No description provided.