Page 1 of 1

Question about Factorio inner engine.

Posted: Wed Apr 17, 2019 8:21 am
by BandaMF
Hi there, my name is Mark, and I am currently working on my own open-source multiplayer Factorio/Rimworld like MMO in C++ (sounds weird, but trust me, it makes much more sense in-game). I read a lot of articles about how most of the engines handle a problem with STL (that is underperforming heavily, especially in MSVC implementation) in a way of re-inventing a wheel and making their own STL containers from ground up. Are you using STL, or you are reimplementing it. And if so, could you explain just a bit what are the benefits of doing that. I would really like to know what you, could tell me about this specific topic, and how did you approach it while working on one of the best optimized games I've seen there :D

Re: Question about Factorio inner engine.

Posted: Wed Apr 17, 2019 11:32 am
by Koub
[Koub] I've moved this to off topic.
Also, I encourage you to read (or at least to have a look to) all the FFF : a significant part of them contain insights on technical aspects.

Re: Question about Factorio inner engine.

Posted: Wed Apr 17, 2019 1:08 pm
by BlueTemplar
MSVC
If you're programming for Windows, you're part of the problem.

Re: Question about Factorio inner engine.

Posted: Wed Apr 17, 2019 1:25 pm
by xfir01
Image

Re: Question about Factorio inner engine.

Posted: Wed Apr 17, 2019 1:56 pm
by leadraven
How exactly containers could be bottlenecks? All operations have well known difficulty : O(1), O(logN), O(N). STL containers are simple as stick. They are very poorly designed, but not slow. What exactly do you need? Vector and map. If you are constantly removing elements from a middle of a vector, it's your fault. 99% performance issues are caused by incorrect use of containers, not their inner implementation.
People write their own containers if :
  1. They need specific architecture.
  2. They are students.
  3. They are stupid.
  4. For fun.
I've wondered Factorio's architecture, even reproduced it's skeleton. All it's optimization is about raw data and math, not data structures.
Good luck with your game, brudda!

Re: Question about Factorio inner engine.

Posted: Wed Apr 17, 2019 4:34 pm
by BlueTemplar
I said Windows, not PC...

Re: Question about Factorio inner engine.

Posted: Wed May 01, 2019 12:26 pm
by posila
BandaMF wrote:
Wed Apr 17, 2019 8:21 am
Are you using STL, or you are reimplementing it.
We use STL a lot (containers, filesystem, unique_ptr, optional, function ... we don't use algorithms much; we try to avoid variant for compilation speed), but we also have lot of custom containers. Most of them used to be boost containers, but we removed dependency on boost to speed up compilation and reimplemented containers we were using ourselves. Out of those the most important for us is probably IntrusiveList.

If you are starting a new project, you might want to look into existing "STL for games" implementations, for example EASTL.
It is easy to replace a container if it proves to be too slow for whatever reason, but it is really hard to change low level stuff. So I think it is important to figure out what your goals are early on (multithreading? autosaves on background? ...) so you don't design yourself into a corner.

And most important of all is to get stuff going and see progress and results quickly, otherwise you'll probably lose motivation and abandon the project.