compass icon indicating copy to clipboard operation
compass copied to clipboard

High CPU usage on macOS from the Renderer process

Open MitchellCash opened this issue 2 years ago • 17 comments

Bug Report

Current Behavior

I notice that Compass causes high CPU usage on my machine and it seems to stem from the Electron renderer process (see screenshot).

My machine is running a 2.6 GHz 6-Core Intel Core i7 and I wouldn't expect the Compass app to be averaging 15%-20% of the CPU when connected to a database.

Code/Gist

N/A

Expected Behavior/Code

Less CPU usage.

Environment

Compass: Version 1.32.2 (1.32.2) OS: macOS Monterey 12.4 CPU: 2.6 GHz 6-Core Intel Core i7 Memory: 16 GB 2667 MHz DDR4

Possible Solution

I do notice the Electron version being used is v13 when v19 is available, which of course is not a guaranteed fix for the problem, but probably doesn't hurt seeing as v13 isn't supported/updated any more.

I also noticed some anecdotal data, which isn't exactly an "apples to apples" comparison, but I will include nonetheless. The high CPU usage seems to be when I connect to a MongoDB 4.4.11 Community instance with 8GB of data using a TLS certificate. When I connect to a MongoDB 5.0.9 Enterprise instance with 10MB of data without using a TLS certificate the CPU usage is about half (~8% usage).

So the differences between the comparison is MongoDB version, logical size or the TLS certificate.

Mongo version Logical size Connect with TLS certificate Compass CPU usage
MongoDB 4.4.11 Community 8 GB True 15%-20%
MongoDB 5.0.9 Enterprise 10 MB False 8%

From these I wonder if the use of a TLS certificate is causing the much higher CPU usage?

Additional Context/Screenshots

MongoDB Compass Renderer process CPU usage

MitchellCash avatar Jun 28 '22 12:06 MitchellCash

This issue is not specific to macOS.
The same exact thing happens on Linux as well.

dumbasPL avatar Jul 22 '22 08:07 dumbasPL

Same here, still 1 year later. MacOS version 13.3.1, Compass version 1.36.4.

john-g-davies avatar May 11 '23 03:05 john-g-davies

Compass still has this bug, very annoying. Apple M1 Max MacOS 13.2.1 (22D68), Compass 1.37.0.

Anybody wants to debug this?

glintik avatar May 29 '23 11:05 glintik

Same here, high CPU usage, MacOS version 13.3.1. M1. Compass version 1.37.0

slavag avatar Jun 13 '23 16:06 slavag

Why isn't this fixed till now? Experiencing the same high CPU usage

abdimussa87 avatar Jul 07 '23 09:07 abdimussa87

What kinds of percentages are you all seeing? Is it significantly different to slack or vscode's renderer processes?

lerouxb avatar Jul 13 '23 14:07 lerouxb

Is it significantly different to slack or vscode's renderer processes?

Slack, Discord, Teams, and two instances of vscode combined use less than compass alone on my machine.
The only one that comes close to the background usage of compass is Chrome with a shit load of tabs and extensions.

dumbasPL avatar Jul 13 '23 15:07 dumbasPL

Hi @dumbasPL! Thank you for confirming. It would be super helpful if you could also answer the following:

  • Are these occasional usage spikes or is Compass consistently on high CPU usage?
  • Does keeping Compass idle (both connected to a cluster and not), still reports the same CPU usage?

himanshusinghs avatar Jul 13 '23 15:07 himanshusinghs

Are these occasional usage spikes or is Compass consistently on high CPU usage?

Occasional spikes on the renderer process are a normal thing and will happen in any electron app when there are changes being made. The problem is that there are no (visible) changes being made but both the renderer and gpu-process processes are constantly eating CPU cycles even where there is seemingly nothing happening.

Does keeping Compass idle (both connected to a cluster and not), still reports the same CPU usage?

While connected yes. It's a constant ~9% or so for me. No matter what tab I'm on, even when connected to an empty database.

While disconnected, it drops down to a near-perfect 0% on idle, just like any other electron app.

So my guess is that there is maybe some sort of animation or some other thing that is constantly updating the DOM that's causing this. If you are actually interested in fixing this then I could profile it and figure out exactly what's causing this.

dumbasPL avatar Jul 13 '23 16:07 dumbasPL

Compass eats ~30% of CPU on Apple M1 Max even sitting in background. Starts eating CPU after some time, can be hours or days. Do you want some profiles or charts? I can record it from DevTools.

glintik1 avatar Jul 13 '23 16:07 glintik1

My experience is very similar to @dumbasPL. Definitely higher CPU usage than the other big name Electron apps.

Also agree that when not connected to a cluster the CPU usage is not an issue, but as soon as I make a connection the CPU usage on the renderer process will hover around ~10% consistently. Then as soon as I open up a collection in a tab the CPU will jump and remain at around ~20% CPU usage.

I would expect the CPU to use a few extra resources while fetching and displaying a collection initially, but once the collection is in view I would think there is nothing to be done as it's not like the Compass UI "auto refreshes" or anything similar to that. I assume, once the data has been fetched, it's a static view that won't change until another button is pressed and shouldn't use many resources?

MitchellCash avatar Jul 14 '23 16:07 MitchellCash

I'm seeing this exactly on Linux (Fedora 38, 6.3.12-200.fc38.x86_64).

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
231291 tomer 20 0 36.7g 195680 61680 S 21.3 1.6 30:15.77 MongoDB Compass

tomerb avatar Jul 19 '23 12:07 tomerb

Still seeing this. Using between 10 and 25% cpu in the background.

MacOS, Compass Version 1.40.4

ff-charles-mccrary avatar Oct 31 '23 15:10 ff-charles-mccrary

An update on this one, we managed to isolate the issue and we will work on a fix soon.

mcasimir avatar Nov 08 '23 07:11 mcasimir

... opened this issue on Jun 28, 2022 oh no. Guess what, I have the same issue on M1 Mac, OS version 14.1.1

vermi321 avatar Jan 03 '24 19:01 vermi321

Hi @vermi321! Could you please confirm what version of Compass are you using? We released a fix for this issue in v1.41.0 (check here for the release notes). Thank you.

himanshusinghs avatar Feb 08 '24 12:02 himanshusinghs

I still have the same issue, using a MacBook Air M2 When I let it Idle, not using Mongo it used up to 99% and make my Mac go hot hot hot Currently using V1.43.0

Anlele1701 avatar May 19 '24 15:05 Anlele1701