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

Extreme performance issues and stuttering on Android and Linux #104

Open
5HT2 opened this issue Aug 10, 2023 · 6 comments
Open

Extreme performance issues and stuttering on Android and Linux #104

5HT2 opened this issue Aug 10, 2023 · 6 comments

Comments

@5HT2
Copy link

5HT2 commented Aug 10, 2023

Using Tag Wrangler 0.5.11 with Obsidian v1.3.7, both on Linux and Android.

I have noticed increasingly more performance issues and stuttering while typing or deleting files, just deleting a blank file would take ~20 seconds for the UI to update.

Upon disabling Tag Wrangler this immediately helped.
Here are my logs: https://cdn.frogg.ie/paste-1691700003.txt
Here is my debug info: https://cdn.frogg.ie/paste-1691700597.txt

I used the "Divide & Conquer" plugin to bisect the issue and narrow it down to Tag Wrangler.

Is there anything else I can help provide to debug this issue?

@pjeby
Copy link
Owner

pjeby commented Aug 11, 2023

The most peculiar thing here is the response to deletion -- all Tag Wrangler does on file deletion is remove some entries from its cache -- entries that don't exist unless you're using tag pages. And the cache is in memory, not on disk. So I don't think the deletion has anything to do with Tag Wrangler, or at least not something TW itself is doing.

Similarly, the only thing TW does when file changes occur is to update the in-memory cache of tag pages -- again, only if you actually have tag pages, and even then it's rate-limited to once every 2 seconds unless another plugin is overriding Obsidian's default save interval. (A tag page is any page with an alias or aliases YAML field (case-insensitive) containing strings beginning with # that are a syntactically-valid Obsidian tag.) And if you aren't using tag pages, the background updates won't actually do anything to start with.

Could you check if older versions have the same problem? Also, I'm curious about your vault, since I'm not having this issue on Windows. How many notes are in it? How many are tag pages?

It's in principle possible that it's an interaction with another plugin causing the issue. I personally use Calendar, Kanban, BRAT, Recent Files, Periodic Notes, and Style Settings, and I've been an occasional user of some of the others, so I don't think they're likely. The ones I suspect most likely to have an interaction are Editor Syntax Highlight, the various embeds, and Auto Note Mover, but I wouldn't rule out others.

My suspicion is that if this is a recent issue with a recent version of TW, that it's something to do with styling of in-editor elements and hovering the mouse over them (though it's unclear to me how that would run away with anything CPU-wise, and the delete/update things make no sense at all).

Overall, my guess is that D&C hasn't found the plugin that's actually delaying things, even if TW's presence is somehow required to trigger the bug. If you open the inspector and then pause in the debugger during a lengthy pause, it'd be interesting to see what the stack looks like.

One thing TW does that might interact with other plugins is that it patches Obsidian's metadata cache to return tags that are only mentioned in tag pages, and not used as regular tags. (So they show with a 0 in the tag pane.) If another plugin isn't expecting tags to exist with a zero count, I suppose it might make them do something weird, but that seems like a long shot.

Anyway, the big question is probably: do you use tag pages, and if so, how many? That would help to rule that out as a cause.

@5HT2
Copy link
Author

5HT2 commented Aug 23, 2023

Could you check if older versions have the same problem? Also, I'm curious about your vault, since I'm not having this issue on Windows. How many notes are in it? How many are tag pages?

~80 notes, about 10k words total in this vault. 59 of them are tag-centric daily notes, with 3.5k words total (so, probably quite a few tags).
What do you mean by tag pages? How are tag pages different from a regular tag?

I can try out older versions - is there an easy way to install / switch versions? I tried using just tag wrangler on it's own.

Thank you for the quick and detailed response! I am back from vacation so I should be checking Github more often.

@pjeby
Copy link
Owner

pjeby commented Aug 23, 2023

Tag pages are pages that have a tag as an alias - i.e. a page that describes the tag, rather than a page tagged with the tag. If you were using them, you'd know, since they're a Tag Wrangler feature.

With a vault that size, there should be no way for TW to cause you performance issues - my main vault is ~3000 notes and many of my notes have more words than your vault. So... it's likely to be another one of your plugins, even if there's somehow an interaction with TW.

The weirdest thing is, TW doesn't do anything when you type. Like, ever. The most it can do is spend a millisecond looking at the tags in the page you're editing once every 2 seconds. Even if you're editing a page of nothing but tags, it only looks at the front matter.

Did just using tag wrangler and no other plugins have the slowdown? If you also disable tag wrangler from that state (without restarting obsidian) does the issue go away, or do you have to restart Obsidian for the issue to go away?

To install older versions, download main.js, manifest.json, and the styles.css from that version's release page on Github, place them in your .obsidian/plugins/tag-wrangler folder for the vault in question, then click the "reload" icon in plugin settings, turn the plugin off, and then back on again. (Or just restart obsidian, and check that the plugin version changed.)

@pjeby
Copy link
Owner

pjeby commented Oct 16, 2023

Did you ever find out what was going on with this?

@5HT2
Copy link
Author

5HT2 commented Oct 26, 2023

I did not, I'll probably re-enable the plugin and test more, I'll let you know if I can reproduce it!

Sorry, I thought I had replied on this thread, I do appreciate the very thorough explanation of how TW works!

I did test with all other plugins disabled but I did end up filing issues with another plugin that I also noticed to be causing performance issues, it might have just been a coincidence (I have no idea if plugins have any kind of context or ability to run code when disabled, I'd get the impression they don't, though the "Divide and Conquer" plugin seems to have the ability to hijack itself from being disabled so maybe they do, it could also have been entirely unrelated with no affect on the issue I described with TW).

For the issue to go away I had to disable TW and restart Obsidian fully, not just reload the plugins.

@pjeby
Copy link
Owner

pjeby commented Oct 26, 2023

The only way for a plugin to run code while disabled is if it installs patches or event handlers and doesn't remove them on exit. This doesn't survive restart of Obsidian unless the plugin also blocks itself from being disabled on disk (ala D&C).

In the case of plugins written by me, they are written to remove all patches, event handlers, etc., so if any are still running after disabling in settings, that's a bug.

With regard to needing to disable and restart, please note that I said "reload, then turn the plugin off and back on again" - if you were still having the problem after the downgrade until restart (and followed that procedure exactly), then it's proof positive that another plugin was involved, as everything TW installs should be removed when you turn the plugin off. (Note: the "reload" icon in plugin settings does not actually "reload" anything - it just refreshes version info from the files on disk. You have to turn a plugin off and back on again to actually reload that plugin.)

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

2 participants