rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Update rustc-hash to version 2

Open Noratrieb opened this issue 1 year ago • 5 comments

This brings in the new optimized algorithm that was shown to have small performance benefits for rustc. I haven't run the rust-analyzer benchmarks.

See https://github.com/rust-lang/rustc-hash/pull/37.

Noratrieb avatar Aug 24 '24 22:08 Noratrieb

oh lord, it looks like something relies on the iteration order or something like that :3.

Noratrieb avatar Aug 24 '24 22:08 Noratrieb

Yup, the iteration here calls a mutating callback and the state there seems to be iteration dependent (sorting the iterator by key causes the same issue on master) https://github.com/rust-lang/rust-analyzer/blob/1271dff610719930bb2cf20206057e57201d2528/crates/hir-ty/src/lib.rs#L249

Veykril avatar Aug 25 '24 07:08 Veykril

The funny thing is, that test apparently should succeed given rustc is fine with it?

        pub enum TagTree {
            Leaf,
            Choice(&'static [TagTree]),
        }
        const GOAL: TagTree = {
            const TAG_TREE: TagTree = TagTree::Choice(&[
                {
                    const VARIANT_TAG_TREE: TagTree = TagTree::Choice(
                        &[
                            TagTree::Leaf,
                        ],
                    );
                    VARIANT_TAG_TREE
                },
            ]);
            TAG_TREE
        };
        ```
        compiles just fine, yet the test errors on master

Veykril avatar Aug 25 '24 07:08 Veykril

Naively I'd say, lets replace the FxHashMap at https://github.com/rust-lang/rust-analyzer/blob/191949eabe87ce71cc120e56af7b791da011a9c8/crates/hir-ty/src/lib.rs#L199 with an FxIndexMap and change the expected test output to success (if that change makes it succeed)

Veykril avatar Aug 25 '24 07:08 Veykril

The test looks strange. I guess it meant to do recursive constants, something like this:

pub enum TagTree {
    Leaf,
    Choice(&'static [TagTree]),
}
const GOAL: TagTree = {
    const TAG_TREE: TagTree = TagTree::Choice(&[
        {
            const VARIANT_TAG_TREE: TagTree = TagTree::Choice(
                &[
                    TAG_TREE,
                ],
            );
            VARIANT_TAG_TREE
        },
    ]);
    TAG_TREE
};

The failure of the original test clearly is a bug. It should work with any order of execution, and sorting or using an stable iteration order does not fix the underlying problem. I would suggest changing the test to use an actual recursive constant like the code above, and opening an issue for that bug for further investigation.

HKalbasi avatar Aug 25 '24 11:08 HKalbasi

@bors r+

Veykril avatar Sep 04 '24 09:09 Veykril

:pushpin: Commit 6a78851cb825581c5adb18017a1b46aeaa7d50cb has been approved by Veykril

It is now in the queue for this repository.

bors avatar Sep 04 '24 09:09 bors

:hourglass: Testing commit 6a78851cb825581c5adb18017a1b46aeaa7d50cb with merge aee8b45e4d2fb67b0b2458dfea32fcc329164fa0...

bors avatar Sep 04 '24 09:09 bors

:broken_heart: Test failed - checks-actions

bors avatar Sep 04 '24 09:09 bors

:umbrella: The latest upstream changes (presumably #18151) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Sep 20 '24 07:09 bors

Okay let's see what breaks @bors r+

Veykril avatar Oct 21 '24 09:10 Veykril

:pushpin: Commit 8be3b80ee1258307a90d4086ef904f6388090c0b has been approved by Veykril

It is now in the queue for this repository.

bors avatar Oct 21 '24 09:10 bors

:hourglass: Testing commit 8be3b80ee1258307a90d4086ef904f6388090c0b with merge 102a3b1ce4008bd23a8a54d55f948128e78c237f...

bors avatar Oct 21 '24 09:10 bors

:broken_heart: Test failed - checks-actions

bors avatar Oct 21 '24 09:10 bors

@bors r+

Veykril avatar Oct 21 '24 09:10 Veykril

:pushpin: Commit 02e189dcb54b17f607a8f66f79e0932e82a0a859 has been approved by Veykril

It is now in the queue for this repository.

bors avatar Oct 21 '24 09:10 bors

:hourglass: Testing commit 02e189dcb54b17f607a8f66f79e0932e82a0a859 with merge fb832ff2ba338105dda1c8172f89d580cb0a570f...

bors avatar Oct 21 '24 09:10 bors

:sunny: Test successful - checks-actions Approved by: Veykril Pushing fb832ff2ba338105dda1c8172f89d580cb0a570f to master...

bors avatar Oct 21 '24 10:10 bors

nice!

Noratrieb avatar Oct 21 '24 12:10 Noratrieb