Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which ABM's could/should be removed? #1561

Closed
MarkuBu opened this issue Feb 11, 2017 · 48 comments
Closed

Which ABM's could/should be removed? #1561

MarkuBu opened this issue Feb 11, 2017 · 48 comments

Comments

@MarkuBu
Copy link
Contributor

MarkuBu commented Feb 11, 2017

There are a lot of ABM's in MTG. One of them could be replaced by something lightweight.

I think, most of the ABM's could be replaced, but the question is: is it worth it?

I tried to replace lava cooling, but it is difficult. Just worked well with lava source, not with lava flowing

@Fixer-007
Copy link
Contributor

Fixer-007 commented Feb 11, 2017

You are approaching from wrong direction, you should first profile abms on IRL servers, check what is the heaviest and then think about what to do...

@MarkuBu
Copy link
Contributor Author

MarkuBu commented Feb 11, 2017

How can I profile them?

@Fixer-007
Copy link
Contributor

Fixer-007 commented Feb 11, 2017

profiler.load = true in minetest.conf

@MarkuBu
Copy link
Contributor Author

MarkuBu commented Feb 11, 2017

I never worked with the profiler. Can you tell me what's next?

@Fixer-007
Copy link
Contributor

enable it in config, load the game/server, in console type /profile reset, wait some time, /profile save txt - will save txt with info in world dir (it is /profile or /profiler, don't remember exact thing)

@MarkuBu
Copy link
Contributor Author

MarkuBu commented Feb 11, 2017

Thanks, that is helpful

@sofar
Copy link
Contributor

sofar commented Feb 11, 2017

Sapling growth used to be per-sapling but is now just 1.

I didn't make that a nodetimer?

@sofar
Copy link
Contributor

sofar commented Feb 11, 2017

if the engine could honor calling on_construct for liquids then the lava ABM can be removed entirely.

So, I suggest we make that change.

It would also potentially aid protection mods.

@sofar
Copy link
Contributor

sofar commented Feb 11, 2017

Saplings have an on_timer(), so there's no ABM for that anymore.

@sofar
Copy link
Contributor

sofar commented Feb 11, 2017

A quick profile shows

  • flower and mushroom spread
  • grass covering dirt

Those are going to be the bulk of the ABM cost, and we can't get rid of them I think.

@paramat
Copy link
Contributor

paramat commented Feb 11, 2017

Oops forgot about node timers.

@MarkuBu
Copy link
Contributor Author

MarkuBu commented Feb 13, 2017

Currently it seems that I have to run minetest.find_nodes_in_area() over a chunk to find e.g. all the flowers and mushrooms and start their node timer. Don't know if that's the best idea

@sofar
Copy link
Contributor

sofar commented Feb 13, 2017

The reason flowers and mushrooms are not nodetimer based is because they're fundamentally different than saplings and farming crops: The growth of those is finite, but mushroom spread should always happen. (same as grass covering dirt).

So there is no reason to attempt to convert these. ABM's can continue to serve them as efficient (on a large scale, I'm not talking micro level comparison) as nodetimers can.

So, before you attempt to write a lot of ugly code that works around the problems mentioned, keep in mind that if something is supposed to happen all the time, and forever, then ABM's are likely going to be the simplest way to do it.

@MarkuBu
Copy link
Contributor Author

MarkuBu commented Feb 13, 2017

You are right. It was just a thought game. I don't have the feeling that the flower ABM is that heavy that it needs to be replaced

The only ABM that could be replaced is the lava cooling, but I'm not sure if it't worth it because lava mostly found in the underground

So possible close of this issue? Cause I don't think we need to replace any other ABM

@paramat
Copy link
Contributor

paramat commented Feb 13, 2017

I've just seen that lavacooling is interval 1 chance 1, which is crazy, and i was the one fiddling with these values, perhaps it can be 2 and 2 instead? Chance 1 can overload the sound generator when a large volume cools. Newer mapgen have lava in larger volumes.

@sofar
Copy link
Contributor

sofar commented Feb 13, 2017

Lava cooling is one of those things that should get fixed radically differently IMHO.

First, it's not something that happens to all lava nodes no matter what - it is entirely event driven. It will only ever occur when new lava is created, or when new water is created.

