Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing in .rs files locks the entire IntelliJ UI for several seconds, even when typing comments #10832

Open
aSemy opened this issue Aug 29, 2023 · 10 comments

Comments

@aSemy
Copy link

aSemy commented Aug 29, 2023

Environment

  • IntelliJ Rust plugin version: 0.4.200.5421-232
  • Rust toolchain version: 1.71.0-nightly (4ca000ac8 2023-07-13) x86_64-pc-windows-msvc
  • IDE name and version: IntelliJ IDEA 2023.2.1 Ultimate Edition (IU-232.9559.62)
  • Operating system: Windows 10.0
  • Macro expansion: enabled
  • Additional experimental features: org.rust.macros.proc.attr

Problem description

When I type in a main.rs file the whole UI freezes and lags. It's even slow when I'm just writing a comment - no Rust code.

When I type in a non-Rust file performance is fine.

I recorded a video of me typing in a .rs and .txt files: https://i.imgur.com/d2G6OnK.mp4

Steps to reproduce

src/main.rs

#![no_std]
#![no_main]

// extern crate alloc;

use esp_println::println;
use hal::{peripherals::Peripherals, prelude::*, Rtc, Rng};
use hal::clock::ClockControl;
use hal::timer::TimerGroup;

use core::panic::PanicInfo;

// mod wifi;
// mod metrics;

// // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
// use esp_idf_sys as _;

/// This configuration is picked up at compile time by `build.rs` from the file `cfg.toml`.
#[toml_cfg::toml_config]
pub struct Config {
    #[default("")]
    wifi_ssid: &'static str,
    #[default("")]
    wifi_psk: &'static str,
}


#[entry]
fn main() -> ! {
    let peripherals = Peripherals::take();
    let mut system = peripherals.DPORT.split();
    let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

    // Disable the RTC and TIMG watchdog timers
    let mut rtc = Rtc::new(peripherals.RTC_CNTL);
    let timer_group0 = TimerGroup::new(
        peripherals.TIMG0,
        &clocks,
        &mut system.peripheral_clock_control,
    );
    let mut wdt0 = timer_group0.wdt;
    let timer_group1 = TimerGroup::new(
        peripherals.TIMG1,
        &clocks,
        &mut system.peripheral_clock_control,
    );
    let mut wdt1 = timer_group1.wdt;
    rtc.rwdt.disable();
    wdt0.disable();
    wdt1.disable();
    println!("Hello world!");


    // let metrics = Metrics::new();
    // let mut rng = rand::thread_rng();
    let mut rng = Rng::new(peripherals.RNG);

    loop {
        // IU am trying to type.

        // but it's really lagging.
        Wh
        // rng.
        if rng.gen::<u8>() > 200  {
            // metrics.counter.inc();
            // println!(metrics.counter.get());
        }
    }
}

/// This function is called on panic.
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

Cargo.toml

[package]
name = "fqnet_rust"
version = "0.1.0"
authors = ["Adam"]
edition = "2021"


[profile.release]
opt-level = "s"
lto = "off"

[profile.dev]
debug = true    # Symbols are nice and they don't increase the size on Flash
opt-level = "z"
lto = "off"

[features]
#default = ["esp32"]
wifi = ["esp-wifi/wifi"]

#default = ["native"]
#native = ["esp-idf-sys/native"]

[dependencies]
hal = { package = "esp32-hal", version = "0.14.0" }
esp-backtrace = { version = "0.7.0", features = ["esp32", "panic-handler", "exception-handler", "print-uart"] }
esp-println = { version = "0.5.0", features = ["esp32"] }

#rustfft = "=6.1.0"
#easyfft = "=0.3.5"

#anyhow = "=1.0.71"

#esp-idf-hal = "=0.41.1"
#esp-idf-svc = { version = "=0.46.0", features = ["experimental", "alloc"] }
#esp-idf-sys = { version = "=0.33.0", features = ["binstart"] }
#log = "=0.4.18"
##rgb-led = { path = "../../common/lib/rgb-led" }
toml-cfg = "=0.1.3"
##wifi = { path = "../../common/lib/wifi" }
#
##embedded-svc = "=0.25.0"
#esp-idf-hal = "=0.41.1"
#esp-idf-svc = { version = "=0.46.0", features = ["experimental", "alloc"] }
#esp-idf-sys = "=0.33.0"
#log = "=0.4.18"

#prometheus = "0.13.3"

[dependencies.esp-wifi]
git = "https://github.com/esp-rs/esp-wifi.git"
rev = "b8bddffa46605a082610e8fc2fea90af98dacb3d"
features = ["esp32", "wifi", "esp-now"]

[profile.dev.package.esp-wifi]
opt-level = 3


[build-dependencies]
anyhow = "=1.0.71"
embuild = "=0.31.2"
toml-cfg = "=0.1.3"

rust-toolchain.toml

[toolchain]
channel = "esp"
components = ["rustfmt", "rustc-dev"]
targets = ["xtensa-esp32-none-elf"]
@Maksim20023
Copy link
Collaborator

Hi. Thank you for the report.
I tried reproducing the issue based on the description, but the UI didn't freeze in my case.
So, as a general troubleshooting step, please try to perform Invalidate caches with the checked "Clear file system cache and Local History" option.
If you have additional custom plugins installed (except for the rust plugin), please try turning them off.
If clearing the cache and turning off plugins doesn't help, and IDEA UI still freezes, please capture and send us CPU snapshot and logs ( Help | Collect Logs and Diagnostic Data), and we will investigate it.
Please remember that idea.log and snapshot data might contain sensitive information (e.g local paths). You can upload your logs and snapshot to our https://uploads.jetbrains.com/. Uploaded files will only be accessible to JetBrains employees, and we guarantee the privacy of the data.

@aSemy
Copy link
Author

aSemy commented Aug 30, 2023

thanks @Maksim20023 - I uploaded the data:

Upload id: 2023_08_30_8dez9rbkqqYv3nx27t7cjF (file: idea-logs-20230830-10240610095648456711175503.zip)

I'm not able to invalidate all caches because I don't have time - IntelliJ would take too long to re-initialise all of my other projects.

Is there a way to quickly open IntelliJ without the plugins activated? I'd rather not have to go through and manually enable/disable all plugins.

Here's my IntelliJ install details, if it's useful:

IntelliJ IDEA 2023.2.1 (Ultimate Edition)
Build #IU-232.9559.62, built on August 23, 2023
Runtime version: 17.0.8+7-b1000.8 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 12288M
Cores: 20
Registry:
    always.show.intention.above.current.line=true
    ide.ui.tree.indent=0
    terminal.use.conpty.on.windows=false
    editor.minimap.enabled=true
    kotlin.scripting.index.dependencies.sources=true
    ide.images.show.chessboard=true

Non-Bundled Plugins:
    com.jetbrains.plugins.ini4idea (232.9559.64)
    Batch Scripts Support (1.0.13)
    org.ziglang.jb (0.3.0)
    org.rust.lang (0.4.200.5421-232)
    com.samvtran.plugins.macosforallkeymap (2.0.0)
    com.intellij.ideolog (222.1.0.0)
    name.kropp.intellij.makefile (232.8660.88)
    org.jetbrains.plugins.localization (232.8660.88)
    Key Promoter X (2023.2.0)
    com.jetbrains.fast.mouse.scroll (1.6.1)
    com.intellij.nativeDebug (232.9559.34)
    org.jetbrains.plugins.hocon (2023.1.0)
    com.jetbrains.packagesearch.intellij-plugin (232.9559.10)
    com.github.camork.fileExpander (2.1)
    nl.rubensten.texifyidea (0.9.1)
    kvision.project.wizard (0.8.0)
    kotest-plugin-intellij (1.3.69-IC-232-EAP-SNAPSHOT)
    com.github.jk1.ytplugin (2023.1.48)
    mobi.hsz.idea.gitignore (4.5.1)
    com.jetbrains.php (232.9559.64)

Kotlin: 232-1.9.0-IJ9559.62

@Maksim20023
Copy link
Collaborator

Maksim20023 commented Aug 30, 2023

Thank you for providing logs, but unfortunately, the idea.log file is empty: its size is 0 bytes.

Screenshot 2023-08-30 at 11 46 44

Could you please collect and send logs again?
Before sending it, please ensure the collected logs are not empty. If the idea.log size is 0 bytes again, please check this file in the log directory https://www.jetbrains.com/help/idea/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#logs-directory manually. In IntelliJ IDEA, go to Help | Show Log in Explorer. The idea.log should not be empty and contain essential information about the IDE's work.

