Skip to content

Commit

Permalink
Auto merge of #16107 - Veykril:rev-16101, r=Veykril
Browse files Browse the repository at this point in the history
internal: Partially revert #16101

#16101 has severe perf regressions unfortunately, so this reverts the part that fixed the issues for now.
  • Loading branch information
bors committed Dec 12, 2023
2 parents 5d7453c + 7cc6b0f commit b3af191
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
15 changes: 5 additions & 10 deletions crates/hir-def/src/import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,22 +413,17 @@ pub fn search_dependencies(
while let Some((_, indexed_values)) = stream.next() {
for &IndexedValue { index, value } in indexed_values {
let import_map = &import_maps[index];
let importables = &import_map.importables[value as usize..];

// Find the first item in this group that has a matching assoc mode and slice the rest away
let Some(importable) =
importables.iter().position(|it| query.matches_assoc_mode(import_map.map[it].1))
else {
let importables @ [importable, ..] = &import_map.importables[value as usize..] else {
continue;
};
let importables @ [importable, ..] = &importables[importable..] else {
let &(ref importable_data, is_trait_assoc_item) = &import_map.map[importable];
if !query.matches_assoc_mode(is_trait_assoc_item) {
continue;
};
}

// Fetch all the known names of this importable item (to handle import aliases/renames)
common_importable_data_scratch.extend(
import_map.map[importable]
.0
importable_data
.iter()
.filter(|&info| query.import_matches(info, true))
// Name shared by the importable items in this group.
Expand Down
3 changes: 2 additions & 1 deletion crates/ide-db/src/items_locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ pub fn items_with_name<'a>(
| NameToImport::Exact(exact_name, case_sensitive) => {
let mut local_query = symbol_index::Query::new(exact_name.clone());
let mut external_query =
import_map::Query::new(exact_name).assoc_search_mode(assoc_item_search);
// import_map::Query::new(exact_name).assoc_search_mode(assoc_item_search);
import_map::Query::new(exact_name);
if prefix {
local_query.prefix();
external_query = external_query.prefix();
Expand Down
44 changes: 40 additions & 4 deletions crates/rust-analyzer/src/integrated_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,46 @@ fn integrated_completion_benchmark() {
vfs.file_id(&path).unwrap_or_else(|| panic!("can't find virtual file for {path}"))
};

// kick off parsing and index population

let completion_offset = {
let _it = stdx::timeit("change");
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
let completion_offset =
patch(&mut text, "db.struct_data(self.id)", "sel;\ndb.struct_data(self.id)")
+ "sel".len();
let mut change = Change::new();
change.change_file(file_id, Some(Arc::from(text)));
host.apply_change(change);
completion_offset
};

{
let _it = stdx::timeit("initial");
let _span = profile::cpu_span();
let analysis = host.analysis();
analysis.highlight_as_html(file_id, false).unwrap();
let config = CompletionConfig {
enable_postfix_completions: true,
enable_imports_on_the_fly: true,
enable_self_on_the_fly: true,
enable_private_editable: true,
full_function_signatures: false,
callable: Some(CallableSnippets::FillArguments),
snippet_cap: SnippetCap::new(true),
insert_use: InsertUseConfig {
granularity: ImportGranularity::Crate,
prefix_kind: hir::PrefixKind::ByCrate,
enforce_granularity: true,
group: true,
skip_glob_imports: true,
},
snippets: Vec::new(),
prefer_no_std: false,
prefer_prelude: true,
limit: None,
};
let position =
FilePosition { file_id, offset: TextSize::try_from(completion_offset).unwrap() };
analysis.completions(&config, position, None).unwrap();
}

profile::init_from("*>5");
Expand All @@ -122,8 +158,8 @@ fn integrated_completion_benchmark() {
let _it = stdx::timeit("change");
let mut text = host.analysis().file_text(file_id).unwrap().to_string();
let completion_offset =
patch(&mut text, "db.struct_data(self.id)", "sel;\ndb.struct_data(self.id)")
+ "sel".len();
patch(&mut text, "sel;\ndb.struct_data(self.id)", ";sel;\ndb.struct_data(self.id)")
+ ";sel".len();
let mut change = Change::new();
change.change_file(file_id, Some(Arc::from(text)));
host.apply_change(change);
Expand Down

0 comments on commit b3af191

Please sign in to comment.