High CPU load while idle

Hi,

I observe a constantly high CPU load with my local vaults on macOS Monterey, except for the sandbox vault.

Things I have tried

  • I enabled safe mode
  • I disabled all core plugins
  • I disabled the legacy editor
  • I re-installed Obsidian (ie, move app to trash, download & move app to /Applications)

Nothing of these steps changed anything.

CPU load for the main process remains constantly high, between 60% and 95% (mostly around 80%).

The Sandbox vault show a near-zero CPU load.

The Performance tab of the Web Dev Tools shows near-zero CPU for most of the time, while the Activity Monitor continuously shows a high load.

Profile-20220629T192925.json.zip (181.1 KB)

When I created a fresh vault from an existing folder (a quite small one, 470 files, mostly non-Markdown files), CPU load is as low as when using the Sandbox vault.

Which makes me wonder if all of my local vaults have some issue with their config or caches?

How can I troubleshoot this further?

What I’m trying to do

Nothing in particular. I only want to use my vaults without maxing out the fans.

2 Likes

Update: Seems to have been some background indexing going on.

I opened all vaults and let Obsidian run for a few hours, and now all Obsidian processes are near 0% CPU/GPU time.

I will observe this further, but for now, things look quite good.

It would be good to have some more tooling available to better identify which long-running thread keeps the CPU busy for hours.

2 Likes

Unfortunately, my Obsidian app keeps returning to 50-80% CPU.

Does Obsidian run regular indexing or caching tasks in the background that take hours to complete?

1 Like

I’m not seeing this on my Mac. I would expect the things you tried would clear up or reveal the source of the problem. Just to add to the list of basics: did you try rebooting the computer?

Are you using any kind of sync (Obsidian Sync, iCloud, Dropbox, etc.)?

Thanks for the suggestion. Although rebooting is mainly a problem solver for Windows rather than Mac/Unix, I tried this today, but Obsidian went to ~80% CPU load again.

I let btop track the per-app CPU usage. For two hours, usage was between 50-90%.

After that, the CPU usage turned into an on-off pattern (a few seconds of activity followed by a few seconds of idling). After 4 hours of uptime, the pattern still persists.

I still suspect that some internal indexing is going on here, but I have no idea how to track that down further, besides staring at CPU graphs.

Some things you might try (I’m just spitballing):

  • Make a copy of your vault folder and open it as a vault in Obsidian. Does it have the same problem?
  • (After backing up) Try deleting or renaming config files 1 by 1 and restarting the app (I think Obsidian will regenerate ones that are missing, but you may want to research that). Does the behavior persist?
  • (After backing up, of course) Try removing other files 1 by 1, in case Obsidian is for some reason hung up on indexing one of them. As a first rough cut, you might remove all non-Markdown files, and if that has no effect put them back and try removing all Markdown files. If 1 of those does something and you have folders, you could get more granular by removing folders 1 by 1.

Thanks, @CawlinTeffid, for the help.

Testing config files one by one might make sense but on the other hand, I observe the problem with several of my vaults. They are completely separate. They don’t share files and are not nested inside each other.

Just now, I opened some random folder as a new vault. So this is a brand-new vault with standard settings. No community plugins enabled (safe mode=on), not too many files inside (1,361 to be precise, with only 2 Markdown files).

After opening the vault, CPU usage of Obsidian.app stays around 80% for a couple of minutes, then drops to near-zero.

(Note the elapsed time, and the disk I/O.)

This pattern repeats every time I close and re-open the vault.

I am more and more convinced that Obsidian does some initial indexing whenever a vault is opened. The larger the vault, the longer it takes. (One of my vaults has 60,000 files inside, of which 2003 are Markdown files.)

Edited to add: I do not refer to the one-time initial indexing that Obsidian does with brand-new vaults. It must be something else that happens at every start of a vault.

1 Like

