I have a technical problem with ChromatiCraft that I would like to see if anyone has a solution to:
For those unfamiliar with the transmission mechanics of ChromatiCraft:
The pylons are the sources of energy, which can transmit it to receivers. Things like the Casting and Ritual tables, as well as some "powered" blocks, are examples of receivers. As both the pylons and the receivers have a limited range, and all connections must have a clear line of sight, repeaters (which have their own range limit) are almost always necessary to "relay" the energy.
For performance reasons, the location and status of all network tiles (sources, receivers, and repeaters) are cached.
From a more technical side, here is what happens when a request is made to the network:
The networker logs a request from a given location, with a specified color, range, and transmission amount. The network then scans over the cache of tiles, collecting only repeaters and sources, and only those within range, and capable of transmitting that color. It then checks each of them to see if there is a clean line of sight. If so, it moves to that location and repeats the process, hopefully eventually finding a source. If no source is found after exhausting all capable those collected repeaters, or there are no operational repeaters of that color within range, it "steps back" to the previous location and tries the next repeater on that level of the list.
If it finds a source, that path is cached for future requests of that color from the original receiver (thus ridding the need of a recalculation for that location unless the network changes) and returned for additional logic.
(More programming-minded users will note that this is a fairly standard recursive search algorithm, and those following my mods' code will notice that this is very similar to ElectriCraft network pathing logic.).
Here is the problem:
With very large (hundreds of repeaters) networks that nonetheless cannot transmit certain colors to the requesting location, any such requests to that network become computationally expensive, as the search tries to exhaust every routing possibility yet never being satisfied. This manifests itself as a significant lag spike that if repeated frequently can see a server time out all of its players.
Compounding this is that the "find nearby repeaters and sources" logic runs over the
entire cache of tiles every step, because as far as I can tell it is not possible for the cache to be presorted for every request location.
Here is the network in question. Pylons are denoted with solid circles of their color, while connected ones also have a box around them. Dotted lines roughly represent repeater trails.