Skip to content

Commit

Permalink
Improve ConfigNode load/save perf (#88)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
NathanKell authored and gotmachine committed Jan 30, 2023
1 parent 67840b7 commit debb119
Show file tree
Hide file tree
Showing 5 changed files with 701 additions and 2 deletions.
12 changes: 12 additions & 0 deletions GameData/KSPCommunityFixes/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,18 @@ KSP_COMMUNITY_FIXES
// and every time you delete a vessel in the Tracking Station
FewerSaves = false

// These settings will make ConfigNode's loader not bother doing
// Extended checking during parsing for keys named ths
CONFIGNODE_PERF_SKIP_PROCESSING_KEYS
{
item = serialized_plugin
}
// or for keys that start with this.
CONFIGNODE_PERF_SKIP_PROCESSING_SUBSTRINGS
{
item = **skipProc**
}
// The stock ModuleAsteroidDrill and ModuleCometDrill do a lot of unnecessary iterating over all
// PartModules on the vessel to see if an asteroid or comet is attached.
// ModuleResourceHarvester already keeps a cache of this information, and all the stock drills
Expand Down
1 change: 1 addition & 0 deletions KSPCommunityFixes/KSPCommunityFixes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
<Compile Include="Modding\OnSymmetryFieldChanged.cs" />
<Compile Include="Modding\ReflectionTypeLoadExceptionHandler.cs" />
<Compile Include="Performance\FewerSaves.cs" />
<Compile Include="Performance\ConfigNodePerf.cs" />
<Compile Include="Performance\PQSCoroutineLeak.cs" />
<Compile Include="Performance\PQSUpdateNoMemoryAlloc.cs" />
<Compile Include="Performance\ProgressTrackingSpeedBoost.cs" />
Expand Down
Loading

0 comments on commit debb119

Please sign in to comment.