# An empty project consumes a lot of CPU time

**URL:** <https://forum.defold.com/t/an-empty-project-consumes-a-lot-of-cpu-time/72576>\
**Category:** Questions\
**Created:** [February 3, 2023, 7:07am UTC](https://forum.defold.com/t/an-empty-project-consumes-a-lot-of-cpu-time/72576 "2023-02-03T07:07:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![osov](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/osov/32/31140_2.png) [@osov](https://forum.defold.com/u/osov)\
**Post date:** [February 3, 2023, 7:07am UTC](https://forum.defold.com/t/an-empty-project-consumes-a-lot-of-cpu-time/72576/1 "2023-02-03T07:07:27Z")

</div>

Hey guys, I’m asking for your help.  
I run an empty project on Windows, it consumes 8% -10% CPU. I do a headless assembly, the results are the same.  
I made a headless assembly on Linux, I run it on a simple VPS, it consumes 94-100%.  
How can I change the build headsles frequency?  
Tried Vsync, Update frequency, fixed update frequency. nothing changes the load. what am I doing wrong ?  
I see the load values in the task manager (% above), as well as through the profiler.get\_cpu\_usage() method.  
Defold 1.4.2 (latest)  
[Headless.zip](https://forum.defold.com/uploads/short-url/cPIh0yr42fhKobwWlWFpy7yaNCS.zip) (1.8 KB)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 3, 2023, 9:56am UTC](https://forum.defold.com/t/an-empty-project-consumes-a-lot-of-cpu-time/72576/2 "2023-02-03T09:56:58Z")

</div>

> [@osov](#):
>
> I run an empty project on Windows, it consumes 8% -10% CPU. I do a headless assembly, the results are the same.

> [@osov](#):
>
> I made a headless assembly on Linux, I run it on a simple VPS, it consumes 94-100%.

Are you sure the Windows numbers are the same when comparing a normal and a headless build? I would expect you to see the same high CPU values on the Windows build in headless mode.

Headless builds run as fast as possible since there is no vsync to wait for. And with vsync disables you can use the update frequency to control how many update()s you get per second. But the engine will still run at a high speed which explains the high CPU usage.

I’m not sure how well the main loop of the engine is designed to actually really sleep in between updates. @JCash will be able to provide some input here. I totally understand that the needs in a headless build are different from a normal build, especially if the intention is to run the headless build on a cloud server, possibly also running multiple instances on a single machine.

---

<div class="post-metadata">

**Author:** ![osov](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/osov/32/31140_2.png) [@osov](https://forum.defold.com/u/osov)\
**Post date:** [February 3, 2023, 10:37am UTC](https://forum.defold.com/t/an-empty-project-consumes-a-lot-of-cpu-time/72576/3 "2023-02-03T10:37:04Z")

</div>

> [@britzl](#):
>
> Are you sure the Windows numbers are the same when comparing a normal and a headless build? I would expect you to see the same high CPU values on the Windows build in headless mode.

Yes, the load is the same in both cases.  
Perhaps the load is not maximum due to the fact that I have 12 cores my PC.  
And on the VPS 1 core.

> [@britzl](#):
>
> if the intention is to run the headless build on a cloud server, possibly also running multiple instances on a single machine.

Yes, this is a very important thing.

PS  
I think I found a suitable function that can be called directly from lua - socket.sleep. Is it suitable for headless builds?

---

<div class="post-metadata">

**Author:** ![aglitchman](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/aglitchman/32/19432_2.png) [@aglitchman](https://forum.defold.com/u/aglitchman)\
**Post date:** [February 4, 2023, 12:28pm UTC](https://forum.defold.com/t/an-empty-project-consumes-a-lot-of-cpu-time/72576/4 "2023-02-04T12:28:12Z")

</div>

> [@osov](#):
>
> I think I found a suitable function that can be called directly from lua - socket.sleep. Is it suitable for headless builds?

Set the software-limited update frequency in the game settings to limit amount of updates per seconds. It works well.

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/d/7/d735cde45f87783d818bf1a7b2850191a3bb2456.png)

However, on my PC and in this mode the headless build still consumes 100% of the single CPU core, yes.
