Question about Factorio inner engine.

Things that are not directly connected with Factorio.
BandaMF
Manual Inserter
Manual Inserter
Posts: 1
Joined: Wed Apr 17, 2019 8:12 am
Contact:

Question about Factorio inner engine.

Post 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
Koub
Global Moderator
Global Moderator
Posts: 7918
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Question about Factorio inner engine.

Post 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.
Koub - Please consider English is not my native language.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3234
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Question about Factorio inner engine.

Post by BlueTemplar »

MSVC
If you're programming for Windows, you're part of the problem.
BobDiggity (mod-scenario-pack)
xfir01
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Fri Feb 10, 2017 5:08 pm
Contact:

Re: Question about Factorio inner engine.

Post by xfir01 »

Image
User avatar
leadraven
Filter Inserter
Filter Inserter
Posts: 354
Joined: Fri Jan 18, 2019 7:23 pm
Contact:

Re: Question about Factorio inner engine.

Post 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!
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3234
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: Question about Factorio inner engine.

Post by BlueTemplar »

I said Windows, not PC...
BobDiggity (mod-scenario-pack)
posila
Factorio Staff
Factorio Staff
Posts: 5408
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Question about Factorio inner engine.

Post by posila »

BandaMF wrote: Wed Apr 17, 2019 8:21 amAre 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.
Post Reply

Return to “Off topic”