Stream: t-compiler/rust-analyzer

Topic: Fixing #3188


Jonas Schievink [he/him] (Dec 19 2020 at 19:18, on Zulip):

Looks like I'm finally working towards an effective solution for https://github.com/rust-analyzer/rust-analyzer/issues/3188:

        16069ms - crate_def_map_query @ salsa
               13ms - crate_def_map:wait (24610 calls)
             4816ms - item_tree_query (8202 calls)
            10773ms - macro_expand (8201 calls)
                0ms - rewrite (1 calls)
              465ms - ???

I'm not sure why this is so slow now, I might have accidentally implemented procedural attribute macros

Jonas Schievink [he/him] (Dec 19 2020 at 19:22, on Zulip):

[ERROR hir_def::nameres::collector] name resolution is stuck

Clearly something broke :)

matklad (Dec 19 2020 at 19:40, on Zulip):

Heh, new features which regress performance considerably are my favorite!

matklad (Dec 19 2020 at 19:40, on Zulip):

First you an tweet about new feature, and next week you can tween about perfomrnace improving 2x!

Jonas Schievink [he/him] (Dec 19 2020 at 19:43, on Zulip):
thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow

huh, looks like the overflow guards in name resolution are not enough

Jonas Schievink [he/him] (Dec 19 2020 at 19:47, on Zulip):
38480ms - crate_def_map_query @ hir_def
    15767ms - crate_def_map:wait
        124ms - DefCollector::resolve_macros @ 21 macros, 748 attrs
            0ms - crate_def_map:wait (1517 calls)
            33ms - item_tree_query (766 calls)
            73ms - macro_expand (766 calls)
            0ms - rewrite (2 calls)
    18502ms - DefCollector::resolve_macros (8191 calls)

odd profiler output, it's only including the .detail() once

Jonas Schievink [he/him] (Dec 19 2020 at 19:48, on Zulip):

yes, apparently, for some crate, we're now expanding 748 attribute macros

Jonas Schievink [he/him] (Dec 19 2020 at 19:52, on Zulip):

Practically all it does is crash the proc macro server, looks like we'll have to come up with a more stable solution for that before this work properly...

matklad (Dec 19 2020 at 19:53, on Zulip):

@Jonas Schievink reminder that this is a thing: https://github.com/matklad/backtrace-on-stack-overflow

Jonas Schievink [he/him] (Dec 19 2020 at 19:55, on Zulip):

oh well this explains the "name resolution is stuck" error, salsa runs right into the iteration limit

        15699ms - crate_def_map_query @ salsa
            15695ms - DefCollector::resolve_macros (8192 calls)
Last update: Jul 27 2021 at 21:30UTC