Hi there!
I supposed that setting display.update_frequency=5
will call update(self, dt)
5 times per second which should limit CPU usage but it does not!
Actually update(self, dt)
called 1 time per second and CPU used about 70-100%. Same behavior I see on setting any number to display.update_frequency
except 0 which works as expected!
Working solution to limit CPU usage and adjust frequency of update(self, dt)
calls are below:
- I added some other params to
display
and maybe smth. is wrong
-- file: game_server.settings
[display]
width = 1136
height = 640
variable_dt = 0
vsync = 0
swap_interval = 0
frame_cap = 0
update_frequency = 0
-- VPS: Ubuntu 22.04.4 LTS(architecture: amd64)
-- Running headless defold engine(v1.9.3) inside docker container with ubuntu image
-- sleep timeouts:
-- 0.1(100ms): update called 8 times per second
-- 0.05(50ms): update called 17 times per second
-- 0.03(30 ms): update called 28 times per second
-- Without docker updates should be more frequent and CPU usage should be less!
local sleepTime = 0.03
function update(self, dt)
local current_time = os.date("%Y-%m-%d %H:%M:%S")
log(current_time, "update", dt)
if sleepTime > 0 then
-- this limits CPU usage on VPS
os.execute("sleep " .. tonumber(sleepTime))
end
checkDataRecievedFromClientSocketAndSendResultBack(dt)
end