The problem is that liquid updates do not call on_construct. If it did, we could entirely solve this with on_construct handlers and remove the ABM entirely, and not even add nodetimers.

@MarkuBu
Copy link
Contributor Author

MarkuBu commented Feb 13, 2017

In general I think, the liquid system needs a rewrite

@paramat
Copy link
Contributor

paramat commented Feb 13, 2017

sofar yes that sounds good let's try it.

@sorcerykid
Copy link

sorcerykid commented Feb 14, 2017

Wait what? O_o Lava cooling really has an interval of only 1!

Admittedly the callback function is infrequently executed, but the nodes in every active map block are still being checked repeatedly.

I threw together a very basic profiler in the ABMHandler class, to see just how many node checks are actually being performed per second with just a single player online. It literally blew my mind!

Map Block 16 ( -4,  -2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,  -2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,  -2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,  -2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,  -2,   2):    5 pass + 4091 fail + 135 near = 4231 total
Map Block 16 ( -4,  -1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,  -1,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,  -1,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,  -1,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,  -1,   2):    1 pass + 4095 fail +   0 near = 4096 total
Map Block 16 ( -4,   0,  -2):   27 pass + 4069 fail +   0 near = 4096 total
Map Block 16 ( -4,   0,  -1):   88 pass + 4008 fail +  32 near = 4128 total
Map Block 16 ( -4,   0,   0):  154 pass + 3942 fail + 128 near = 4224 total
Map Block 16 ( -4,   0,   1):  133 pass + 3963 fail +  57 near = 4153 total
Map Block 16 ( -4,   0,   2):  101 pass + 3995 fail +  32 near = 4128 total
Map Block 16 ( -4,   1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,   1,  -1):   83 pass + 4013 fail +  67 near = 4163 total
Map Block 16 ( -4,   1,   0):  132 pass + 3964 fail +  81 near = 4177 total
Map Block 16 ( -4,   1,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,   1,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,   2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,   2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,   2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,   2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -4,   2,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,  -2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,  -2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,  -2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,  -2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,  -2,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,  -1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,  -1,  -1):   37 pass + 4059 fail +   8 near = 4104 total
Map Block 16 ( -3,  -1,   0):   54 pass + 4042 fail +  21 near = 4117 total
Map Block 16 ( -3,  -1,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,  -1,   2):    1 pass + 4095 fail +   0 near = 4096 total
Map Block 16 ( -3,   0,  -2):   94 pass + 4002 fail +   3 near = 4099 total
Map Block 16 ( -3,   0,  -1):   59 pass + 4037 fail +  17 near = 4113 total
Map Block 16 ( -3,   0,   0):   66 pass + 4030 fail +  22 near = 4118 total
Map Block 16 ( -3,   0,   1):   54 pass + 4042 fail +  10 near = 4106 total
Map Block 16 ( -3,   0,   2):  138 pass + 3958 fail +  52 near = 4148 total
Map Block 16 ( -3,   1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,   1,  -1):   22 pass + 4074 fail +   6 near = 4102 total
Map Block 16 ( -3,   1,   0):   27 pass + 4069 fail +   2 near = 4098 total
Map Block 16 ( -3,   1,   1):   17 pass + 4079 fail +   1 near = 4097 total
Map Block 16 ( -3,   1,   2):   12 pass + 4084 fail +   3 near = 4099 total
Map Block 16 ( -3,   2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,   2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,   2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,   2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -3,   2,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -2,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -1,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -1,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -1,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,  -1,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   0,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   0,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   0,   0):    5 pass + 4091 fail +   0 near = 4096 total
Map Block 16 ( -2,   0,   1):    6 pass + 4090 fail +   0 near = 4096 total
Map Block 16 ( -2,   0,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   1,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   1,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   1,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   1,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -2,   2,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,  -2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,  -2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,  -2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,  -2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,  -2,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,  -1,  -2):    1 pass + 4095 fail +   0 near = 4096 total
Map Block 16 ( -1,  -1,  -1):    5 pass + 4091 fail + 135 near = 4231 total
Map Block 16 ( -1,  -1,   0):    6 pass + 4090 fail + 162 near = 4258 total
Map Block 16 ( -1,  -1,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,  -1,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   0,  -2):   36 pass + 4060 fail +   9 near = 4105 total
Map Block 16 ( -1,   0,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   0,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   0,   1):    5 pass + 4091 fail +   5 near = 4101 total
Map Block 16 ( -1,   0,   2):   27 pass + 4069 fail +   0 near = 4096 total
Map Block 16 ( -1,   1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   1,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   1,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   1,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   1,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 ( -1,   2,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,  -2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,  -2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,  -2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,  -2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,  -2,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,  -1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,  -1,  -1):    6 pass + 4090 fail + 162 near = 4258 total
Map Block 16 (  0,  -1,   0):    7 pass + 4089 fail + 189 near = 4285 total
Map Block 16 (  0,  -1,   1):    3 pass + 4093 fail +  81 near = 4177 total
Map Block 16 (  0,  -1,   2):    4 pass + 4092 fail + 108 near = 4204 total
Map Block 16 (  0,   0,  -2):  203 pass + 3893 fail +  48 near = 4144 total
Map Block 16 (  0,   0,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   0,   0):    1 pass + 4095 fail +   0 near = 4096 total
Map Block 16 (  0,   0,   1):    6 pass + 4090 fail +   8 near = 4104 total
Map Block 16 (  0,   0,   2):    2 pass + 4094 fail +   0 near = 4096 total
Map Block 16 (  0,   1,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   1,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   1,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   1,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   1,   2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   2,  -2):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   2,  -1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   2,   0):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   2,   1):    0 pass + 4096 fail +   0 near = 4096 total
Map Block 16 (  0,   2,   2):    0 pass + 4096 fail +   0 near = 4096 total

