layout: restructure into src/ tests/ android/ scripts/ tools/

- extension/src/{port,platform,codepage} -> src/; native_render -> src/host
  (+ dxt, shaders/); libgr2 -> src/gr2; extension/third_party -> third_party
- extension/tests -> tests/port, libgr2/tests -> tests/gr2
- android-native -> android (build.sh, push-client.sh moved in)
- script -> scripts; tools/40250 -> tools/server; oracle -> tools/granny-oracle;
  perf tools -> tools/perf
- all build trees under build/ (native, release, android, port-gate)
- xrender:: CMake aliases -> mt::; port-map ledger impl paths rewritten

No code changes. ctest 15/15, port_gate macos+android PASS, port_map check 0 errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-29 19:08:19 +09:00
co-authored by Claude Opus 5.5
parent 70710477cf
commit a46093104c
2817 changed files with 13728 additions and 13744 deletions
+126
View File
@@ -0,0 +1,126 @@
#!/usr/bin/env python3
"""Summarises a native client --perf-log CSV (src/host/perf_log.h).
usage: perf_summary.py perf-YYYYMMDD-HHMMSS.csv [--all]
Only in-game rows (a map is loaded) are summarised unless --all is given. Prints the median of each
frame-time section so the largest cost stands out, the worst windows, thermal/clock trend and the
"# hitch" lines.
"""
import csv
import statistics
import sys
SECTIONS = [
("frame_ms", "whole frame"),
("app_ms", " script thread (AppFrame)"),
("net_ms", " network"),
("camera_ms", " camera/resource"),
("update_game_ms", " UpdateGame"),
("render_game_ms", " RenderGame"),
("shadow_raster_ms", " CPU shadow raster"),
("py_ms", " Python callbacks (incl. Update/RenderGame)"),
("handoff_ms", " baton handoff"),
("pace_ms", " fps-cap sleep (before the frame)"),
("host_ms", " host UI/audio"),
("render_ms", " renderer"),
("sync_ms", " fence wait + acquire"),
("fence_ms", " frame-slot fence wait"),
("prepare_ms", " prepare (incl. uploads)"),
("geo_upload_ms", " geometry uploads"),
("tex_upload_ms", " texture uploads"),
("submit_ms", " submit"),
("present_ms", " present"),
("gpu_ms", " GPU (timestamps)"),
]
def num(row, key):
try:
return float(row.get(key, "") or "nan")
except ValueError:
return float("nan")
def median(rows, key):
values = [num(r, key) for r in rows]
values = [v for v in values if v == v]
return statistics.median(values) if values else float("nan")
def main():
args = [a for a in sys.argv[1:] if not a.startswith("--")]
if not args:
sys.exit(__doc__)
path = args[0]
comments, lines = [], []
with open(path, encoding="utf-8", errors="replace") as f:
for line in f:
(comments if line.startswith("#") else lines).append(line)
rows = list(csv.DictReader(lines))
if "--all" not in sys.argv:
rows = [r for r in rows if r.get("map")]
print(path)
for c in comments[:2]:
print(c.rstrip())
if not rows:
print("no in-game rows (use --all to include the login/select screens)")
return
duration = num(rows[-1], "t_s") - num(rows[0], "t_s")
print("%d windows, %.0f s in game, maps: %s" % (len(rows), duration, ", ".join(sorted({r["map"] for r in rows}))))
print("display %s Hz app vsync (render_hz) median %.1f fps cap %s" % (
"/".join(sorted({r.get("refresh_hz", "?") for r in rows})), median(rows, "render_hz"),
rows[-1].get("fps_cap", "?")))
print("median fps %.1f frame p95 %.1f ms jank>33ms %d frames jank>50ms %d frames" % (
median(rows, "fps"), median(rows, "frame_p95_ms"),
sum(int(num(r, "jank33")) for r in rows), sum(int(num(r, "jank50")) for r in rows)))
if "power_mw" in rows[0]:
# power_mw is -1 in a window with any sample on the charger: the battery current is then the
# charger's surplus, not the app's draw. Split by frame-rate mode and idle.
print("power (battery, unplugged windows only; plugged windows show current only)")
groups = {}
for r in rows:
groups.setdefault((r.get("fps_mode", "?"), r.get("idle", "?")), []).append(r)
for (mode, idle), rs in sorted(groups.items()):
powered = [r for r in rs if num(r, "power_mw") >= 0]
print(" mode %s%s: %d windows fps %.1f %s current %.0f mA" % (
mode, " idle" if idle == "1" else "", len(rs), median(rs, "fps"),
("power %.0f mW (%d windows)" % (median(powered, "power_mw"), len(powered))) if powered
else "power n/a (plugged)", median(rs, "batt_ma")))
print("median actors %.0f draws %.0f skinned %.0f python calls/frame %.0f (missing %.0f)" % (
median(rows, "actors"), median(rows, "draws"), median(rows, "skinned_draws"),
median(rows, "py_calls"), median(rows, "py_missing")))
print("uploads/frame: geometry %.1f (%.1f KB) texture %.2f (%.0f KB)" % (
median(rows, "geo_uploads"), median(rows, "geo_kb"), median(rows, "tex_uploads"), median(rows, "tex_kb")))
print()
print("median ms per frame")
for key, label in SECTIONS:
print(" %-48s %7.2f" % (label, median(rows, key)))
print()
print("worst windows (lowest fps)")
for r in sorted(rows, key=lambda r: num(r, "fps"))[:5]:
print(" t=%6.0fs fps=%5.1f frame=%5.1f app=%5.1f render_game=%5.1f render=%5.1f sync=%5.1f gpu=%5.1f "
"actors=%s thermal=%s cpu_mhz=%s" % (
num(r, "t_s"), num(r, "fps"), num(r, "frame_ms"), num(r, "app_ms"), num(r, "render_game_ms"),
num(r, "render_ms"), num(r, "sync_ms"), num(r, "gpu_ms"), r.get("actors"), r.get("thermal"),
r.get("cpu_mhz")))
step = max(1, len(rows) // 8)
print()
print("trend (thermal: 0 none .. 3 severe; -1 unknown)")
for r in rows[::step]:
print(" t=%6.0fs fps=%5.1f thermal=%s batt=%s C cpu_mhz=%s (max %s) rss=%s MB" % (
num(r, "t_s"), num(r, "fps"), r.get("thermal"), r.get("batt_c"), r.get("cpu_mhz"),
r.get("cpu_max_mhz", "?"), r.get("rss_mb")))
hitches = [c.rstrip() for c in comments if c.startswith("# hitch")]
if hitches:
print()
print("%d hitches >= 100 ms (first 10)" % len(hitches))
for h in hitches[:10]:
print(" " + h[2:])
if __name__ == "__main__":
main()
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
# Copies the Android client's --perf-log files (src/host/perf_log.h) to ./perf-logs and prints a
# summary of the newest one. The phone must be connected with USB debugging; the files can also be
# taken off the phone without a PC from Android/data/org.metin2port.client/files/perf.
set -e
PKG=org.metin2port.client
OUT=${1:-perf-logs}
mkdir -p "$OUT"
adb pull "/sdcard/Android/data/$PKG/files/perf/." "$OUT"
newest=$(ls -t "$OUT"/perf-*.csv 2>/dev/null | head -1)
[ -n "$newest" ] && python3 "$(dirname "$0")/perf_summary.py" "$newest"