Skip to content

Investigate Mac CPU issues issues #9490

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

Closed
jrainville opened this issue Feb 8, 2023 · 3 comments
Closed

Investigate Mac CPU issues issues #9490

jrainville opened this issue Feb 8, 2023 · 3 comments
Assignees
Labels
Milestone

Comments

@jrainville
Copy link
Member

Description

On Mac, users experience a crazy amount of CPU usage, even with the app in the background, whereas Linux and even Windows don't have that issue.

The only 2 things that come to mind that are different on Mac are the Frame (to have the Mac buttons and such at the top), and the OS notifications (we have custom DOtherSide code for those on Mac).

Try to comment those out and see if the app still uses as much CPU in the background. We are aiming for close to 0 when the app is in the background and no messages are being received.

The goal of this issue is just to get information. We can decide after what to do with those depending on the findings.

@borismelnik
Copy link
Contributor

@jrainville I test it and seems like it doesn't help :(
There is maybe a problem with Qt specifically in current platform implementation. We can fix it if we start using analyzer tools for app. I tried to run it with Xcode analyzer but failed - it stuck on running state or after attaching to running process.
One think in OS notifications code looks weird:
`
void OSNotification::showNotificationMacOs(QString title, QString message,
QString identifier)
{
if (!m_notificationHelper)
return;

NSUserNotification* notification = [[NSUserNotification alloc] init];
notification.title = title.toNSString();
notification.informativeText = message.toNSString();
notification.soundName = NSUserNotificationDefaultSoundName;
notification.hasActionButton = false;
notification.identifier = identifier.toNSString();

NSUserNotificationCenter* center = NSUserNotificationCenter.defaultUserNotificationCenter;
center.delegate = m_notificationHelper->delegate;
[center deliverNotification:notification];
[notification release];

}
`

there center.delegate is initialized when every notification was shown, but I think its the same instance every time so no memory leaks.

Any new ideas? :)

@caybro
Copy link
Member

caybro commented Mar 2, 2023

@alexjba has a lot of good news here :)

@alexjba
Copy link
Contributor

alexjba commented Mar 3, 2023

I guess we're working on the same thing #8139
So these are my findings so far:

  1. ~90% of the CPU usage wile the app is in the background is consumed by status-go. I've shared some profiling data here [dogfooding] App uses constantly 50% CPU on mac m1 even in the background #8139 that can be analysed using Instruments.

  2. While the app is in foreground min 10% of CPU is consumed by the renderer. This usually happens when we animate things on the screen. Most common are the StatusChatInput cursor and the busy indicator in the message history.

  3. Now on the bright side, the app can be compiled natively for M1 and the performance is better. It was the first time I've seen the app consuming 7% CPU while actually using the app 🎉 . Usually I've seen it around 15-20%. One thing to note here is that the arm build I'm using is slowed down by the Address sanitizer. Unfortunately status-go will freeze with the normal nim compilation flags and the only workaround I've found is to enable the Address sanitizer. See runtime: Error related to runtime.open_trampoline in darwin/arm64 golang/go#48437

@borismelnik borismelnik moved this from In Progress to Iteration Backlog in Status Desktop/Mobile Board Mar 6, 2023
@github-project-automation github-project-automation bot moved this from Iteration Backlog to Done in Status Desktop/Mobile Board Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

5 participants