Significantly improved performance by adding caching of combinational chips #507
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purely combinational chips, so chips whose outputs entirely depend on their inputs and on nothing else, who also don't have too many input bits, now get cached. This means that a look up table (LUT) with 2^(number of input bits) entries gets created and whenever this chip needs to determine its output, it can just use the LUT to immediately know what its output should be.
This usually gave me a speedup of up to 4x (for example my CPU went from 1500 sps to more than 5000 sps).
Also added some UI in the chip customization menu where the player can decide for medium sized chips whether they should get cached or not.
Also added a little pop up info to give progress information when creating large caches.
Any special cases (like displays, keys, tristated values, view mode, ...) also all get handled correctly (usually by turning off chip caching).