Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSP loader performance optimization #109

Closed
wants to merge 34 commits into from
Closed

Conversation

gotmachine
Copy link
Contributor

Fix issue #108
Fix issue #69

Reimplementation of the KSP loader :

  • Atomic asset loading and part compilation operations decoupled from framerate
  • Audio assets loading : basic parallel async implementation by starting multiple requests at once
  • Texture/model loading : threaded disk reads pulling data into a buffer to be consumed sequentially in the main thread
  • Various small optimizations in individual loaders, mainly in the PNG loader (faster normal map swizzle, faster metadata parsing)
  • Port of the PNG texture cache feature

Due to this relying on a lot of KSP implementation details, as well as some features only available in Unity 2019.4, this patch is limited to KSP 1.12+. The patch doesn't have any configuration mechanism, it is always active. The texture cache feature is still opt-in and can be disabled in the in-game settings.

gotmachine and others added 30 commits August 24, 2022 14:03
* Rewrite PreFormatConfig to iterate through strings as little as possible.

* Improve logging, add @siimav's parallel processing bit (seems to be strictly slower even for 1m+ rows, tho)

* Patch writing, too, for a slight improvement in perf

* Fix a lingering issue with trailing braces

* Patch on startup, not after MM. Skipping keys will only happen after MM, but they're really just there for sfs loading, can't trust what's in gamedatabase enough to skip parsing there.

* Update readme and Settings

* Big improvements to save perf by not writing lines / flushing / using a puny buffer.

* missed a newline
* Create ModUpgradePipeline modding patch. This patch will store and use mods' versions when running SaveUpgradePipeline scripts.

* Go back to storing versions for all assemblies. Bump KSPCF version to minor, not revision.

* Fix readme to link PR
* Rewrite more of ConfigNode. Avoid all recursion when reading from disk. Add further optimization around specific use cases (craft, sfs, cache loading). Add blacklist support (assumes all values are sane unless otherwise informed).

* Try with MemoryMappedFile

* Read to a char array, more inlining and optimizing

This is better than it was, but in some cases the old version outperforms it.

Fix some further parser issues, switch to new method of reading files

Remove unused code from parser

* Remove confignodeperf settings blocks, upodate readme

* ConfigNodePerf: Patch copy, tostring, and parse as well. Refactor parse method so it can be used for either file or string case.

* Allow not writing indents when saving nodes.

* Found another copypasta issue with Santiize...

* Rewrite ReadObject/WriteObject and associated code. Works fine in test but crashes my live game...

* Add KSPAssembly attribute

* Fixed exception when single field is specified more than once due to cfg error

* Fix not saving nodes for objects/components when writing, cache fieldless objects to prevent recreating them when Persistent is applied wrongly

* Fix fallback decoding for ReadFile

* Don't double translate on load fail. Use a static stringbuilder, and reflect to clear previous chunks.

* Further expand on notes in readme, clean up last bits prior to merge. Force sanitize off in the UpgradePipeline patch.
…for better support for other mods, update release script to behave correctly with new versioning bump version (only fileversion and KSPAssembly).
…'t support both sfs and craft contexts. Bump version.
When using physics warp, Unity will set the max physics dt to be at least as high as the scaled physics dt.  But KSP will never restore it back to the normal value from the settings.  This can degrade performance as it allows more FixedUpdates to run per frame.

reported by Wilds on the forum: https://forum.kerbalspaceprogram.com/index.php?/topic/184740-solved-losing-300-performance-after-time-warping/
- Backport of the texture cache (TextureLoaderOptimizations)
- Unpatching after loading to prevent breaking stock/MM database reload feature, as well as runtime drag cube generation
@gotmachine gotmachine closed this Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants