-
Notifications
You must be signed in to change notification settings - Fork 104
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
ANTLR plugin high CPU utilization during idle #702
Comments
Hi, and thanks for the detailed description. It seems your problem is related to a bad grammar. To fix #399 I implemented a "watchdog" that prevents the grammar interpreter from being stuck in an infinite loop when it parses such grammars. It's working correctly, but in your case the error recovery strategy is somehow trying to recover again and again from the exception thrown by the watchdog. You can 'fix' your grammar by removing the infinite recursion: list: x list?; And on my side I'll fix the plugin to avoid the infinite recovery and try to provide a useful error message. BTW antlr itself (not the IJ plugin) also crashes on your grammar:
|
For context, this happened while I was doing a direct 1-to-1 conversion of a grammar from another project. Under the direction of my professor, I was attempting to keep the grammar structure as close as possible to the original. Although I cannot pull up the original grammar (I did not keep it, even though maybe I should have), I know that it did not have a forced infinite loop (Running ANTLR itself worked fine, and would produce a meaningful parse tree), but still caused this performance issue. I eventually switched to alternate notation of At some point in the near future, when I have some extra time, I'll revisit this to try and recreate that behavior so you have a more concrete example to work with. |
Windows 10 x64
IntelliJ IDEA 2024.1.1
IDEA plugin version 1.23.1
When starting the IDE with the plugin enabled, CPU utilization is normal.
After opening a
.g4
file, CPU usage spikes and stays high.CPU utilization continues staying high if the file is closed. It also stays high if parsing is stopped by the "stop" button in the preview pane. The preview pane does not ever need to have opened for the high utilization to start.
When setting idea64.exe affinity to just cores 0 and 2 (to avoid hyper-threading), both cores are at 100% utilization. Giving IDEA additional cores distributes the load, which suggests 2 no-sleep looping threads.
Closing the project does not cause this utilization to come back down. Only terminating the IDE and restarting causes idle utilization to be normal again.
This anomalous utilization does not occur if the plugin is disabled.
After some testing, I discovered that this does not happen to all grammars. I have created an offending grammar that causes this issue:
The text was updated successfully, but these errors were encountered: