TickProfiler
Valheim 1.0 performance profiler with real-time TPS deadlines, hitch forensics, safe mod attribution, runtime context and client graphs.
模組介紹 作者原文
MagiCorp Valheim TickProfiler
TickProfiler 1.0 is a Valheim dedicated-server and client performance profiler focused on real-time tick deadlines, main-thread hitches, and safe mod attribution.
Server profiler
The dedicated-server component records:
- Effective 50 Hz FixedUpdate rate based on real wall-clock deadlines. Unity catch-up bursts never repay deadlines that were already missed.
- Correct pending-deadline accounting when a stall crosses a report boundary.
- Main Update throughput, p95/p99/worst gaps, stall count, excess wall time and cumulative hitch buckets.
- Event-correlated hitch attribution with confidence levels. Managed GC is reported as observed during a hitch rather than automatically blamed.
- Safe BepInEx plugin-loop attribution for Update, FixedUpdate and LateUpdate. TickProfiler never instruments another mod's Harmony Prefix/Postfix/Finalizer methods.
- Harmony patch-owner context for game methods, reported as involved mods rather than assumed causes.
- Runtime context including players, ZDO count, active objects, loaded/generated zones, thread count and VM network throughput.
- Process RSS/private memory, managed heap, GC collections and CPU usage.
- TickProfiler self-overhead, timed calls/sec, output queue depth and exception-stack recovery count.
- Optional 1-in-N sampling for deep/high-frequency game methods. Aggregate rates are scaled while worst-call values remain observed values.
The first 45 seconds are ignored by default so scene/world startup does not pollute runtime hitch statistics.
Hitch forensics
Significant hitches can create JSON captures under:
BepInEx/tickprofiler-forensics/
Each capture includes the hitch duration, estimated missed fixed deadlines, attribution/confidence, runtime context and the preceding performance samples. File output is serialized on a background worker so slow storage does not block the Valheim main thread.
Output
Normal output is written to:
- BepInEx/LogOutput.log
- BepInEx/tickprofiler-latest.txt
- BepInEx/tickprofiler-status.json
- BepInEx/tickprofiler-forensics/*.json for qualifying hitches
Touch BepInEx/tickprofiler.request to request an immediate full snapshot. The request file is polled at a configurable low rate rather than once per frame.
Client overlay
Install the same package on a Windows Valheim client and press F8 to toggle the overlay.
The client shows:
- Local FPS/frame-gap timing, stalls, CPU, RSS, managed memory and GC activity.
- Server effective tick rate and Update rate.
- Server runtime context and TickProfiler self-overhead.
- Top server consumers.
- Rolling five-minute client and server graphs.
- Exact server hitch-event markers at the time the hitch occurred rather than only at the next periodic snapshot.
- Snapshot age, server-side Steam transport ping for every connected player, and server/client protocol compatibility.
TickProfiler 1.0 uses protocol v2 while retaining legacy v1 hello/snapshot compatibility with 0.x clients/servers where possible. Overlay text is cached between refreshes to avoid allocating new strings every render frame.
Important server settings
Created in BepInEx/config/magicorp.valheim.tickprofiler.cfg:
- ReportIntervalSeconds = 10
- OverlayIntervalSeconds = 2
- RequestPollSeconds = 1
- StartupWarmupSeconds = 45
- DeepGameProfiling = true
- ProfilePluginLoops = true
- HotMethodSampleEveryN = 4
- TopConsumers = 12
- SpikeThresholdMs = 20
- MainThreadStallThresholdMs = 75
- WriteHitchForensics = true
- ForensicHitchThresholdMs = 100
- AnnounceHitchesInChat = true
- AnnounceHitchesInGame = false
- AnnounceHitchThresholdMs = 250
- AnnounceHitchCooldownSeconds = 10
ProfileModHarmonyMethods is retained only as a deprecated 0.x compatibility key and migrates to ProfilePluginLoops.
Validation
TickProfiler 1.0.0 is built against Valheim 1.0.14 and BepInExPack Valheim 5.4.2350.
The included core tests validate deadline accounting, Unity catch-up behavior, report-boundary pending misses, JSON escaping, hitch bu
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。 多人連線時,主機與所有用戶端需要安裝一致的模組。
下面這些內容需要先安裝,否則該模組不會生效: