Friday Facts #322 - New Particle system

Regular reports on Factorio development.
User avatar
FactorioBot
Factorio Staff
Factorio Staff
Posts: 249
Joined: Tue May 12, 2015 1:48 pm

Friday Facts #322 - New Particle system

Post by FactorioBot » Fri Nov 22, 2019 12:42 pm


User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 531
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by Gergely » Fri Nov 22, 2019 12:46 pm

Klonan wrote:we will not be doing any more 0.17 releases
:roll: Okay then...

Guess we don't get the better fluid physics.
Last edited by Gergely on Fri Nov 22, 2019 12:56 pm, edited 2 times in total.

Melerion
Burner Inserter
Burner Inserter
Posts: 5
Joined: Wed May 17, 2017 8:11 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by Melerion » Fri Nov 22, 2019 12:52 pm

Not sure if it has been previously discussed or not, but ...

Did you ever consider having certain API interfaces marked as deprecated when you replace them, with the "old" one being a wrapper to the new solution, and (optionally) maybe generate a one time notice on map load if that can be easily done.
That would not immediately break a number of mods but allow them to migrate in an orderly fashion.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 3964
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by Klonan » Fri Nov 22, 2019 12:56 pm

Gergely wrote:
Fri Nov 22, 2019 12:46 pm
Klonan wrote:we will not be doing any more 0.17 releases
:roll: Okay then...

Guess we don't get the better fluid physics.
Not in 0.17 at least

MrBuisson
Inserter
Inserter
Posts: 20
Joined: Sat Feb 04, 2017 9:08 am
Contact:

Re: Friday Facts #322 - New Particle system

Post by MrBuisson » Fri Nov 22, 2019 12:57 pm

Guys, I loved this last update on particules. I was wondering what send my framerate from 10FPS all the way up to 50FPS. Now I know. My base has quite long walls with many, many flame throwers (40k unit) in death world setting. Bitter dies so often that the stats are smothed out :twisted:
I tough first it was the fluid update, but it's great to get this one latter on top of the other.

well, I now I have to expand enough to reclaim my 40FPS voucher
Last edited by MrBuisson on Fri Nov 22, 2019 1:00 pm, edited 1 time in total.

Linver
Inserter
Inserter
Posts: 47
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by Linver » Fri Nov 22, 2019 12:59 pm

Do u have an available estimation of 0.18 release and/or the category of mod API that will be changed?

Yehn
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Tue Jul 12, 2016 3:45 am
Contact:

Re: Friday Facts #322 - New Particle system

Post by Yehn » Fri Nov 22, 2019 1:02 pm

I like playing with (sometimes very large amounts of) biters, so I'm guessing this will help performance when under heavy siege, or doing heavy siege-ing, or pretty much time there's a lot of effects going off. Great to hear.

User avatar
Lubricus
Fast Inserter
Fast Inserter
Posts: 239
Joined: Sun Jun 04, 2017 12:13 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by Lubricus » Fri Nov 22, 2019 1:03 pm

Isn't particles usually some sort of shaders that only lives in the graphics card? And thus use no CPU power nor RAM.

Rseding91
Factorio Staff
Factorio Staff
Posts: 10019
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Friday Facts #322 - New Particle system

Post by Rseding91 » Fri Nov 22, 2019 1:27 pm

Melerion wrote:
Fri Nov 22, 2019 12:52 pm
Not sure if it has been previously discussed or not, but ...

Did you ever consider having certain API interfaces marked as deprecated when you replace them, with the "old" one being a wrapper to the new solution, and (optionally) maybe generate a one time notice on map load if that can be easily done.
That would not immediately break a number of mods but allow them to migrate in an orderly fashion.
Deprecation doesn't work. In my 4.5~ years on Factorio not once have I seen any function or API marked as deprecated actually have any effect except to add more complication to the programmer that has to mark it as such.

The only thing that works is to just delete the old one and provide the new one at the same time. Otherwise everyone just keeps using the old one because "it works, why would I spend the time to switch over?"
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 10019
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Friday Facts #322 - New Particle system

Post by Rseding91 » Fri Nov 22, 2019 1:28 pm

Lubricus wrote:
Fri Nov 22, 2019 1:03 pm
Isn't particles usually some sort of shaders that only lives in the graphics card? And thus use no CPU power nor RAM.
Particles in Factorio can spawn other particles, other entities, smoke, do damage, and so on. They couldn't ever just live in render-only land. Also, you still have to spend CPU time and RAM to tell the GPU what to do so it's never possible to "use no CPU por nor RAM".
If you want to get ahold of me I'm almost always on Discord.

NIronwolf
Burner Inserter
Burner Inserter
Posts: 18
Joined: Sat Jul 07, 2018 6:44 am
Contact:

Re: Friday Facts #322 - New Particle system

Post by NIronwolf » Fri Nov 22, 2019 1:35 pm

So no more push on 0.17. Guess it's time to concentrate on finishing out this modded playthrough since everything has settled for a while. :D

Although, I've been anticipating the UI updates so that expectation is tempered now.

Great work on optimizations! Potatoes everywhere thank you!

PacifyerGrey
Smart Inserter
Smart Inserter
Posts: 1044
Joined: Wed Jun 29, 2016 10:02 am
Contact:

Re: Friday Facts #322 - New Particle system

Post by PacifyerGrey » Fri Nov 22, 2019 1:55 pm

After all these years it is really nice to see you guys carefully shape your masterpiece!
Kudos to a master optimizer Rseding as always rocking this side of Factorio

User avatar
ledow
Long Handed Inserter
Long Handed Inserter
Posts: 90
Joined: Sat Sep 24, 2016 3:00 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by ledow » Fri Nov 22, 2019 2:30 pm

