logseq / logseq

A privacy-first, open-source platform for knowledge management and collaboration. Download link: http://github.com/logseq/logseq/releases. roadmap: http://trello.com/b/8txSM12G/roadmap
https://logseq.com
GNU Affero General Public License v3.0
30.26k stars 1.77k forks source link

Constant CPU usage, relatively high #9963

Open hmijail opened 10 months ago

hmijail commented 10 months ago

Search first

What Happened?

I've seen other issues about high occasional CPU usage. What I'm seeing is rather constant CPU usage, even though at a lower level: >15% (across the various logseq processes) after just scrolling down my journal, >5% after just restarting the app but just leaving it in the background without touching it (why not ~0%?), and about 0.5% when it's idle and hidden (why not 0%?).

I'm relatively new to logseq: I have only a couple dozen journal entries and a couple of pages, so it's concerning that even now it's consuming CPU just to stay open.

Reproduce the Bug

  1. Open logseq with a few journal entries, don't touch it anymore

Expected Behavior

CPU should go down to ~0% after a few seconds.

Screenshots

No response

Desktop or Mobile Platform Information

macOS 13.4.1 (c) logseq Version 0.9.11 (64) - Current Revision: 5cab221

Additional Context

No response

Are you willing to submit a PR? If you know how to fix the bug.

hmijail commented 10 months ago

Profile recorded after just starting logseq. During the 15 seconds recorded, I didn't do anything. Activity Monitor showed about ~10% CPU usage. Profile-20230801T133044.json.zip

andelf commented 10 months ago

This might be an issue in the main thread. Could you check ~/Library/Logs/logseq/main.log?

This should be resolved by "Clear Cache".

hmijail commented 10 months ago

Could you check ~/Library/Logs/logseq/main.log?

Sure, but what should I do with it? There's no entries during the time that I recorded that trace. In fact looks like there's only entries when there was some change being synced or some check for logseq updates.

hmijail commented 10 months ago

I used the "Clear cache" option. It was scary that it made me re-choose my graph folder and log in again. I'd suggest that "clear cache" isn't the best description - that sounds like it'd be rather inocuous.

Anyway, after a couple of minutes of idling Lgseq Helper (Renderer and GPU) still show >5% CPU, with occasional additional >5% GPU. This is even if I don't see anything animated in Logseq, not even a text cursor.

Screenshot 2023-08-01 at 4 11 40 pm
hmijail commented 10 months ago

I last typed something into Logseq about 3 hours ago; since then it's been idle. I just realized that right now Logseq is the app using the most CPU on my computer (~25% CPU, ~10% GPU). That's higher than Firefox with >500 tabs open!

New profile recording while doing nothing: Profile-20230802T175345.json.zip

hmijail commented 10 months ago

Yesterday Logseq updated to 0.9.13 - revision 4b4b4e8.

The CPU/GPU usage seems to have improved a lot, though it's still high for an idle program: after some idle hours, it's currently using about ~5% CPU constantly, with some peaks of ~1% GPU.

New profile recording while doing nothing: Profile-20230804T083416.json.zip

QasimK commented 10 months ago

I'd also like to chip in with another reproduction. As soon as I open Logseq, it hits 100% CPU usage (one core) and just stays like that... seemingly forever. I have to close it with kill -9 as it's very difficult to do anything. Sometimes I manage to open it without this issue.

cnrpman commented 9 months ago

@hmijail I can't see any spike of cpu usage in the reported profile.

I guess it's some corner case related to installation / hibernation. Usually restarting app could fix.

hmijail commented 9 months ago

Today Logseq's processes are taking a constant ~20% CPU and ~10% GPU even though I didn't touch it for a couple of hours and nothing seems to be animated. Profile-20230814T150243.json.zip

image
kerim commented 9 months ago

Logseq CPU usage is just terrible. I suspect that this won't be fixed until the database version comes out? I really hope that solves the problem. Below is high usage vs. normal background usage from today.

Screenshot 2023-08-15 at 9 39 21 AM Screenshot 2023-08-15 at 10 10 35 AM
bartv42 commented 9 months ago

I just noticed that on my system (Linux), I have constant 5-10% CPU use when idling on my Journals page. As soon as I select any other page, the load drops to zero. Hope that helps zero in on the issue!

Edit: upon looking a little deeper, it looks like 'simple' pages idle correctly at 0%, but pages that contain queries (like the TODO page) show the constant cpu load during idling. I hope I'm explaining myself correctly, I'm still rather new to logseq terminology.

kerim commented 9 months ago

Seems like things are better with the latest nightly (0.9.13-nightly, caf1d9d-dirty) build? I'm now seeing background CPU usage of between 0.0 and 0.5. It jumps to 25-30% when the app is loaded, yes, but background use seems much better.

Curious whether or not it still has the problem of occasional very high usage? Will monitor that as well.

kerim commented 9 months ago

Now on 0.9.14 and it seems even better - when Logseq is active it is more like 15% (as opposed to 25%). Note that is just when the app is brought to the front. I still haven't measured use while actively editing in the app.

bartv42 commented 9 months ago

I just installed 0.9.14 and idle CPU use hasn't improved for me; still between 5-10% on the Journals page and 0% on other pages.

To add to my report: CPU drops to 0% in all cases when I minimize the app. The idle CPU use occurs when the window loses focus.

moonlitknight commented 6 months ago

To add my notes... Idle Logseq 0.10.0 (no plugins) on Ubuntu uses 25% CPU when the app window is maximised. This is not acceptable. NB. The CPU drops to 0% if the app window is minimised. I did a quick strace of the two Logseq processes and they are constantly sending IPC messages between themselves. HTH

hmijail commented 5 months ago

