Repository navigation
feat(mcp): add performance readout tools matching debug overlay (#468) - #711
Merged
Merged
Conversation
Profiler.Reset cleared the scope index and stopped any active trace recording, so game_perf_reset silently discarded a Chrome trace started from the dev console, and a scope token spanning the reset was charged to whichever new scope reused its ID. Reset now only zeroes each scope's accumulators and history.
Config.RenderStatsFunc returned render3d.RenderStats, so game/mcp imported game/render3d and every 2D game attaching the bridge linked nsgo/gpu, scene3d, particles and ktx2. It now returns mcp.PerfRender3DStats, which has the same fields as render3d.RenderStats, so a game converts with mcp.PerfRender3DStats(stats).
houko
force-pushed
the
feat/mcp-perf-readouts-468
branch
from
November 24, 2026 19:30
cc5bcf5 to
c234fb7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements MCP performance readout tools for #468 (parent: #460), exposing live frame timings, update/draw costs, draw statistics, per-frame allocations, GC/heap telemetry, asset memory, and profiler zones matching
game/debug's on-screen overlay.Changes
packages/game/mcp/perf.go&packages/game/mcp/mcp.go:Overlay,Profiler,GC,Memory,DrawStatsFunc, andRenderStatsFuncfields tomcp.Configand hookedb.perfTools()intoBridge.Tools().game_perf_readoutreturning exact overlay-matchedfps, rolling average and latestframe_ms/update_ms/draw_ms, min/max/p50/p95/p99 frame times, draw stats (draw_calls,sprites,batches,triangles,vertices), per-frame heap allocations (allocs_per_frame,alloc_bytes_per_frame,last_frame_allocs,last_frame_alloc_bytes),heap_bytes,gc_count, GC pause/hitch metrics, optionalrender3d(mcp.PerfRender3DStats, convertible fromrender3d.RenderStats) andasset_memory(debug.MemoryTracker) summaries, and optional chronologicalhistory/ profilerzones.game_perf_zoneslisting nameddebug.Profilerzones sorted by recent cost (last_ms,avg_ms,max_ms,calls).game_perf_resetresetting accumulated overlay frame timings, pushed draw stats, profiler zones, and GC monitor history.DisallowUnknownFields()decoding on all tools and graceful handling when subsystems are unconfigured.packages/game/debug:GCMonitorto sample/gc/heap/allocs:objectsand/gc/heap/allocs:byteswith zero steady-state allocations (AllocsPerFrame(),AllocBytesPerFrame(),Reset()).DrawStats,Options.DrawStats,Overlay.SetDrawStats,Overlay.DrawStats,Overlay.HasDrawStats,Overlay.ResetStats, andProfiler.Resetwith matching-tags releasestubs.packages/game/mcp/perf_test.goverifying exact parity againstdebug.Overlay(including rendered HUD text),render3d.RenderStats, standalone providers, reset behavior, and strict argument validation.docs/en/mcp.mdanddocs/zh/mcp.md, addedchangelog.d/mcp-perf-readouts-468.md, and added.agents/notes/implemented/feature/2026-11-24-mcp-performance-readouts.md.Verification
git ls-files -z -- '*.go' | xargs -0 -r gofmt -l(empty)go run ./cmd/gameschema -checkgo tool nsgo check -target macos,windows,linux,android,webgo tool nsgo test ./mcp(12 passed)go tool nsgo test ./debug(30 passed, includingTestGCMonitorZeroAllocsSteadyState)go build -tags release ./debug ./mcpgo tool nsgo test -run TestStabilityTable .(1 passed)go run ./tools/changelog checkbun run verify-notesCloses #468
Review follow-ups
Tools(), the package doc andExampleNew.Profiler.Resetnow only zeroes each scope's timings and history: scope IDs and any active trace recording survivegame_perf_reset, so a scope open across the reset is charged to its own name.Config.RenderStatsFuncreturnsmcp.PerfRender3DStats(same fields asrender3d.RenderStats, converted withmcp.PerfRender3DStats(stats)), sogame/mcpno longer importsgame/render3d.ResetStats,GCMonitor.Resetand per-frame allocation averages indebug.mdandgc-and-allocations.md(en and zh).