Yeah, I’d expect it updates the index whenever you open a vault (because you could have changed the files while it was closed). I normally leave mine open all the time. I closed and reopened it and saw CPU go pretty high, settle at around 40%, then go back down, all taking about half a minute (this is on an M1 MacBook Air).

Maybe there is something here to explore?

That does look excessive (to not-an-Obsidian-developer me). And the I/O on the earlier pics you posted goes up to almost 1 GB.

I am on a MacBook Pro 2017. The 60,000-files vault keeps the CPU busy for ~2 hours.

Maybe I should upgrade… :slight_smile:

Oh yeah, I forgot to mention that my vault has 6,000 files (mostly Markdown).

I would hope that your computer should be able to handle Obsidian without much trouble (I was thinking you might have an old Air; anyway I realized that I won’t have much insight into normal performance problems).

I’ll try putting my vault on my old Linux machine to see what happens, but I don’t know when I’ll get around to it.

1 Like

I am sorry that I have to revive this thread.

I have a new MacBook Pro 2023 now, with 12 CPU cores. Obsidian still consumes 100% CPU and when I am on battery, the time until empty reduces from 7-8 hours on normal load to 3 hours when Obsidian runs.

It’s the same when I disable community plugins. So it is definitely a bug in core Obsidian.

Is there any way I can debug this and drill down to the part of Obsidian that sucks so much CPU time while apparently doing nothing?

Update: I recently moved two of my vaults to the Obsidian iCloud folder. When I open only these vaults, CPU load is near zero.

But when I open any of the vaults inside my Documents folder, CPU raises to 100%.

A new, empty vault inside Documents does not show this problem.

Have you tried copying everything except the .obsidian folder from a problem vault to a working empty vault in Documents?

@CawlinTeffid Not yet, because meanwhile, I observed the following:

  • I had Obsidian open with one of the affected vaults, let’s name it Vault A.
  • After a while (I cannot tell how long it took—I noticed it one or two days later), CPU load dropped to near-zero.
  • I got curious and started another of the affected vaults (Vault B).
    CPU went up to near-100%.
  • Then I stopped Vault B.
    CPU load REMAINED at ~100%

I then dug further and found that Obsidian seems intensely busy with updating a database in

~/Library/Application Support/obsidian/IndexedDB/

One day later, the above scenario repeated. (I had one vault open, CPU load was at 100% but the next day it was near zero. I closed that vault and opened another one, and CPU load is at 100% again.)

I reckon that there is some horribly inefficient indexing going on that needs hours or a day to complete. And this repeats for every vault I open.

Am I right?

Is this a known issue?

If it is, are there already plans or ideas for fixing this?

One more observation.

  • I open a vault
  • I wait for the CPU load to drop to near-zero
  • I close the vault
  • I open the same vault again
  • The CPU load is at 100% again, for hours

Which means that I should never open a vault while on battery, or the battery life drops to 3 hours (when the battery is still full).

Should I try to delete the IndexedDB cache files?

Update: or remove the [Cache_Data directory]?(Stuck on Loading cache - #19 by wealthychef)

I should mention that the “Loading cache” phase is very short for all vaults. Because of this, I don’t think it is a cache issue.

1 Like

Yeah, I’d try deleted the IndexedDB caches files (or just moving them somewhere else temporarily).

Thanks @CawlinTeffid but this did not work out. I deleted the cache DB files, restarted Obsidian, and the CPU load is at 100% again.

Maybe I am wrong about IndexedDB being the source of the high load.

Is there any way to dig deeper into what’s going on inside Electron?

(I am thinking of Chrome’s about://tracing but I don’t know if and how this works with the release version of Obsidian.app)

I don’t know, sorry.

I vaguely recall seeing one or more threads in which Obsidian got hung up on a particular file. I don’t remember if this was in the context of indexing — might have been sync or something else — but maybe that gives you something else to look into.

No probs, thanks for your assistance. I’ll see if I can find some tools that could help reveal where the CPU usage is going to.

I also encountered the same problem, every time I open obsidian, it takes about 10% CPUfor a long time
image