Skip to content

Add multi-state sessions, CPU v2 profiles, and regression tests - #1

Merged
esrrhs merged 1 commit into
masterfrom
feat/multi-state-and-pprof-v2
Dec 1, 2026
Merged

esrrhs merged 1 commit into
masterfrom
feat/multi-state-and-pprof-v2

Conversation

@esrrhs

@esrrhs esrrhs commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to pLua's November tooling and session work, adapted to vLua's SIGPROF C-function sampler (Linux only; no Windows port).

  • CPU v2 .pro files with pLua-compatible metadata (magic / version / kind / SIGPROF backend / interval). Legacy readers that walk from the tail still work.
  • tools/vlua -proto writes gzip profile.proto for modern go tool pprof (no third-party Go deps). -pprof and -flame/-collapsed are unchanged. Converter has go test coverage.
  • Per-lua_State sessions: stopping one session does not stop others. New Lua APIs: status(), close(), set_config() / get_config(), and an optional start(func, path, interval_ms) argument. hookso lrealstart / lrealstop signatures are unchanged.
  • Clear errors when the target C function is missing, the binary looks stripped, or the VM is not Lua 5.3.x.
  • Real CI regressions: hotspot ranking assertions (calc_damage / update_kill ahead of colder paths), function-name recovery without host luac/./pprof, API and not-found tests, two-state unit test, hot-reload stress (crash = fail). Optional bench_vlua.lua stays out of CI.
  • CI: drop the removed google-perftools apt package; install Go pprof instead. Linux remains the only CI target.

Lua 5.4 is explicitly out of scope. Sessions are not OS-thread safe (same limitation as pLua). The SIGPROF path still does no Lua API calls, allocations, or locks.

On optimized Lua builds, luaH_getshortstr is often inlined into luaH_get; attribution tests sample luaH_get for that reason. This is documented in the READMEs.

Test plan

  • cmake --build build (Release, BUILD_TESTING=ON)
  • ctest --test-dir build --output-on-failure — 8/8 passed locally
  • go test in tools/
  • tools/show.sh ../test (flame + proto); go tool pprof -top reads the v2 proto
  • GitHub Actions on this PR

Align vLua with recent pLua tooling and session APIs: write CPU v2
.pro metadata, add tools/vlua -proto export with Go tests, and replace
the removed google-perftools apt package in CI.

Give each lua_State its own profiler session with status/close/config
and a configurable SIGPROF interval, keep hookso lrealstart/lrealstop,
and return clear errors when the target C function cannot be found.

Register attribution ranking, API, hot-reload stress, converter, and
two-state unit tests in ctest. Document Lua 5.3.x-only support.
@esrrhs
esrrhs merged commit 56a4d19 into master Dec 1, 2026
1 of 2 checks passed
@esrrhs
esrrhs deleted the feat/multi-state-and-pprof-v2 branch December 2, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant