Cuberite Forum
Could redstone simulator use cBlockArea? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Could redstone simulator use cBlockArea? (/thread-596.html)



Could redstone simulator use cBlockArea? - xoft - 10-23-2012

While I'm messing around simulators, I noticed that by far the most costly simulator is the redstone. It hogs the most CPU and it spends most of it on calling cWorld::GetBlock(). I was wondering, could it be modified so that it read a small area using cBlockArea and then query that area instead of the entire world? That would most certainly speed things up, since there would be no locking and no chunk lookup needed for each single block. Also it would naturally bound the simulator not to simulate too close to the world edges, because the block area would refuse reading there.


RE: Could redstone simulator use cBlockArea? - NiLSPACE - 10-23-2012

Of course I do not know a lot of c++ but i think it needs to see a range of 15 around a redstone wire becouse a redstone signal can only go 15 blocks far.


RE: Could redstone simulator use cBlockArea? - xoft - 10-26-2012

I did some timing and here's what popped out:
Code:
cRedstoneSimulator::Simulate: 0 torches, 0 repeaters, 5411 blocks took 362542 ticks (362.54 sec)
A full 67 milliseconds per a single block? WTF?



RE: Could redstone simulator use cBlockArea? - NiLSPACE - 10-26-2012

is that fast or slow?


RE: Could redstone simulator use cBlockArea? - xoft - 10-26-2012

Normally one game tick takes 1/20 of a second ( = 50 ms). Since a game tick consists of a simulator simulation, the tick when this redstone was simulated took whole 363 seconds. That is 6 minutes instead of 50 ms. Super-slow.