In all fairness, block->getNodeNoEx( ) is lightweight. Yet as shown above, there are over half a million node checks every second, most of which fail and thus are completely wasteful of CPU cycles. That is a lot of needless repetition that could be greatly optimized if a different algorithm were used for ABMs.

I guess I should go back and start vetting all ABMs, because this is quite scary to be honest :(

@MarkuBu
Copy link
Contributor Author

MarkuBu commented Feb 14, 2017

I think, instead of removing the lava cooling ABM the whole liquid system should be changed

@sorcerykid
Copy link

sorcerykid commented Feb 14, 2017

Yes, it would seem liquids should be overhauled as well. I think together with ABMs, they can be a severe performance drain even on high-end systems.

@tenplus1
Copy link
Contributor

If we had an on_flood function active for nodes then we could use that to replace with stone or obsidian only when required instead of all the checks every second.

@paramat
Copy link
Contributor

paramat commented Feb 14, 2017

We are not going to suddenly do a complete rewrite of liquids, it actually works fairly well, it's very easy to be dissatisfied with it, but that's because it's simple and unrealistic for good reason. If you tried to code a liquid system you would find it's much more difficult than you think, then you would realise what we have works quite well.
When you rewrite you throw away years of effort tuning and tweaking and testing in-game, it's almost always best to evolve a system. Let's work on improving the system we have.

@sorcerykid
Copy link

sorcerykid commented Feb 14, 2017

Here's an idea for a rudimentary alternative to the current ABM mechanism, one which could provide significant advantages in terms of efficiency and simplicity:

  • evaluate the trigger conditions for registered ABMs only when a map block is loaded or modified.
  • store the results of all map block positions into a unique bitmap cache for each registered ABM.
  • at the designated interval, select random positions within every bitmap via a probability function.
  • verify the number of objects in the map block and surrounding map blocks is not yet exceeded.
  • invoke the callback function for each registered ABM at the corresponding map block positions.

Since map blocks are infrequently loaded and/or modified and the trigger conditions for ABMs are already known at the time of registration, then the results can obviously be cached into a simple bitmap (where 1 is pass and 0 is fail). This, of course, is just an ad hoc example. There are undoubtedly more robust algorithms that could be devised to account for all manner of scenarios. I'm mainly putting this out there just to show what can be done to greatly lessen the CPU workload with active block modifiers.

@paramat
Copy link
Contributor

paramat commented Apr 28, 2017

There have been ideas discussed about how to remove the lava ABM, replacing it with an update when nearby nodes are updated.

@paramat
Copy link
Contributor

paramat commented Jul 16, 2017

There have been ideas discussed about how to remove the lava ABM, replacing it with an update when nearby nodes are updated.

However on mapgen lava nodes are generated next to water nodes and there may not be an update.
We'll remove more ABMs if it is possible.

@paramat
Copy link
Contributor

paramat commented Jun 19, 2018

Reopen as is important and ideas are very welcome.

Here's one for flora spreading, that may well not be usable in MTG but is worth noting.

I suggest that flora spread is something that can happen when you dig a flora node. Therefore spreading happens when and where it is needed due to the removal of a flora node, instead of happening everywhere, increasing density where a low density is intended, and most of the time doing nothing because the maximum density has been reached.

On this player action 1 or 2 nearby soil nodes can be 'seeded' with a seedling of the dug flora node and nodetimers started on them for later growth. The seedlings could be tiny plantlike nodes on the surface. We therefore use a system like tree saplings but automate the seeding so that you don't have to collect seeds and plant them.

@paramat
Copy link
Contributor

paramat commented Jun 19, 2018

MTG ABMs and their intervals:

default:
lavacool 2
cactus 12
papyrus 14
grass spread 6
grass death 8
moss 16

farming:
soil 15

tnt:
ignite 4

fire:
ignite flame 7
remove flammable nodes 5

flowers:
flower spread 13
mushroom spread 11

stairs:
slab replace 16 (disabled by default)

12 ABMs running by default.

Intervals ordered, brackets indicate ABMs usually not running:
2
None for 3
4
5
6
7
8
None for 9
None for 10
11
12
13
14
15
16
(16)

The intention is for each ABM to have a different interval to reduce the occurence of many ABMs acting at once, to make them as out-of-phase as possible.

@paramat
Copy link
Contributor

paramat commented Jun 19, 2018

Of these, flower and mushroom spread could certainly be removed using either seeds or the above described method. But, might cause disruption for some players and worlds.

Coral death: EDIT: Done.

Coral is only placed underwater in places unlikely to be drained of water (if they were drained players would likely dig the coral anyway). Dug coral drops dead coral. Kelp does not die if drained of water. Many other plants survive in weird situations, like removing dirt from under a tree.
So this ABM is not essential, added for good reason and to be thorough, but i feel it can be removed.

Fire: EDIT: Done.

'extinguish flame' (run every 3s so very intensive) can be done by making flames 'floodable = true'. The ABM would be needed for ice and snow to extinguish, but these nodes do not melt in this process so extinguishing doesn't make much sense, there's no meltwater to run into the flame.
Water would then need to run into the flame to extinguish it, instead of just being beside it. The 'on_flood' callback would play the extinguish sound.

Note that flame spread already prevents flames appearing next to snow and ice, the ABM is only there for the situation of placing snow or ice to extinguish a flame, the player can extinguish the flame much faster just by punching it.
Considering all this the ABM can certainly be removed.

@paramat paramat reopened this Jun 23, 2018
@Fixer-007
Copy link
Contributor

Maybe instead optimise it engine itself? Don't cut out those minor yet meaningful abms...

@paramat
Copy link
Contributor

paramat commented Jun 24, 2018

We await your PR :)
We will of course optimise it in the engine as well, but they will still be fairly intensive. Also, someone has to actually do it first, we could always re-add ABMs once done, but until then (could be years away) we need to avoid ABMs if at all possible.
The coral death ABM is not meaningful, it's unnecesary and inconsistent.

