luagc: 5.1 incremental GC with timing, stress tests, pre-alloc hooks (BROKEN)

Current state CRASHES on load due to pre-alloc hooks with wrong calling
conventions. pushcclosure hook is still enabled with partially disabled
others. Needs all pre-alloc hooks disabled or CCs fixed before use.

Implemented:
- Full 5.1 tri-color incremental GC
- 5.1-style singlestep budget loop (replaces chunk-based approach)
- Per-step rdtsc timing (ZGCStats returns max_step_us, atomic_us)
- Configurable gcstepsize/gcstepmul/gcpause via ZGCTune()
- Pre-alloc GC hooks for 7 API functions (5.1 luaC_checkGC pattern)
- Stress test addon: /gclife, /gcsweep, /gccompare

Broken:
- Pre-alloc hooks have CC mismatches causing immediate crash on load
- pushfstring is cdecl variadic, not fastcall (removed)
- pushstring has ambiguous CC (removed, covered by pushlstring)
- pushcclosure hook still active -- may be causing the crash
- Half-initialized objects cause garbage gcptr under heavy stress

weirdperformance: re-enabled luagc.install() + luastr + luavm
This commit is contained in:
MarcelineVQ
2026-04-11 13:03:37 -07:00
parent 8d3460cf1e
commit 039cec1806
7 changed files with 1255 additions and 136 deletions
+12 -3
View File
@@ -44,6 +44,8 @@ const cull_sse = @import("cull_sse.zig");
const silicon_sse = @import("silicon_sse.zig");
const luaalloc = @import("luaalloc.zig");
const luagc = @import("luagc.zig");
const luastr = @import("luastr.zig");
const luavm = @import("luavm.zig");
const renderParticleSprites_SSE = particle_sse.renderParticleSprites_SSE;
const resetParticleCache = particle_sse.resetParticleCache;
@@ -326,9 +328,14 @@ pub fn installHooks() void {
// libdeflate inflate replacement
if (inflate_hook.install()) installed += 1;
// Lua slab allocator + GC: owned by luagc module.
// installed += luaalloc.install();
// installed += luagc.install();
// Lua slab allocator replacement
installed += luaalloc.install();
installed += luagc.install();
installed += luastr.install();
installed += luavm.install();
}
pub fn lateInit() void {
@@ -338,6 +345,8 @@ pub fn lateInit() void {
pub fn removeHooks() void {
if (g_is_hook_owner) {
luavm.remove();
luastr.remove();
luaalloc.dumpStats();
luagc.dumpStats();
filecache.remove();