# Kortex - Performance Suite (v1.2.0)
### For Kerbal Space Program 1.12.5

Kortex reduces CPU overhead, UI rendering costs, memory allocation pressure, and disk I/O bottlenecks in KSP, targeting core engine limitations not covered by other optimization mods.

---

## What It Does

### CoreKinetics (System & Disk)
* **Async Autosave:** Replaces KSP's native, game-freezing autosave mechanism with a secure background threading architecture. Your flight simulation remains perfectly fluid while your progress is saved on another CPU core. Includes rotating multi-backup protection to ensure your data safety.

### PerformanceFlux (CPU & Memory)
* **GC Evader (Memory Pooling):** Replaces repetitive and heavy frame-by-frame heap memory allocations (such as `Vessel.GetActiveParts`) with a static, thread-safe memory pooling system. This starves Unity's Garbage Collector, eliminating the cyclical micro-stutters and sudden framerate drops every few seconds.
* **UI Refresh Throttle:** Caps heavy UI element refresh rates (such as the resource display panel) to 10 Hz instead of running every single frame. This frees massive CPU headroom under high part counts without sacrificing readability.
* **Adaptive Frame Stabilizer:** Dynamically monitors engine load and smooths out severe physics lag. By temporarily micro-adjusting the physics timestep, it prevents structural stutters during extreme situations or massive launches.
* **Map Mode Portrait Culling:** Completely halts the 3D rendering and animation loops of Kerbal crew portraits when you are looking at the Map View, avoiding wasted CPU cycles.
* **Log Anti-Spam:** Intercepts, filters, and mutes infinite engine warning loops in the KSP log file. This drastically reduces intense disk write operations (I/O overhead) that cause random stuttering.

### PerformanceFlux (GPU & Rendering)
* **Cargo & Fairing Mesh Culling:** Intelligently hides the 3D meshes and geometry of all parts hidden inside closed cargo bays and fairings. This reduces GPU draw calls and VRAM pressure significantly until the payload is deployed.
* **Shadow Cascade Governor:** Restructures KSP's outdated shadow rendering pipeline per scene. Forces `StableFit` shadow projections to fully eliminate shadow flickering while restoring substantial FPS on the launchpad and near planetary surfaces.

---

## Requirements

* KSP 1.12.5
* Harmony 2 for KSP (HarmonyKSP) — Installed automatically via CKAN, or manually from GitHub.
* KSPCommunityFixes — Optional but highly recommended. Kortex automatically detects KSPCF at startup and disables any overlapping patches to prevent conflicts.

---

## Installation

### Via CKAN (Recommended)
1. Open the CKAN client.
2. Search for `Kortex - Performance Suite`.
3. Check the box, click **Apply Changes**, and let CKAN manage your dependencies automatically.

### Manual Installation
1. Install HarmonyKSP first.
2. Copy the `Kortex` folder into your KSP `GameData/` directory.

---

## Settings

Open **Settings → Difficulty Options → Kortex** in-game to configure:
* Toggle individual CPU, GPU, and memory optimization modules on/off.
* Adjust background autosave intervals and maximum backup rotations.

> **Note:** Turning anything ON after disabling it mid-flight requires reloading your save or returning to the main menu. Disabling it works immediately. (so Kortex do not always scan your settings and it saves precious performances)

---

## Compatibility

Tested with: Scatterer, EVE Redux, KSPCommunityFixes, TweakScale, MechJeb, RasterPropMonitor, AvionicsSystems (MAS).
No known conflicts. If you experience issues, check your `KSP.log` for `[Kortex]` entries and report them on the GitHub repository or the forum thread.

---

## Backups & Links

* **Backup Folder:** `GameData/Kortex/Backups/` (Files are named `[savename]_backup_[timestamp].sfs`)
* **GitHub:** https://github.com/MrCrustyToast/Kortex---KSP-optimization-mod
* **SpaceDock:** https://spacedock.info/mod/4272
* **Forum:** https://forum.kerbalspaceprogram.com/topic/230724-kortex-cpu-and-ui-optimization-mod/

Developed by MrCrustyToast  
Licensed under the MIT License.
