Skip to content

Conversation

@matklad
Copy link
Contributor

@matklad matklad commented May 4, 2021

bors r+
🤖

@matklad
Copy link
Contributor Author

matklad commented May 4, 2021

$ cargo test --release --package rust-analyzer --lib -- integrated_benchmarks::integrated_completion_benchmark --exact --nocapture
running 1 test
workspace loading: 329.92ms
initial: 6.87s
change: 33.93µs
cpu profiling is disabled, uncomment `default = [ "cpu_profiler" ]` in Cargo.toml to enable.
   23ms - SourceBinder::to_module_def
       23ms - crate_def_map:wait
           16ms - item_tree_query (197 calls)
            0ms - parse_macro_expansion (1 calls)
            7ms - ???
   20ms - descend_into_macros
       20ms - Semantics::analyze_impl
           15ms - infer:wait @ name
               15ms - infer_query
                   15ms - deref
                       15ms - deref_by_trait
                           15ms - trait_solve::wait
                                5ms - impl_data_query (272 calls)
                                9ms - ???
                    0ms - crate_def_map:wait (36 calls)
                    0ms - deref (5 calls)
                    0ms - resolve_obligations_as_possible (3 calls)
                    0ms - trait_solve::wait (5 calls)
            0ms - SourceBinder::to_module_def (1 calls)
            0ms - body_with_source_map_query (1 calls)
            0ms - crate_def_map:wait (2 calls)
            0ms - impl_data_query (1 calls)
            1ms - macro_expand (108 calls)
            1ms - parse_macro_expansion (152 calls)
   47ms - import_on_the_fly @ sel
       28ms - import_assets::search_for_imports
           28ms - import_assets::search_for
               28ms - import_assets::path_applicable_imports
                   23ms - items_with_name @ Name: sel, crate: Exclude, assoc items: Some("hir"), limit: Some(40)
                       23ms - find_items
                           20ms - search_dependencies @ Query { query: "sel", lowercased: "sel", name_only: true, assoc_items_only: false, search_mode: Fuzzy, case_sensitive: false, limit: 40, exclude_import_kinds: {AssociatedItem} }
                               19ms - import_map_query (17 calls)
                            0ms - crate_def_map:wait (1 calls)
                    2ms - find_path_prefixed (43 calls)
                    1ms - get_name_definition (40 calls)
                0ms - import_assets::scope_definitions (1 calls)
        9ms - render_resolution
            9ms - render_fn
                9ms - parse_query @ FileId(2993)
                0ms - crate_def_map:wait (6 calls)
                0ms - generic_params_query (1 calls)
                0ms - item::Builder::build (1 calls)
        0ms - crate_def_map:wait (1 calls)
        9ms - render_resolution (38 calls)
unqualified path completion: 137.42ms
change: 41.78µs
cpu profiling is disabled, uncomment `default = [ "cpu_profiler" ]` in Cargo.toml to enable.
   21ms - SourceBinder::to_module_def
       21ms - crate_def_map:wait
           13ms - item_tree_query (197 calls)
            0ms - macro_expand (34 calls)
            0ms - parse_macro_expansion (43 calls)
            7ms - ???
   19ms - descend_into_macros
       19ms - Semantics::analyze_impl
           15ms - infer:wait @ name
               15ms - infer_query
                   14ms - deref
                       14ms - deref_by_trait
                           14ms - trait_solve::wait
                                5ms - impl_data_query (272 calls)
                                9ms - ???
                    0ms - crate_def_map:wait (35 calls)
                    0ms - deref (6 calls)
                    0ms - resolve_obligations_as_possible (3 calls)
                    0ms - trait_solve::wait (5 calls)
            0ms - SourceBinder::to_module_def (1 calls)
            0ms - body_with_source_map_query (1 calls)
            0ms - crate_def_map:wait (2 calls)
            0ms - impl_data_query (1 calls)
            1ms - macro_expand (99 calls)
            1ms - parse_macro_expansion (148 calls)
    8ms - import_on_the_fly @ 
        8ms - import_assets::search_for_imports
            8ms - import_assets::search_for
                7ms - import_assets::trait_applicable_items
                    0ms - crate_def_map:wait (155 calls)
                    0ms - deref (2 calls)
                    0ms - generic_params_query (72 calls)
                    1ms - get_name_definition (40 calls)
                    4ms - items_with_name (1 calls)
                    0ms - trait_solve::wait (44 calls)
                0ms - import_assets::scope_definitions (1 calls)
        0ms - Semantics::analyze_impl (1 calls)
dot completion: 71.34ms
test integrated_benchmarks::integrated_completion_benchmark ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 40 filtered out; finished in 7.68s

@matklad
Copy link
Contributor Author

matklad commented May 4, 2021

Things that jump at me -- there should be no item_tree or impl_data queries in there.

bors bot added a commit that referenced this pull request May 4, 2021
8720: internal: add integrated completion benchmark r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
#[test]
fn integrated_highlighting_benchmark() {
// Don't run slow benchmark by default
if true {
Copy link
Member

Choose a reason for hiding this comment

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

Wait, how does this work?

Copy link
Contributor Author

@matklad matklad May 4, 2021

Choose a reason for hiding this comment

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

I uncomment this manually when I want to capture profile :-)

Copy link
Member

Choose a reason for hiding this comment

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

Might be worth checking for an env variable instead.

@matklad
Copy link
Contributor Author

matklad commented May 4, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented May 4, 2021

Canceled.

@bors
Copy link
Contributor

bors bot commented May 4, 2021

@bors bors bot merged commit a231da9 into rust-lang:master May 4, 2021
@SomeoneToIgnore
Copy link
Contributor

47ms - import_on_the_fly @ sel
8ms - import_on_the_fly @

I've expected complete opposite results, IMO we should exaggerate the latter by calling it on some struct with multiple applicable trait impls.

@matklad matklad deleted the b branch May 4, 2021 12:30
@matklad
Copy link
Contributor Author

matklad commented May 4, 2021

Filed #8721. I am exctremely satisfied that it took like 15 minutes to find the first WTF behavior after having the benchmark :3

@SomeoneToIgnore this type (hir::Struct) has a fair number of impls: HasSource, HasAttrs, HirDisplay, a bunch of derived ones. I do expect "plain" lookups to be costlier, as they look at all the symbols, without any kind of type filtering at all.

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