Design Problems in the Redstone Simulator
#1
I am a new developer. I have already fixes some bugs and while trying to fix some more of them today, I found out that there are
many issues with the redstone power cache "cIncrementalRedstoneSimulatorChunkData::m_CachedPowerLevels". This is actually the root cause for many problems. The concept of "powered blocks" is the wrong way to think about redstone. As an example take a look at this picture: (Vanilla)
   
There are actually two different power levels tranferred through the same block. This is possible because the game evaluates the redstone power level for the requested strength conceptually from the receiver to the source and not the other way around (like it is currently in Cuberite). This way different receivers can pick up different signals through the same block. That other concept makes everything complicated and some things like this do not currently work.

But there is more: The power cache uses a STL hash map and they wastes a lot of memory, does rather expensive lookups and trashes the CPU caches while the block data itself would most likely already be in the cache (the STL hash maps are especially bad because they are based on linked lists). Has anyone done measurements about this? Except if we change it to use something like a plain array for the cache, directly checking the power level should be faster. (It might be a good idea to do move some work in cChunk or cChunkMap to avoid extensive locking and access overhead)

While playing with Cuberite I often noticed that redstone got stuck. A clearly powered repeater would just not turn on. This was only fixable through reloading the world or rebuilding at another location. Some Plugins like WorldEdit caused that too. I am fairly certain that this issues were caused by the power cache that was probably not correctly updated in some circumstances.



Long story short:
The power cache has problems and I am not convinced that it even gives a speed up.
That is why I am thinking about removing it. That should simplify the code a lot and fix many subtle issues.

Any thoughts are welcome.Confusedhy:
Reply
Thanks given by:


Messages In This Thread
Design Problems in the Redstone Simulator - by QUSpilPrgm - 06-06-2016, 11:29 PM



Users browsing this thread: 1 Guest(s)