CPU spike/performance issue  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Re: CPU spike/performance issue

Postby Mike.Sheen » Tue Jul 05, 2022 7:52 pm

This StackOverflow post suggests when using Process\% Processor Time you need to divide the percentage by the number of processors on the system.

So, changing this line:

Code: Select all
pct = Math.Round(pct, 2)

to this:
Code: Select all
pct = Math.Round(pct / System.Environment.ProcessorCount, 2)


and now when I madly move my mouse around in the screen, when Task manager shows me 1%, so does your console logger.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: CPU spike/performance issue

Postby perry » Wed Jul 06, 2022 10:30 am

Code: Select all
pct = Math.Round(pct / System.Environment.ProcessorCount, 2)

my console app is now only showing 30% of whats in task manager... 5% vs 15%. The magic number for me is 5.5 (8 core, 16 logical processors)

I can make it occur by simply moving the mouse around the inventory maintenance form - doing so and your app logs 29.x% CPU usage. In fact if any form is open, just moving the mouse will see that figure reported if you move the mouse around constantly for the 3 second sample window.

ok, interesting, is that because of the mouse events?
When I mouse rub inventory form, it is about 13% cpu from task manager.


However, I wasn't doing that during my testing yesterday. I simply had Jiwa sit on my 2nd screen (not minimized) and doing other things.

Edit: end user said he tested with no form, and it still does it.
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: CPU spike/performance issue

Postby Mike.Sheen » Wed Jul 06, 2022 11:41 am

perry wrote:ok, interesting, is that because of the mouse events?


I don't know for sure. The controls we have would handle their own mouse events, and then raise events up which we potentially handle as well - the only control I can think of which has a mouse move event handler is the grid to check whether or not the mouse had moved over a cell which is a drill down cell to change the icon to the drill down icon.

perry wrote:Edit: end user said he tested with no form, and it still does it.

I tested that scenario and found no significant cpu usage - even without dividing by the number of CPU's in the system. End users can be somewhat unreliable.

The CPU usage every 300 seconds might just be the .NET garbage collector or something.

If you think this is a significant enough problem, create a ticket on our helpdesk - we can then spend some time looking into this further.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: CPU spike/performance issue

Postby perry » Wed Jul 06, 2022 1:33 pm

So I tested on my local Jiwa client + demo DB + no plugin
It still jumps to 13-15% every 300s. There was no SQL transaction at all in my testing.

I dont believe this is a performance issue, unless all clients on a virtual machine server do this at the same time... which I dont know how to test/prove, yet.
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: CPU spike/performance issue  Topic is solved

Postby perry » Mon Aug 15, 2022 3:12 pm

Thanks to Mike, we found it is caused by ticking "Participate in Customer Experience Improvement Program" per user.

It is resolved after running below query and restarting Jiwa application
Code: Select all
UPDATE HR_StaffUserSettings
SET HR_StaffUserSettings.ParticipateInCustomerExperienceImprovementProgram = 0


I dont believe this is a performance issue, unless all clients on a virtual machine server do this at the same time... which I dont know how to test/prove, yet.

It is an issue if
- spike lasts more than few seconds (30+ seconds)
- multiple users shared the same virtual desktop server
basically so 1x% CPU usage overlapping between users
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: CPU spike/performance issue

Postby Mike.Sheen » Mon Aug 15, 2022 3:15 pm

There is still something off about the environment because I couldn't replicate what you were seeing.

In my observations I saw 1 or 2% CPU at random times - you showed me graphs of it at regular 300 second intervals and I still can't replicate that.

Have a work-around - which is great - but we're still no wiser as to what the root cause is.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: CPU spike/performance issue

Postby perry » Mon Aug 15, 2022 3:28 pm

in my observations I saw 1 or 2% CPU at random times - you showed me graphs of it at regular 300 second intervals and I still can't replicate that.


Weird... I have this consistent interval from all PCs (physical/virtual/server) I tested with.

There is still something off about the environment because I couldn't replicate what you were seeing.

Yes, that is the only place the spike last between 30-120 seconds.

P.S. we also found moving mouse cursor on maintenance form causes high cpu usage in the thread :twisted:
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: CPU spike/performance issue

Postby Mike.Sheen » Mon Aug 15, 2022 3:44 pm

perry wrote:Weird... I have this consistent interval from all PCs (physical/virtual/server) I tested with.


Actually - after paying closer attention I too saw CPU usage at the every 300 second mark - just nowhere near as pronounced. I also saw usage not at those time points, which confuses the issue.

I've tested with an updated version of the problem component and it uses some CPU after 300 seconds - but nothing afterwards. Logged as DEV-9511

perry wrote:P.S. we also found moving mouse cursor on maintenance form causes high cpu usage in the thread :twisted:


Were you moving it over a grid? Grids handle the mouse move event to see if the cell you're hovering over is a drill-down cell and changes the cursor to the hand cursor. We can probably improve things there to make it more efficient - logged as DEV-9515
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: CPU spike/performance issue

Postby perry » Mon Aug 15, 2022 4:07 pm

We're you moving it over a grid? Grids handle the mouse move event to see if the cell you're hovering over is a drill-down cell and changes the cursor to the hand cursor. We can probably improve things there to make it more efficient - logged as DEV-9515


nope, not just the grid. every form I open, e.g. staff maintenance -> Main tab

[img]
Screenshot%202022-08-15%20150557.png
[/img] even if I move mouse slowly in highlighted area will cause CPU to go up.
Attachments
Screenshot 2022-08-15 150557.png
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: CPU spike/performance issue

Postby Mike.Sheen » Mon Aug 15, 2022 4:14 pm

perry wrote:even if I move mouse slowly in highlighted area will cause CPU to go up.


Ok - absolutely nothing we can do about that - that's Windows. When you mouse the mouse some CPU is going to be used.

In my superficial testing just now I could get the CPU to 0.6% usage by moving the mouse on the Staff Maintenance form, on the area you indicated. I also saw the same behaviour with Word, Visual Studio and Edge.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

PreviousNext

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 42 guests

cron