@paramat
Copy link
Contributor

paramat commented Jul 10, 2018

#2172 merged.

@paramat
Copy link
Contributor

paramat commented Aug 20, 2018

@Ezhh any opinion on removing fire extinguish ABM? #1561 (comment)

@JurajVajda
Copy link

fire extinguish ABM is not hugging lot of resources at all but the right approach would be to not spread fire when disabled instead of spreading fire anyway and then removing it

@rubenwardy
Copy link
Member

I disagree with removing the fire ABM. With the ABM caching optimisation, ABMs are now very inexpensive if there are no such nodes in a block - which is the case almost all the time for fire

@Ezhh
Copy link
Contributor

Ezhh commented Aug 20, 2018

If all the ABM really does is remove fire if it happens to be next to snow/ice nodes, I am struggling to understand the point of it (as opposed to currently thinking about it in terms of an optimisation issue). Fire simply being next to ice or snow would not put out fire, so long as the fire itself has a suitable fuel source, so it seems a bit of a pointless thing.

That leaves water, which should put out fire... if it floods the node the fire is in, which does bring us back to on_flood again.

Instead of thinking about how resource-hungry this particular ABM is, we should figure out if the current behaviour is actually desired or not.

@Fixer-007
Copy link
Contributor

That ABM optimisation PR was merged, is this issue still relevant?

