#1300  Heavy client-side CPU usage
Released
Jerome St-Louis opened 1 year ago

In Chromium, with a single OneDev window up, a considerable amount of CPU (or GPU?) seems to be used. htop will show Chromium regularly jumping to one maxed out core every second or so. This is a major annoyance, because it causes my (extremely loud) laptop CPU fan to keep spinning full speed and is very noisy / distracting.

Trying to run the Chromium profiler seems to hint at WebSockets timers being fired every ~1 second as a potential cause. Whatever this is intended to be for (refreshing if someone else modifies issues?) is not anywhere close to being worth the deafening noise caused by this CPU usage.

Perhaps an option to turn off those timers or configure the delay to 30 second or one minute instead of 1 second would solve this problem?

Robin Shen commented 1 year ago

This is abnormal. OneDev does not call websocket every second. Are you able to create a sample database reproducing the issue and attach it here?

Jerome St-Louis commented 1 year ago

@robin Either it applies to all databases, or otherwise I'm afraid if I create a new database it will not suffer from the issue. My guess is that it is not specific to the database.

Please find below a couple screenshots from the Chromium performance profiling tab (10 seconds of profiling) that may help identify a potential problem. Note that the time spent seems quite small, but it seems to be regularly calling this setTimeout() with sendMessages in setupWebsocketCallback: function() {.

timers.jpg

code.jpg

It is possible that this has nothing to do with the seemingly heavy CPU usage... Perhaps this combined with the fact that Chrome/Chromium has become more and more of a CPU/GPU hog for no reason at all is why it gets my CPU hot and the fans spinning.

Unknown commented 1 year ago

In Chromium, with a single OneDev window up, a considerable amount of CPU (or GPU?) seems to be used. htop will show Chromium regularly jumping to one maxed out core every second or so. This is a major annoyance, because it causes my (extremely loud) laptop CPU fan to keep spinning full speed and is very noisy / distracting.

Trying to run the Chromium profiler seems to hint at WebSockets timers being fired every ~1 second as a potential cause. Whatever this is intended to be for (refreshing if someone else modifies issues?) is not anywhere close to being worth the deafening noise caused by this CPU usage.

Perhaps an option to turn off those timers or configure the delay to 30 second or one minute instead of 1 second would solve this problem?

I can't reproduce this issue, I have almost no CPU use while using Onedev, this could be an isolated incident.

I am using Firefox however, this might be isolated to V8 javascript runtime.

Jerome St-Louis commented 1 year ago

Thanks for looking into this @polarian. As per the screen caps above, the actual CPU time spent seems small, but some code seems to be executed every 4 milliseconds (not every second as I mentioned earlier, sorry). This might be enough to make the V8 engine to use enough CPU to cause my laptop CPU to heat up just enough to get the spans spinning loud. Every few seconds, I will see one Chromium thread showing at ~30% in htop.

Unknown commented 1 year ago

Well unfortunately I do not have anything to benchmark this against.

My laptop runs a ryzen 5500U, it is too powerful to notice small inefficiencies.

I do have a device with an intel core duo, so I might benchmark onedev's performance with both chromium and firefox and see if I can reproduce this.

Question: does this CPU spike happen on every page, or is there a specific page which it occurs on?

Thanks :)

Jerome St-Louis commented 1 year ago

@polarian Thank you. It seems to happen on every page, but I am noticing mainly on a kanban board with around 150 issues showing and 5 columns. It is a lot more noticeable on a laptop where things are more compact and heat up quickly. My laptop fan is spinning loudly right now trying to sort through issues.

Unknown commented 1 year ago

Hm,

I am not sure if this is possible to fix unfortunately.

The CPU use is probably the loading of all the issues into the board, unless server side processing is deployed, javascript is bound to heat up your laptop, especially during compute heavy tasks like fetching all the issues and arranging them on the board.

May I ask what CPU you have within your laptop?

Jerome St-Louis commented 1 year ago

@polarian I don't think the issue is because any loading is going on. The problem is CPU usage is being wasted doing nothing at all.

There is no reason whatsoever for CPU/GPU fans to be spinning when managing issues in a kanban board :)

Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz with 6 cores / hyper-threading.

I am not sure if this is possible to fix unfortunately.

I highly doubt that is the case. What I would like to test is if we can avoid or change the delay for this setTimeout() being executed, if this is indeed something that gets executed every 4 ms.

Unknown commented 1 year ago

Weird,

Your CPU is new enough it should not be an issue, have you tried other browsers?

If you can reproduce the issue on other browsers, then there is definitely something wrong with the javascript code causing idle executions.

Referenced from other issue 1 year ago
Jerome St-Louis commented 1 year ago

I seem to have the same issue with Firefox. See Firefox profiler that very clearly indicates there is a 4ms setTimeout handler:

oneDevHeavyClient.png

Unknown commented 1 year ago

Hm,

Well I guess this does warrant investigation then.

The thing is I do not have any CPU issues when executing this myself.

May I ask what operating system you are on? (It could be specific to the browser on the OS?)

Even with the timeout handler is causing slow page loads, it shouldn't eat your CPU (it doesn't for me)

Jerome St-Louis commented 1 year ago

@polarian it is not at all about loading pages, it is when OneDev is just sitting there doing nothing, firing this timer every 4 ms.

I'm on Linux 6.1.12-artix1-1.

Well I guess this does warrant investigation then.

Likely because you either have a cool CPU or silent fans :) As I mentioned it doesn't show as high CPU usage, but it's just high enough to keep the fans spinning.

Unknown commented 1 year ago

Hm... weird

I do not know why you get this issue and I don't.

I will profile it myself to see if the delay is there too, but I do not get any single core CPU load which maxes out and heats up my laptop, I sit at 31C using Onedev.

Robin Shen commented 1 year ago

There did exist a bug calling a function indefinitely. Thanks for all your investigations.

Robin Shen changed fields 1 year ago
Name Previous Value Current Value
Type
Discussion
Bug
Affected Versions
empty
<=8.0.14
OneDev changed state to 'Closed' 1 year ago
Previous Value Current Value
Open
Closed
OneDev commented 1 year ago

State changed as code fixing the issue is committed (adf69ec6)

Referenced from commit 1 year ago
Robin Shen referenced from other issue 1 year ago
OneDev changed state to 'Released' 1 year ago
Previous Value Current Value
Closed
Released
OneDev commented 1 year ago

State changed as build #3540 is successful

issue 1 of 1
Type
Bug
Priority
Normal
Assignee
Affected Versions
<=8.0.14
Issue Votes (0)
Watchers (4)
Reference
onedev/server#1300
Please wait...
Page is in error, reload to recover