egraphs-good / egglog

egraphs + datalog!
https://egraphs-good.github.io/egglog/
MIT License
458 stars 54 forks source link

Compile time regression #468

Open DaniPopes opened 1 week ago

DaniPopes commented 1 week ago

Building a simple program takes significantly longer on the latest git versions than on crates.io

fn main() {
    for path in std::env::args().skip(1) {
        let path = std::path::Path::new(&path);
        let contents = std::fs::read_to_string(&path).unwrap();
        let filename = path.file_stem().unwrap().to_str().unwrap();
        egglog::EGraph::default()
            .parse_and_run_program(Some(filename.to_owned()), &contents)
            .unwrap();
    }
}

Clean builds:

I've bisected it to https://github.com/egraphs-good/egglog/commit/4c280616db0b1bf2bb850aab0075c8f83acd5f33: cargo build --bin egglog in this repository goes from 6s to 45s on that commit.

I could reproduce this on 1.79, 1.82 and 1.84.0-nightly (fbab78289 2024-11-04)

Output of -Ztime-passes:

time:   0.008; rss:  106MB ->  113MB (   +7MB)  parse_crate
time:   0.000; rss:  113MB ->  114MB (   +1MB)  setup_global_ctxt
time:   0.088; rss:  114MB ->  184MB (  +70MB)  expand_crate
time:   0.088; rss:  114MB ->  184MB (  +70MB)  macro_expand_crate
time:   0.026; rss:  184MB ->  207MB (  +23MB)  late_resolve_crate
time:   0.035; rss:  184MB ->  207MB (  +23MB)  resolve_crate
time:   0.057; rss:  208MB ->  215MB (   +8MB)  unused_lib_feature_checking
time:   0.057; rss:  208MB ->  215MB (   +8MB)  looking_for_derive_registrar
time:   0.063; rss:  208MB ->  218MB (  +10MB)  misc_checking_1
time:   0.073; rss:  218MB ->  275MB (  +57MB)  coherence_checking
time:   0.195; rss:  218MB ->  337MB ( +118MB)  type_check_crate
time:   0.096; rss:  337MB ->  401MB (  +64MB)  MIR_borrow_checking
time:  38.326; rss:  401MB ->  401MB (   +1MB)  MIR_effect_checking
time:   0.027; rss:  401MB ->  401MB (   +0MB)  privacy_checking_modules
time:   0.035; rss:  401MB ->  401MB (   +0MB)  module_lints
time:   0.035; rss:  401MB ->  401MB (   +0MB)  lint_checking
time:   0.063; rss:  401MB ->  401MB (   +0MB)  misc_checking_3
time:   0.001; rss:  404MB ->  406MB (   +2MB)  monomorphization_collector_root_collections
time:   0.166; rss:  406MB ->  455MB (  +49MB)  monomorphization_collector_graph_walk
time:   0.057; rss:  457MB ->  469MB (  +12MB)  partition_and_assert_distinct_symbols
time:   0.263; rss:  401MB ->  477MB (  +76MB)  generate_crate_metadata
time:   0.000; rss:  484MB ->  484MB (   +0MB)  find_cgu_reuse
time:   0.154; rss:  484MB ->  603MB ( +120MB)  compile_first_CGU_batch
time:   1.188; rss:  484MB ->  708MB ( +224MB)  codegen_to_LLVM_IR
time:   1.205; rss:  477MB ->  708MB ( +231MB)  codegen_crate
time:   1.047; rss:  603MB ->  708MB ( +104MB)  LLVM_passes
time:   0.039; rss:  708MB ->  703MB (   -5MB)  encode_query_results
time:   0.042; rss:  708MB ->  703MB (   -5MB)  incr_comp_serialize_result_cache
time:   0.042; rss:  708MB ->  703MB (   -5MB)  incr_comp_persist_result_cache
time:   0.043; rss:  708MB ->  703MB (   -5MB)  serialize_dep_graph
time:   0.021; rss:  703MB ->  589MB ( -114MB)  free_global_ctxt
time:   0.085; rss:  578MB ->  581MB (   +3MB)  link_rlib
time:   0.087; rss:  578MB ->  581MB (   +3MB)  link_binary
time:   0.087; rss:  578MB ->  578MB (   +0MB)  link_crate
time:   0.091; rss:  589MB ->  578MB (  -11MB)  link
time:  40.517; rss:   41MB ->  189MB ( +148MB)  total
DaniPopes commented 1 week ago

Reported upstream: https://github.com/rust-lang/rust/issues/132991