rust-analyzer/crates/hir_expand/src
bors[bot] 9946def7e2
Merge #10877
10877: feat: make hightlighting linear r=matklad a=matklad

In https://youtu.be/qvIZZf5dmTE, we've noticed that AstIdMap does a
linear lookup when going from SyntaxNode to Id. This leads to
accidentally quadratic overall performance. Replace linear lookup with a
O(1) hashmap lookup.

Future work: don't duplicate `SyntaxNodePtr` in `AstIdMap` and switch to
"call site dependency injection" style storage (eg, store a
`HashSet<ErasedFileAstId>`).

See the explanation of the work here on YouTube :-)

As you can see from then benchmark results, this doesn't actually make analysis stats fastre. I am a bit mystified as to why this is happening to be honest. 

Baseline
```
Database loaded:     598.40ms, 304minstr, 118mb (metadata 390.57ms, 21minstr, 841kb; build 111.31ms, 8764kinstr, -214kb)
  crates: 39, mods: 824, decls: 18647, fns: 13910
Item Collection:     9.70s, 75ginstr, 377mb
  exprs: 382426, ??ty: 387 (0%), ?ty: 285 (0%), !ty: 145
Inference:           43.16s, 342ginstr, 641mb
Total:               52.86s, 417ginstr, 1018mb
```

This PR:
```
Database loaded:     626.34ms, 304minstr, 118mb (metadata 416.26ms, 21minstr, 841kb; build 113.67ms, 8750kinstr, -209kb)
  crates: 39, mods: 824, decls: 18647, fns: 13910
Item Collection:     10.16s, 75ginstr, 389mb
  exprs: 382426, ??ty: 387 (0%), ?ty: 285 (0%), !ty: 145
Inference:           44.51s, 342ginstr, 644mb
Total:               54.67s, 417ginstr, 1034mb
```

I think we probably should merge the first commit here, but not the second. 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-12-11 14:49:29 +00:00
..
ast_id_map.rs more frugal map 2021-12-11 17:49:09 +03:00
builtin_attr_macro.rs Check for derive attributes by item path, not derive identifier 2021-11-17 20:46:57 +01:00
builtin_derive_macro.rs Rename intern_macro -> intern_macro_call 2021-11-14 16:25:47 +01:00
builtin_fn_macro.rs Fix concat! with captured expression 2021-12-10 15:17:31 +01:00
db.rs Rename intern_macro -> intern_macro_call 2021-11-14 16:25:47 +01:00
eager.rs Rename intern_macro -> intern_macro_call 2021-11-14 16:25:47 +01:00
hygiene.rs Rename intern_macro -> intern_macro_call 2021-11-14 16:25:47 +01:00
lib.rs Document token up/down mapping 2021-11-22 17:58:36 +01:00
name.rs Use known names instead of string literals 2021-12-09 18:13:15 +01:00
proc_macro.rs Don't discard attributed items when a proc-macro unexpectedly fails to expand 2021-10-29 15:10:44 +02:00
quote.rs Escape characters in builtin macros correctly 2021-05-09 19:57:29 +08:00