From 236cf95bdd67bd255a643362cd843d9fe2737bf4 Mon Sep 17 00:00:00 2001 From: MarcelineVQ Date: Sat, 14 Mar 2026 15:03:31 -0700 Subject: [PATCH] Add file cache and timer fix to release notes and DLL_README --- DLL_README.md | 26 ++++++++++++++++++++++++++ RELEASE_NOTES.md | 17 +++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/DLL_README.md b/DLL_README.md index e2b89c3..7bc1200 100644 --- a/DLL_README.md +++ b/DLL_README.md @@ -188,6 +188,32 @@ Lua API for addon developers: --- +### MPQ File Cache + +Caches the results of MPQ archive file lookups so repeat file opens skip the expensive archive chain walk and hash table probe. The game re-opens the same model and texture files hundreds of times per second during gameplay -- each lookup normally searches through every loaded MPQ archive. The cache remembers which archive contains each file and returns the answer directly. + +Cache hits cost roughly 1/30th of a full search. During heavy gameplay (cities, raids, zone transitions), this saves 50-160ms every 15 seconds. In quiet scenes with few new models loading, there is little to save because the game does fewer lookups. + +The cache validates that archives are still alive before returning cached results, so if the game closes or reloads an archive, the cache falls through to the original search. + +No configuration needed. Enabled by default when using `weirdutils.dll`. + +**DLL:** `filecache.dll` + +--- + +### Timer Calibration + +Improves the game's internal timer precision by recalibrating the TSC (Time Stamp Counter) frequency using the OS performance counter as a reference. The vanilla client's built-in calibration is inaccurate, which can cause animation stutter and timing jitter on some systems. + +Also requests higher OS timer resolution (0.5ms instead of the default 15.6ms) and disables Windows 11 power throttling for the game process. + +Ported from [VanillaFixes](https://github.com/hannesmann/vanillafixes). Primarily benefits native Windows. On Wine/Linux the game typically uses GetTickCount instead of TSC, so this module enables TSC mode with a proper calibration. + +No configuration needed. Included in `weirdutils.dll`. + +--- + ## Why No Source Code? This project is distributed as pre-built DLLs only. The source code is not and will not be made publicly available. diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 16ed543..f961dcb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -58,9 +58,26 @@ Track notable changes here between releases. Clear this file when cutting a new for ClipPolygonToSinglePlane (4x), BuildTrianglePlanes (10x), rotateMatrixByAxisAngle (4.3x), RayTriangleIntersection (1.3x), multiplyMatrix4x4 (4.3x). +- **VanillaFixes Math Polyfill** (WIP) - incorporating x87 FPU replacements from UnitXP + and libSiliconPatch into our SSE pipeline. Replaces ~20 game math functions (matrix + multiply, vector ops, collision geometry, animation interpolation) with SSE or modern + scalar equivalents. Compiled ReleaseFast as a separate compilation unit (math_sse.zig). + Not yet wired into hooks -- will be its own module with independent mutex. + - **Glyph Shadow Cache** - direct-mapped O(1) bypass for the game's 4-bucket hash table in GetOrCreateCharacterGlyph. Reduces glyph lookup from ~3.65% frame time. +- **MPQ File Cache (filecache)** - 2-way set-associative cache for File_FindInArchive + (0x6549a0). Skips the MPQ chain walk and per-archive hash table probe on repeat file + opens. Cache hits cost ~1000 cycles vs ~30000 cycles for full search. 60-90% hit rate + during gameplay, saving 6-160ms per 15s reporting period depending on scene load. + Validated via game's own FindAndIncrementResourceReference to handle archive lifecycle. + +- **Timer Fix (VanillaFixes port)** - TSC calibration, OS timer resolution (0.5ms via + NtSetTimerResolution), and Windows 11 power throttling disable. Ported from + hannesmann/vanillafixes. Primarily benefits native Windows; no measurable impact on + Wine/Linux but applied unconditionally. + - **MPQ File Cache** - hooks File_FindInArchive (0x6549a0) to cache archive lookup results. First open does full MPQ chain walk (~60K cycles), subsequent opens hit direct-mapped cache with filename verification (~300 cycles). 80% hit rate in testing.