@rubenwardy
Copy link
Member

Instead of thinking about how resource-hungry this particular ABM is, we should figure out if the current behaviour is actually desired or not.

I agree with this very much

@paramat
Copy link
Contributor

paramat commented Aug 20, 2018

Fixer yes it's still relevant, because ABMs can still be temporarily intensive (see below), and they are essentially undesirable as they are continuous instead of event-triggered.

The newly-added ABM cache is not saved in the database, so each time a block is loaded the ABMs run as before the first time, then afterwards the cache optimisation has effect. When a block is unloaded from the server (this happens often) the cache is lost.
Beyond a certain number of nodes per mapblock the optimisation doesn't work, so ABMs will be as intensive as before in a few very complex areas of servers, which are also likely to be the areas where ABMs are most intensively used.

It's good that it's less urgent but my attitude to ABMs hasn't changed much, they need to be removed where reasonably possible.

As i explained a few posts back, there isn't actually much need for this ABM at all once fire is floodable, so i still think it's worth removing the ABM. Neighbouring snow or ice doesn't melt and isn't removed anyway.
I can do the PR if pre-approved.

@Ezhh
Copy link
Contributor

Ezhh commented Aug 20, 2018

Unless there is something I'm missing, I'd be in favour of this change simply from a common sense standpoint, because I don't think the current behaviour is right.

@rubenwardy What's your stance on this? You were against removing the ABM to begin, but if you agree the current snow/ice behaviour isn't needed, on_flood makes more sense to me than the ABM does.

@paramat
Copy link
Contributor

paramat commented Aug 21, 2018

Also consider, whenever the contents of a mapblock are changed the cache is invalidated and the ABM runs as before. Considering that players are very often digging or placing nodes, and mods and are altering the world, this means ABMs are very often running as intensively as before.
The optimisation is patchy and only has effect in certain situations.

@paramat
Copy link
Contributor

paramat commented Aug 23, 2018

PR #2200

@paramat
Copy link
Contributor

paramat commented Aug 23, 2018

Another ABM that could possibly be removed: EDIT: Done.

if not fire_enabled then

	-- Remove basic flames only if fire disabled

	minetest.register_abm({
		label = "Remove disabled fire",
		nodenames = {"fire:basic_flame"},
		interval = 7,
		chance = 1,
		catch_up = false,
		action = minetest.remove_node,
	})

When fire is disabled there is still a ABM running to remove flames. Instead we could simply remove the flame when it's timer expires.

@paramat
Copy link
Contributor

paramat commented Aug 26, 2018

Instead of thinking about how resource-hungry this particular ABM is, we should figure out if the current behaviour is actually desired or not.

Well .. both need to be considered, as the ABM optimisation only occurs in some situations, and not at all during a fire as the cache is constantly being invalidated. The extinguish ABM has very little or no benefit so i don't think it justified.

@paramat
Copy link
Contributor

paramat commented Sep 2, 2018

#2200 merged.

@paramat
Copy link
Contributor

paramat commented Sep 4, 2018

PR #2209 for #1561 (comment)

@paramat
Copy link
Contributor

paramat commented Sep 17, 2018

#2209 merged, excellent we've made some good progress.

@paramat
Copy link
Contributor

paramat commented Oct 20, 2019

It seems we have removed roughly everything that can be, so closing. New issues can be made if further ABMs seem removable.

@paramat paramat closed this as completed Oct 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants