zed icon indicating copy to clipboard operation
zed copied to clipboard

Slow tab switching (Zed 0.119.17)

Open Labrium opened this issue 1 year ago • 7 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

When simply switching tabs, Zed sometimes does switch instantly like 0.188.1, but most of the time freezes for almost a full second before actually switching to the new tab.

Environment

Zed: v0.119.17 (Zed) OS: macOS 10.15.7 Memory: 16 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

Zed.log

Labrium avatar Jan 24 '24 19:01 Labrium

Hey @Labrium, thanks for the report! Do you have Instruments.app installed and, if so, would you mind capturing a CPU Profile while you move across tabs and Zed freezes? We are unable to reproduce this on our machines, so this would be huge to help diagnose what the problem is. Thank you! 🙏

as-cii avatar Jan 25 '24 10:01 as-cii

Sure thing. I also just found that switching tabs using the keyboard shortcut does not trigger the freezing, only clicking on the tabs.

Labrium avatar Jan 25 '24 15:01 Labrium

From these profiles, it looks like Zed is creating a ton of threads when you click to switch tabs, but not when you use the keybinding, even though using the keybinding increases the CPU usage more: ZedTabSwitchingClick.trace.zip ZedTabSwitchingKeybinding.trace.zip

Labrium avatar Jan 25 '24 15:01 Labrium

@Labrium nothing really stands out in the trace. Any timestamp in particular you think we should focus on?

Also: is there anything special about the files you're opening? Are they large? LSP attached?

A screen recording would be ideal, because it's really hard to reproduce this.

EDIT: Another think work trying is to launch Zed with ZED_MEASUREMENTS=1 which will then cause Zed to print the time it takes for frames to render: env ZED_MEASUREMENTS=1 /Applications/Zed.app/Contents/MacOS/zed

You can then post the results here.

mrnugget avatar Jan 26 '24 13:01 mrnugget

https://github.com/zed-industries/zed/assets/76017200/8f4100d8-0d97-4012-b03f-8c6e6ae10a83

Labrium avatar Jan 26 '24 17:01 Labrium

Same as this Zed: v0.119.20 (Zed) OS: macOS 12.2.1 Memory: 16 GiB Architecture: arm

ClanEver avatar Jan 29 '24 06:01 ClanEver

@Labrium thanks! Wow, that's interesting. Exactly 1s frames. Sadly I can't see those blocks in the traces you provided.

Could you maybe re-record a trace but this time add the Thread State Trace instrument? To do, you need to hit the + in the top right corner of Instruments.app and add it. Like this:

screenshot-2024-01-29-16 34 48@2x

That will then record a trace showing what each thread was doing. Ideally we'd see the 1s show up somewhere.

screenshot-2024-01-29-16 35 36@2x

mrnugget avatar Jan 29 '24 15:01 mrnugget

@mrnugget I was about to record that trace for you, but it looks like this issue is completely fixed in Zed 0.121.5!

Labrium avatar Feb 08 '24 15:02 Labrium

Ha! Well, I wish I knew what it was, but I'll take a closed issue :)

mrnugget avatar Feb 08 '24 16:02 mrnugget