# Thread are slower in cooked game

**URL:** <https://forums.unrealengine.com/t/thread-are-slower-in-cooked-game/463467>\
**Category:** Debugging, Optimization, & Profiling\
**Tags:** Cooking, threads, unreal-engine, Performance, bug-report, question\
**Created:** [April 8, 2020, 3:17am UTC](https://forums.unrealengine.com/t/thread-are-slower-in-cooked-game/463467 "2020-04-08T03:17:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![azukaar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@azukaar](https://forums.unrealengine.com/u/azukaar)\
**Post date:** [April 8, 2020, 3:17am UTC](https://forums.unrealengine.com/t/thread-are-slower-in-cooked-game/463467/1 "2020-04-08T03:17:05Z")

</div>

When executing a simple C++ loop in a FRunnable in the game like so, the performance are widely different from the uncooked game (Whether it’s in editor, or in right click\>launch game standalone) and cooked (whether the game is packaged or not). I have observed around 50% difference, which is massive, it seems for some reason the thread is code is executing slower when the cooked game runs…

link to code : [class ThreadChunk : public FRunnable {public: bool bAlive = true; - Pastebin.com](https://pastebin.com/7Ryt5tgJ)

Preview :

 ![299273-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/6/0a6b289167bdc9a47c514b55efaff12b41f539f6.png)

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [April 11, 2020, 9:19pm UTC](https://forums.unrealengine.com/t/thread-are-slower-in-cooked-game/463467/2 "2020-04-11T21:19:39Z")

</div>

This is kind of hard to take it as a valid test in UE4 you suppose to use UE4 API. Can you try to do the same with FDateTime, TArray, FMath and potentially with UE4 stat system:

> **[Stats System Overview](https://docs.unrealengine.com/5.1/en-US/unreal-engine-stats-system-overview/)**
>
> The Stats System collects and displays performance data to help optimize Unreal Engine projects

You can also use Unreal Insights:

> **[Unreal Insights](https://docs.unrealengine.com/5.1/en-US/unreal-insights-in-unreal-engine/)**
>
> Profile your project with Unreal Insights

Anyway UE4 is out of control of your thread when your code loop, it does not got thru any control code aspecially as you use C++ standard API UE4 is complitly unaware what are you doing in that thread. OS is one deciding when and how it is executed on CPU or else UE4 telling OS to do something with it, so it’s either that that or compilationconfiguration diffrence makes something

Also make sure to do run on both Development build and Shipping build as both are complitly diffrent builds on UE4

---

<div class="post-metadata">

**Author:** ![azukaar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@azukaar](https://forums.unrealengine.com/u/azukaar)\
**Post date:** [April 12, 2020, 9:21pm UTC](https://forums.unrealengine.com/t/thread-are-slower-in-cooked-game/463467/3 "2020-04-12T21:21:48Z")

</div>

Hello,  
Closing the thread as I have figured it out.  
Essentially, my threads were using std:: stuff, and for some reason, thoses stuff were a lot slower on threaded versions. In editor, somehow, it seems the UE **does** definitly change the way threads works, since they act closer to what single threads would look like (just look at how low your CPU usage is, regardless of thread count) so the multithread issue with std wouldnt be such a problem. I believe this might be because of the single process simulated when you play in editor.

Moving to Txxxx did fix my issues, since those work well regardless of thread count.

Thanks for your help
