nhaouari / obsidian-textgenerator-plugin

Text Generator is a versatile plugin for Obsidian that allows you to generate text content using various AI providers, including OpenAI, Anthropic, Google and local models.
https://text-gen.com/
MIT License
1.45k stars 128 forks source link

Performance issue: Typing is signficantly delayed. On Mac #227

Open KleinByte opened 9 months ago

KleinByte commented 9 months ago

With only this plugin turned on, I experience a significant delay in rendering text on keypress. This has been tested over and over again. Turning this plugin off brings back obsidian to normal typing response times. Turning this plugin back on, reintroduces an unacceptable amount of delay in typing.

Not quite sure why this is happening. Nothing in the console or anything that clearly shows why.

I do not have autocomplete turned on either.

I would expect that when you do not activate a command for this plugin, that it does nothing in the background.

haouarihk commented 9 months ago

Thats weird.. sorry if you were experiancing this. can you post some more info, so that we can replicate it such as obsidian version, pc specs, platform, plugin version... etc

dverslegers commented 9 months ago

Same issue here. Will try to provide some more details after the holiday period. Behaviour is as described above: after some limited time and with limited notes open (+/- 5) delays occur when typing text with the plugin enabled. I tried disabling the autosuggest features, no change in behaviour.

andreicozma1 commented 9 months ago

Can confirm this plugin causes extreme lag in Obsidian while typing. Suspecting that it comes from a key event listener gone rogue, possibly related to the Auto-Suggest feature, unfortunately even whilst disabled within the UI.

haouarihk commented 9 months ago

can you test it with version 0.5.26-beta and disable auto-suggest

andreicozma1 commented 9 months ago

can you test it with version 0.5.26-beta and disable auto-suggest

At first glance, the performance appears to be slightly better on version 0.5.26-beta with auto-suggest disabled.

I'll keep using it and if I notice the issue persists I'll do some more investigation

dverslegers commented 9 months ago

Currently testing with version 0.5.27-beta and auto suggest disabled and still experiencing significant delays. They are slightly better compared to the previous version but a noticeable lag remains.

haouarihk commented 9 months ago

Can you list your pc specs?

dverslegers commented 9 months ago

Most certainly:

3.5 Ghz 8-core Intel Xeon 96GB DDR4 Sonoma 14.1.2

Also tested on M3-PRO with 32Gb of memory, same results

haouarihk commented 9 months ago

So its a macos issue?

dverslegers commented 9 months ago

I can only confirm the issue on MacOS as I do not have a Windows system at my disposal. We could set up a lab with a VM... Maybe @andreicozma1 can chime in on his OS?

haouarihk commented 9 months ago

can you try also disabling modal-suggest

andreicozma1 commented 9 months ago

Below is the initial result of the profiling. My testing is as follows:

image

Notice that the result with text generator plugin enabled has greatly increased load for the purple area (re-rendering?).

Let's look at just 1 of the 4 instances of me typing "hello world":

image

In this time frame, we see the below behavior under the Event Log:

With Text Generator disabled, notice the total times are really low (sorted descending):

image

With Text Generator enabled, notice the total times are extremely high (still sorted descending):

image

Something within Text Generator is causing Obsidian to forcefully re-calculate the styles and layouts of the entire UI causing the lag spikes with every key press.

Note: Both Auto Suggest and Modal Suggest are disabled within Text Generator.

Unfortunately I do not have a Windows machine at my disposal at the moment. I can test on macOS with intel chip and Ubuntu

haouarihk commented 9 months ago

can you test on version 0.5.28-beta i've made some optimizations

andreicozma1 commented 9 months ago

can you test on version 0.5.28-beta i've made some optimizations

It seems a lot better with this one so far. Thanks a lot!

dverslegers commented 9 months ago

Upon some testing with 0.5.28-beta and the suggested settings, I have the following results:

It seems like the plugin is having some issues with larger notes from which it cannot recover until an Obsidian restart.

Let me know what I can do to help investigate the issue.

dverslegers commented 9 months ago

FYI, just tested with version 0.6.0 -> the behaviour remains the same.

haouarihk commented 9 months ago

can you try using this release https://github.com/nhaouari/obsidian-textgenerator-plugin/releases/tag/developmentBuild

it should give us more insights on what is being used