1 x Global List/Array/whatever of pointers to all entities, each with a type inside it.
1 x List/Array/whatever for each "type" of entity that needs to be handled separately, stored as a set of pointers to each of those entities.

Even for a thousand particles, the memory overhead is pathetic - basically an "extra" list of ~1000 pointers to the same entities if you do it right.
When you want to iterate over particles only, you can do without having to go through every entity in the global list.
When you want to pathfind / whatever, you only iterate over the pathfind-affecting lists of entities.
When you want to draw everything, you iterate over the global list.

You're not storing entities twice (there may be a pointer to them in multiple lists, sure, but only one copy of the entity "structure/class"), your iterations are linear and don't have to interrogate every entity to see if it's the right type. And with just two helper functions to add / remove an entity which add it or remove it from all the appropriate lists that it should be in and stitches the lists back together, and which you call whenever you change/create/destroy an entity so they don't get out of sync.

I mean... this is pretty much what lists/arrays/hashes etc. and pointers were MADE for, isn't it?

starholme
Fast Inserter
Fast Inserter
Posts: 199
Joined: Tue Oct 21, 2014 7:25 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by starholme » Fri Nov 22, 2019 2:46 pm

Time to ramp up the biters in the crash site scenario!

Omarflyjoemacky
Long Handed Inserter
Long Handed Inserter
Posts: 87
Joined: Tue Nov 15, 2016 10:56 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by Omarflyjoemacky » Fri Nov 22, 2019 3:03 pm

Loaded question, but .18 before Christmas? ... Super FFF this week.
"And then Bender ran."

jcranmer
Long Handed Inserter
Long Handed Inserter
Posts: 85
Joined: Wed Jun 29, 2016 9:59 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by jcranmer » Fri Nov 22, 2019 3:23 pm

ledow wrote:
Fri Nov 22, 2019 2:30 pm
1 x Global List/Array/whatever of pointers to all entities, each with a type inside it.
1 x List/Array/whatever for each "type" of entity that needs to be handled separately, stored as a set of pointers to each of those entities.

Even for a thousand particles, the memory overhead is pathetic - basically an "extra" list of ~1000 pointers to the same entities if you do it right.
When you want to iterate over particles only, you can do without having to go through every entity in the global list.
When you want to pathfind / whatever, you only iterate over the pathfind-affecting lists of entities.
When you want to draw everything, you iterate over the global list.

You're not storing entities twice (there may be a pointer to them in multiple lists, sure, but only one copy of the entity "structure/class"), your iterations are linear and don't have to interrogate every entity to see if it's the right type. And with just two helper functions to add / remove an entity which add it or remove it from all the appropriate lists that it should be in and stitches the lists back together, and which you call whenever you change/create/destroy an entity so they don't get out of sync.

I mean... this is pretty much what lists/arrays/hashes etc. and pointers were MADE for, isn't it?
Each pointer is 8 bytes. As you get to medium-sized factories, that means your lists are each going to be in the 100K-1MB range. You might then say "I've got 8+GB of RAM, who cares?", but the reality is that it's not the RAM that's precious, it's your caches. If your lists don't fit in the cache, you're now paying a miss to main memory to get the address of the location you need to retrieve from main memory, all the while twiddling your thumbs while you're waiting for main memory. When you have enormous memory requirements, performance optimization tends to become all about optimizing cache locality. The classic example here is the random insertion in a list: at what N does it become faster to use a linked list instead of an array list for randomly inserting elements into the middle?

gGeorg
Inserter
Inserter
Posts: 44
Joined: Wed Jun 19, 2019 8:06 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by gGeorg » Fri Nov 22, 2019 4:43 pm

Rseding91 wrote:
Fri Nov 22, 2019 1:28 pm
Lubricus wrote:
Fri Nov 22, 2019 1:03 pm
Isn't particles usually some sort of shaders that only lives in the graphics card? And thus use no CPU power nor RAM.
Particles in Factorio can spawn other particles, other entities, smoke, do damage, and so on. They couldn't ever just live in render-only land. Also, you still have to spend CPU time and RAM to tell the GPU what to do so it's never possible to "use no CPU por nor RAM".
Interesting. Does it mean we can have a Factorio particles AND the classic particles which live in the render only land?
With these second one, the graphics dept. would go wild with all the sparkles and steam leaks.

Impatient
Filter Inserter
Filter Inserter
Posts: 374
Joined: Sun Mar 20, 2016 2:51 am
Contact:

Re: Friday Facts #322 - New Particle system

Post by Impatient » Fri Nov 22, 2019 4:54 pm

Big thanks to Klonan and Rseding for taking a look at the particle system with its edge performance case of flamethrowers defending against biters. This case was the reason why I had to stop playing multiplayer games regularily, when players started to use flamethrower turrets, due to the low end cpu in my pc. Looking forward to see the lowered performance impact.

Side question: Would it not be perfect to use sprites for the decorative bleed out effects? I have no in depth knowledge, but shouldn't take that kind of solution all the performance strain from the CPU and just require a bit more graphics memory?

User avatar
BattleFluffy
Fast Inserter
Fast Inserter
Posts: 120
Joined: Sun Mar 31, 2019 4:58 pm
Contact:

Re: Friday Facts #322 - New Particle system

Post by BattleFluffy » Fri Nov 22, 2019 5:41 pm

Thankyou for this excellent optimization work guys :>

User avatar
Ohz
Fast Inserter
Fast Inserter
Posts: 173
Joined: Tue Feb 03, 2015 11:40 am
Contact:

Re: Friday Facts #322 - New Particle system

Post by Ohz » Fri Nov 22, 2019 6:23 pm

If you lost count, this scene contains 15,689 entities
oh ok
I'm not english, sorry for my mistakes

Post Reply

Return to “News”

Who is online

Users browsing this forum: No registered users