This makes several processes during city construction asynchronous instead of synchronous, thus making sure the game keeps running even during longer loading processes. Specifically, the following processes are made asynchronous in the following ways:
Loading GXLs, Loading JaCoCo: Uses the Async variant of the XmlReader and runs on the thread pool.
Loading CSVs: Uses the Async variant of the CsvReader, but does not run on the thread pool (CSVs are sufficiently quick to read that switching to the thread pool adds more overhead than just running on the main thread.)
Creating a MergeDiff: Runs on the thread pool.
Drawing a graph: This uses a newly implemented extension methods, BatchPerFrame, to draw a set number of nodes/edges per frame, passing control to Unity in between so that the game does not freeze[^1]. The disadvantage of this is that drawing slows down by about 20% for edges specifically, but this is unavoidable if we want the game not to freeze, since we can't use the thread pool for this.
Loading Dashboard metrics: Apart from the API retrieval (which was already asynchronous), matching metrics to nodes now also happens asynchronously, using the BatchPerFrame method from above.
Parts of the evolution city: Note that it can make sense to make the evolution city as a whole more asynchronous. I've just made the parts asynchronous that were necessary to convert anyway due to changes to the GXLReader.
[^1]: Note that "not freezing" still means ~5 FPS, which is very slow and unpleasant, but still barely controllable. We can increase the batch size to increase FPS at the cost of processing speed.
Additional changes
The above changes now also make it possible to easily cancel any of these processes while they are running, using CancellationTokens. Currently, this is done when pressing "Reset Data".
Progress reports have been added where applicable, so this resolves #729.
Some unused code regarding sublayouts has been removed. If we need it again, we can retrieve it from VCS history.
The determinate spinner now has an additional animation to indicate that the process is still running (since it is otherwise a static image if the progress is currently stuck).
The dependency MoreLinq has been added, which provides some very convenient LINQ extension methods. For this PR, Batch was needed, and our own implementation Permutations has been removed in favor of the implementation by this library.
Some minor code style improvements in various places.
This makes several processes during city construction asynchronous instead of synchronous, thus making sure the game keeps running even during longer loading processes. Specifically, the following processes are made asynchronous in the following ways:
Async
variant of theXmlReader
and runs on the thread pool.Async
variant of theCsvReader
, but does not run on the thread pool (CSVs are sufficiently quick to read that switching to the thread pool adds more overhead than just running on the main thread.)BatchPerFrame
, to draw a set number of nodes/edges per frame, passing control to Unity in between so that the game does not freeze[^1]. The disadvantage of this is that drawing slows down by about 20% for edges specifically, but this is unavoidable if we want the game not to freeze, since we can't use the thread pool for this.BatchPerFrame
method from above.[^1]: Note that "not freezing" still means ~5 FPS, which is very slow and unpleasant, but still barely controllable. We can increase the batch size to increase FPS at the cost of processing speed.
Additional changes
CancellationToken
s. Currently, this is done when pressing "Reset Data".MoreLinq
has been added, which provides some very convenient LINQ extension methods. For this PR,Batch
was needed, and our own implementationPermutations
has been removed in favor of the implementation by this library.