AdaCore / gnatstudio

GNAT Studio is a powerful and lightweight IDE for Ada and SPARK.
399 stars 52 forks source link

Gnat Studio and the language server processes saturate a core for minutes with large arrays #159

Open kevlar700 opened 1 year ago

kevlar700 commented 1 year ago

When using GNAT Studio Continuous Release 20230501 (other versions untested) with an constant Interfaces.Unsigned_8 array containing 310,352 bytes in my case (generated by the Advanced Resource Embedder tool and the array contents copied over). I find that Gnat Studio has serious performance issues compared to vscode. vscode does take minutes like gnat studio to format the file containing the array.

AnthonyLeonardoGracio commented 1 year ago

Hello @kevlar700,

Could you attach the file that exhibits the issue? Also, what does trigger the performance issue? Is it tooltips, navigation, something else? If you could give more details.

kevlar700 commented 1 year ago

I couldn't attach files with extension .ads|.adb so you can find them here. "https://github.com/kevlar700/Gnat-Studio-issue-159"

I shall try to pin point some extra information but the issues should hopefully be quite apparent if you start doing any editing in the .adb file utilising the array or try to format the .ads file. However my array formatting pretty print options currently put array components on lines by themselves.

My pretty print options are:

   package Pretty_Printer is
      for Default_Switches ("ada") use ("--call-threshold=1", "--par-threshold=1", "--vertical-enum-types", "--vertical-named-aggregates", "-W8", "-c5", "-c4");
   end Pretty_Printer;

The gnat_studio_exe process is tied up for several minutes followed by the language server upon killing gnat studio. There is a kernel log entry for the language server of overflowed sigaltsack

kevlar700 commented 1 year ago

Realising that the following was missing:

type Positive_8_Array_Data is array (Positive range <>) of Interfaces.Unsigned_8 with
Component_size => 8;

I created a project just with the trouble code and the performance issue is there but much much less and usable.

I am trying to narrow down the cause though the language_server was using 1.35 gigabytes of ram on this tiny project. Perhaps it ran out of stack on my larger project where my large projects language server normally uses less than 500 megabytes (before the addition of this array).

kevlar700 commented 1 year ago

I haven't changed anything and now the large project seems to be performing better than yesterday so long as I do not attempt to format the .ads file with the array.

Perhaps this issue should be closed or renamed to a feature request of adding multi core support to the language server and gnat studio processes or efficiency improvements to the formatter?

Edit: I just left the formatter going until completion for around twenty minutes and it failed to complete the task so I guess the issue may not just be performance.

AnthonyLeonardoGracio commented 1 year ago

Hello @kevlar700,

We have identified an issue with the tooltips: we are trying to display all the components of the very big constant array, which makes GNAT Studio to hang. We'll fix that.

Regarding formatting, we'll open an issue internally to see what we can do.

Regards,