Commit message (Collapse) | Author | Age | Files | Lines | |
---|---|---|---|---|---|
* | feature: massively improve performance for large files | Aleksey Kladov | 2021-06-21 | 1 | -1/+1 |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This story begins in #8384, where we added a smart test for our syntax highting, which run the algorithm on synthetic files of varying length in order to guesstimate if the complexity is O(N^2) or O(N)-ish. The test turned out to be pretty effective, and flagged #9031 as a change that makes syntax highlighting accidentally quadratic. There was much rejoicing, for the time being. Then, lnicola asked an ominous question[1]: "Are we sure that the time is linear right now?" Of course it turned out that our sophisticated non-linearity detector *was* broken, and that our syntax highlighting *was* quadratic. Investigating that, many brave hearts dug deeper and deeper into the guts of rust-analyzer, only to get lost in a maze of traits delegating to traits delegating to macros. Eventually, matklad managed to peel off all layers of abstraction one by one, until almost nothing was left. In fact, the issue was discovered in the very foundation of the rust-analyzer -- in the syntax trees. Worse, it was not a new problem, but rather a well-know, well-understood and event (almost) well-fixed (!) performance bug. The problem lies within `SyntaxNodePtr` type -- a light-weight "address" of a node in a syntax tree [3]. Such pointers are used by rust-analyzer all other the place to record relationships between IR nodes and the original syntax. Internally, the pointer to a syntax node is represented by node's range. To "dereference" the pointer, you traverse the syntax tree from the root, looking for the node with the right range. The inner loop of this search is finding a node's child whose range contains the specified range. This inner loop was implemented by naive linear search over all the children. For wide trees, dereferencing a single `SyntaxNodePtr` was linear. The problem with wide trees though is that they contain a lot of nodes! And dereferencing pointers to all the nodes is quadratic in the size of the file! The solution to this problem is to speed up the children search -- rather than doing a linear lookup, we can use binary search to locate the child with the desired interval. Doing this optimization was one of the motivations (or rather, side effects) of #6857. That's why `rowan` grew the useful `child_or_token_at_range` method which does exactly this binary search. But looks like we've never actually switch to this method? Oups. Lesson learned: do not leave broken windows in the fundamental infra. Otherwise, you'll have to repeatedly re-investigate the issue, by digging from the top of the Everest down to the foundation! [1]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/.60syntax_highlighting_not_quadratic.60.20failure/near/240811501 [2]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Syntax.20highlighting.20is.20quadratic [3]: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Syntax.20highlighting.20is.20quadratic/near/243412392 | ||||
* | Don't insert imports outside of cfg attributed items | Lukas Wirth | 2021-06-18 | 1 | -1/+7 |
| | |||||
* | Allow to disable import insertion on single path glob imports | Lukas Wirth | 2021-06-18 | 1 | -0/+9 |
| | |||||
* | Fix parser tests for 1.53 | Lukas Wirth | 2021-06-17 | 54 | -198/+198 |
| | |||||
* | Create modules in correct directory for nested modules in move_module assist | Lukas Wirth | 2021-06-17 | 1 | -0/+8 |
| | |||||
* | Highlight unsafe trait refs as unsafe only in impl blocks and definitions | Lukas Wirth | 2021-06-15 | 1 | -0/+9 |
| | |||||
* | internal: enforce no #[ignore] and no #[should_panic] | Aleksey Kladov | 2021-06-15 | 2 | -2/+2 |
| | |||||
* | clippy::manual_str_repeat | Maan2003 | 2021-06-13 | 1 | -1/+1 |
| | |||||
* | clippy::redudant_borrow | Maan2003 | 2021-06-13 | 6 | -10/+10 |
| | |||||
* | internal: cross-crate cov-marks | Aleksey Kladov | 2021-06-12 | 1 | -1/+1 |
| | |||||
* | Update ungrammar | Jonas Schievink | 2021-06-11 | 35 | -649/+769 |
| | |||||
* | Fix edge case for ImportGranularity guessing | Lukas Wirth | 2021-06-08 | 1 | -1/+4 |
| | |||||
* | Apply more clippy suggestions and update generated | Clemens Wasser | 2021-06-03 | 2 | -5/+5 |
| | |||||
* | Account for generics in extract_struct_from_enum_variant | Lukas Wirth | 2021-06-02 | 1 | -3/+2 |
| | |||||
* | minor: remove debug print | Aleksey Kladov | 2021-05-31 | 1 | -1/+0 |
| | |||||
* | Merge #9062 | bors[bot] | 2021-05-30 | 1 | -1/+1 |
|\ | | | | | | | | | | | | | | | | | | | 9062: internal: Bump deps r=lnicola a=lnicola Fixes #9061 bors r+ Co-authored-by: Laurențiu Nicola <[email protected]> | ||||
| * | Bump deps | Laurențiu Nicola | 2021-05-30 | 1 | -1/+1 |
| | | |||||
* | | Attribute completion is context aware | Lukas Wirth | 2021-05-27 | 1 | -0/+7 |
| | | |||||
* | | generate match arms with todo!() as placeholder body | Domantas Jadenkus | 2021-05-24 | 1 | -6/+15 |
|/ | |||||
* | Bump rustc_lexer | Laurențiu Nicola | 2021-05-24 | 1 | -1/+1 |
| | |||||
* | Add more docs | Aleksey Kladov | 2021-05-22 | 6 | -6/+17 |
| | |||||
* | internal: replace AstTransformer with mutable syntax trees | Aleksey Kladov | 2021-05-22 | 4 | -54/+19 |
| | |||||
* | Don't compare ast::Visibility by stringifying | Lukas Tobias Wirth | 2021-05-20 | 1 | -0/+23 |
| | |||||
* | fix: don't add extra whitespace around fields | Aleksey Kladov | 2021-05-17 | 1 | -0/+4 |
| | | | | closes #8785 | ||||
* | internal: use mutable syntax trees when filling fields | Aleksey Kladov | 2021-05-16 | 2 | -98/+42 |
| | |||||
* | internal: use mutable trees when filling match arms | Aleksey Kladov | 2021-05-16 | 2 | -126/+69 |
| | |||||
* | Merge #8813 | bors[bot] | 2021-05-16 | 1 | -20/+61 |
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 8813: Get some more array lengths! r=lf- a=lf- This is built on #8799 and thus contains its changes. I'll rebase it onto master when that one gets merged. It adds support for r-a understanding the length of: * `let a: [u8; 2] = ...` * `let a = b"aaa"` * `let a = [0u8; 4]` I have added support for getting the values of byte strings, which was not previously there. I am least confident in the correctness of this part and it probably needs some more tests, as we currently have only one test that exercised that part (!). Fixes #2922. Co-authored-by: Jade <[email protected]> | ||||
| * | Support length for ByteStrings | Jade | 2021-05-13 | 1 | -20/+61 |
| | | | | | | | | I am not confident that my added byte string parsing is right. | ||||
* | | Attach comments to ast::Impl | Lukas Wirth | 2021-05-15 | 2 | -5/+5 |
| | | |||||
* | | internal: use more mutable APIs | Aleksey Kladov | 2021-05-14 | 2 | -35/+17 |
| | | |||||
* | | internal: rewrite assoc item manipulaion to use mutable trees | Aleksey Kladov | 2021-05-14 | 3 | -153/+72 |
| | | |||||
* | | internal: remove SyntaxRewriter | Aleksey Kladov | 2021-05-14 | 2 | -153/+4 |
| | | |||||
* | | internal: remove more of the SyntaxRewriter | Aleksey Kladov | 2021-05-14 | 1 | -29/+31 |
| | | |||||
* | | internal: remove one more immutable tree | Aleksey Kladov | 2021-05-14 | 4 | -40/+13 |
| | | |||||
* | | Cleanup imports | Aleksey Kladov | 2021-05-13 | 1 | -4/+3 |
|/ | |||||
* | simplify | Aleksey Kladov | 2021-05-10 | 1 | -0/+3 |
| | |||||
* | internal: introduce `ast::make::ext` module with common shortcuts | Aleksey Kladov | 2021-05-09 | 1 | -43/+52 |
| | | | | | | | | | | There's a tension between keeping a well-architectured minimal orthogonal set of constructs, and providing convenience functions. Relieve this pressure by introducing an dedicated module for non-orthogonal shortcuts. This is inspired by the django.shortcuts module which serves a similar purpose architecturally. | ||||
* | internal: fix make API | Aleksey Kladov | 2021-05-09 | 1 | -8/+31 |
| | |||||
* | internal: rewrite **Repalce impl Trait** assist to mutable syntax trees | Aleksey Kladov | 2021-05-09 | 1 | -12/+7 |
| | |||||
* | cleanups | Aleksey Kladov | 2021-05-09 | 1 | -2/+2 |
| | |||||
* | minor: remove dead code | Aleksey Kladov | 2021-05-08 | 1 | -11/+1 |
| | |||||
* | internal: pull_assignment_up uses mutable trees | Aleksey Kladov | 2021-05-08 | 1 | -0/+3 |
| | |||||
* | dead code | Aleksey Kladov | 2021-05-08 | 1 | -121/+1 |
| | |||||
* | internal: remove one more syntax rewriter | Aleksey Kladov | 2021-05-08 | 1 | -1/+4 |
| | |||||
* | fix: use raw idents in `make::name{_ref}` with keywords | Jonas Schievink | 2021-05-07 | 1 | -2/+12 |
| | |||||
* | Hide implementation details of TokenText | Dawer | 2021-05-06 | 2 | -8/+20 |
| | |||||
* | Clean up | Dawer | 2021-05-06 | 1 | -15/+2 |
| | |||||
* | Borrow text from nodes of immutable syntax trees | Dawer | 2021-05-06 | 2 | -25/+49 |
| | |||||
* | Adapt to a new rowan borrowing node API. | Dawer | 2021-05-06 | 2 | -2/+2 |
| | |||||
* | Update to rowan 0.13.0-pre.5 | Dawer | 2021-05-06 | 1 | -1/+1 |
| |