Recent

Author Topic: Application produces high CPU load. Can I reduce it?  (Read 2959 times)

DragoRosso

  • Guest
Re: Application produces high CPU load. Can I reduce it?
« Reply #30 on: January 30, 2025, 09:54:27 am »
There is something strange in those numbers...

Presuming a sleep time of 1ms done 100 times for each file and there are 100 files, the total time sleeping is approximately 1ms * 100 * 100 div 1000ms/sec = 10 seconds.

Therefore, if without sleep the app takes 5 seconds then with sleep(1), it should take about 15 seconds, not 50.
You are overestimating the functionality of sleep. As long as you do not use "TimerBeginPeriod", sleep(1) can occur in the range between 0.5 and 16 ms. So the increased time between the ideal 15 s. and the real 50 s. is justified. Statistically speaking, I see that sleep(1) gives a timeslice between 3 and 7 ms., rarely more than 10 ms.
« Last Edit: January 30, 2025, 10:12:10 am by DragoRosso »

alpine

  • Hero Member
  • *****
  • Posts: 1372
Re: Application produces high CPU load. Can I reduce it?
« Reply #31 on: January 30, 2025, 10:18:00 am »
@Vodnik
Apart from the Sleep(1) stuff - have you tried to put your updates into an explicit sqlite3 transaction? My recent reviewing of the LCL sources (sqlite3conn.pp) showed me that most likely it will have a serious impact on the speed of the updates execution.

It's really an easy try.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

440bx

  • Hero Member
  • *****
  • Posts: 5068
Re: Application produces high CPU load. Can I reduce it?
« Reply #32 on: January 30, 2025, 10:21:07 am »
All the calculations _obviously_ considered the resolution to be high. 

High or not, the numbers are still out of whack because if the time goes from 5 to 50 seconds the decrease in CPU time should be much larger than 25%.  The other problem is that the numbers he shows are system global instead of per thread. 

The drop in CPU load should be close to inversely proportional to the increase in time and it obviously isn't indicating that the numbers are not representative.

In a nutshell, the CPU usage should be roughly 1/10 of what it originally was and it isn't thus indicating a problem in the measurements given. 

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Packs

  • Sr. Member
  • ****
  • Posts: 476
Re: Application produces high CPU load. Can I reduce it?
« Reply #33 on: January 30, 2025, 11:13:13 am »
These files will be fix format file

 

TinyPortal © 2005-2018