Logseq 0.10.1(75) consumes 10-15% CPU just by idling on the "Journals" page. About 5% if on the "All pages" page. I tried recording a profile as I did in the past to post it here, but now profiles fail to save - they end up with size 0 and a warning & error appear in the Console:

DevTools failed to load source map: Could not load content for file:///Users/mija/Applications/Logseq.app/Contents/Resources/app/js/interact.min.js.map: Unexpected end of JSON input Failed to save timeline: The request is not allowed by the user agent or the platform in the current context. (NotAllowedError)

Things aren't improving, are they?

moonlitknight commented 5 months ago

@hmijail Have you tried minimizing the window and seeing if the CPU usage drops? For me, it does and just about makes it usable. Without this workaround I'd be forced to abandon Logseq

Logseq 0.10.1(75) consumes 10-15% CPU just by idling on the "Journals" page. About 5% if on the "All pages" page. I tried recording a profile as I did in the past to post it here, but now profiles fail to save - they end up with size 0 and a warning & error appear in the Console:

hmijail commented 3 months ago

Logseq 0.10.5 still consumes 10% CPU while idling in the Journals page, 5% when on a single day page without queries. If I close the window it consumes 1% (which still is bad, why not 0%?).

It still allows me to create a perforamnce profile, but now the save button doesn't even react, so can't post it here. Doesn't look like devs pay attention anyway.

@moonlitknight having to minimize so that it doesn't eat battery uselessly is bad. Even more in an app that was supposed to be there to catch your thoughts at any moment.

bartv42 commented 3 months ago

Same for me. I'm a paying supporter now, but I'm considering abandoning logseq for this reason. I use it mainly on my laptop and it always makes it run hot/use up my battery way too fast - hate it.

On Mon, Feb 5, 2024 at 2:56 AM Horacio Mijail Antón Quiles < @.***> wrote:

Logseq 0.10.5 still consumes 10% CPU while idling in the Journals page, 5% when on a single day page without queries. If I close the window it consumes 1% (which still is bad, why not 0%?).

It still allows me to create a profile, but now the save button doesn't even react, so can't post it here. Doesn't look like devs pay attention anyway.

@moonlitknight https://github.com/moonlitknight having to minimize so that it doesn't eat battery uselessly is bad. Even more in an app that was supposed to be there to catch your thoughts at any moment.

— Reply to this email directly, view it on GitHub https://github.com/logseq/logseq/issues/9963#issuecomment-1926087766, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUAFVLTFWCEDMRLSIDMTX3YSA33HAVCNFSM6AAAAAA27ECHY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRWGA4DONZWGY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

andelf commented 3 months ago

Thanks for the report.

bartv42 commented 3 months ago

I'm on Linux (Pop!_OS). Happy to provide a recording, but I'll need some guidance.

On Mon, Feb 5, 2024 at 8:57 AM Andelf @.***> wrote:

Thanks for the report.

  • On Windows, high CPU usage might be caused by Windows Defender
  • On other platforms, a performance recording with Developer tools will be helpful to diagnose the performance issue

— Reply to this email directly, view it on GitHub https://github.com/logseq/logseq/issues/9963#issuecomment-1926408734, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUAFVPFMDCAZOR3JY2PZKDYSCGGFAVCNFSM6AAAAAA27ECHY6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRWGQYDQNZTGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

hmijail commented 3 months ago

@andelf , as I already said, performance recordings don't seem to work.

I posted a couple of recordings back in August, but as of my comment of Dec 8 for Logseq 1.10.1, the recording was saved as a 0 byte file with errors in the console, and in current Logseq 1.10.5 the save button doesn't do anything when clicked.

andelf commented 3 months ago

@hmijail The screen shot of the result flamegraph is also helpful.(with zoomed view to the tallest and most time-consuming calling tree)

Thanks for the detail. It seems to be an Electron bug. I'll check if the upstream has the fix.

hmijail commented 3 months ago

So it's been broken for at least 2 months and only now was noticed?

I don't see a way to generate flamegraphs in the current version. Here's the screenshot I thought was most informative.

Screenshot 2024-02-05 at 8 37 37 pm
hmijail commented 3 months ago

(That was captured with the main window closed. Before recording, CPU usage was about 2% in total across all the Logseq processes. While recording, the total was about 15%).

hmijail commented 3 months ago

New Logseq version (0.10.6), new try. Logseq window open on the Journals page, idling. CPU usage across Logseq processes totalled 10-15%.

The saving button for recordings still doesn't work, so here's a screenshot of the performance recording. The screenshot seems to show about 2% of non-idling, vs the >10% shown in macOS' Activity Monitor. So I find it hard to believe that a screenshot like this is useful - please confirm.

And I just learnt that Chrome devtools don't have flame-graphs, only frame-charts. Oh well.

Screenshot 2024-02-06 at 11 01 36 am
hmijail commented 3 months ago

Zooming into one of the tallest "icicles"...

Screenshot 2024-02-06 at 11 07 43 am
shyney7 commented 3 months ago

Same problem logseq is just minimized and doing nothing and Im getting a cpu load of over 20% grafik

There is already a pull request to minimize cpu load but is not being reviewed for over 6 months: https://github.com/logseq/logseq/pull/10037

lightproof commented 2 months ago

Same issue here with (currently latest) 0.10.7 on Linux (Fedora 39). While Logseq is running, it's idle CPU use eventually creeps up to a constant of 15-20%. Minimizing the window lowers the CPU load to essentially 0%. After Logseq restart, it's initial idle CPU use is 1-3%, but but begins to creep up again after some time/use.

It looks like the #10037 was eventually merged and ended up in 0.10.7, yet the problem still exists.