And, as I mentioned, please capture CPU snapshots. This is a very important source of information for performance issues.

Is there a way to quickly open IntelliJ without the plugins activated?

You can launch IntelliJ IDEA without installing plugins by the command line parameter:
disableNonBundledPlugins
Please take a look at this link for more information: link
After launching with this parameter, all non-bundled plugins will be turned off.
Alternatively, you can turn off all plugins in IntelliJ IDEA on the plugin settings page.
Go to
File | Settings | Plugins
Press the gear icon
Press the "Disable All Downloaded Plugins" option.
Also, could you please specify whether lags and freezes are observed in every project or only in this one?

@AlyoshaVasilieva
Copy link

My experience is that typing in a function that has a proc macro applied to it is often very slow. (In my case, it was debug_handler from axum.)

@Maksim20023
Copy link
Collaborator

Hi @AlyoshaVasilieva !
To investigate the issue you are facing, please provide a CPU snapshot and detailed information about your environment. It is very important for the investigation process to have a CPU snapshot as it is the primary source of information about performance issues.
Please also try to comment out the macro and perform invalidate caches. Does that help?
Please remember that snapshot data might contain sensitive information (e.g local paths). You can upload your logs and snapshot to our https://uploads.jetbrains.com/. Uploaded files will only be accessible to JetBrains employees, and we guarantee the privacy of the data.

@aSemy
Copy link
Author

aSemy commented Aug 31, 2023

hi @Maksim20023, I've uploaded the log file again

Upload id: 2023_08_31_Ee6kiH4sBQQCdEKo7AiSiX (file: idea-logs-20230831-17365712261283660449026686.zip)

@profiluefter
Copy link

Hi, I'm having the exact same issue.
I tried disabling "Expand macros" ("Languages & Frameworks" > Rust) in the settings and it stopped slowing down. But it also stopped recognizing my actix_web::main function as it uses a macro.
Invalidating caches did not make a difference for me.

Some macros cause major slowdowns such as actix_web::get, however typing in a actix_web::main function does not have noticable performance issues for me.

I have uploaded logs and a CPU snapshot:
Upload id: 2023_09_03_pWimHY3ayk5rUSRsGeZMSa

I also zipped the rust project I was typing in since it is only a few lines more than the Actix Web Hello World example:
Upload id: 2023_09_03_2A4VtYESrYVTH85z4SLKv4

Hope I could help in resolving this issue.

@Maksim20023
Copy link
Collaborator

@aSemy I'm grateful to you for the logs. However, to investigate the cause of the problem, it's also important for us to obtain a snapshot, so please send it according to these instructions.

@profiluefter Thank you for providing us with snapshots, logs, and the project. I forwarded it to our development team for investigation.

@aSemy
Copy link
Author

aSemy commented Sep 5, 2023

@aSemy I'm grateful to you for the logs. However, to investigate the cause of the problem, it's also important for us to obtain a snapshot, so please send it according to these instructions.

Upload id: 2023_09_05_AxmbdNqHrTjFMSysUbYLxT (files: IU-232.9559.62_Adam_05.09.2023_12.19.38.zip, IU-232.9559.62_Adam_05.09.2023_12.20.35.zip)

@aSemy
Copy link
Author

aSemy commented Sep 6, 2023

So, as a general troubleshooting step, please try to perform Invalidate caches with the checked "Clear file system cache and Local History" option.
If you have additional custom plugins installed (except for the rust plugin), please try turning them off.

Even if I cleared the caches and disabled the plugins, bad caches and plugins shouldn't affect the entire IntelliJ UI should it?

For example, if IntelliJ Rust autocompletion suggestions was a difficult operation then I'd expect that there'd be a little 'loading' spinner in the autocomplete dropdown, like there is in Kotlin:

image

But it's extremely strange that the whole UI locks up.

@aSemy aSemy changed the title Typing is really slow and laggy Typing in .rs files locks the entire IntelliJ UI for several seconds, even when typing in comment blocks Sep 6, 2023
@aSemy aSemy changed the title Typing in .rs files locks the entire IntelliJ UI for several seconds, even when typing in comment blocks Typing in .rs files locks the entire IntelliJ UI for several seconds, even when typing comments Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants