Skip to content

LuaJIT GMNGC - An uplift to LuaJIT's Stock Allocator & GC #5

Description

@blueshank-gh

Over the past year, I have worked on getting a much more updated GC that currently the Stock LuaJIT 2.1.0-beta3 does not have.

This is based on Mike's now forgotten 3.0 Proposal Sheet, which indicates improvements directly tied to the GC itself.

  • Arena allocator - A new arena-based allocator that groups objects into large, aligned memory blocks, an alternative to the stock heap allocator.

  • Generational collector - Objects are organized into minor and major so that long-lived objects aren't re-scanned on every cycle.

  • Quad-color marking - From Mike's 3.0 concept paper, splitting gray into light-gray and dark-gray so the write barrier only has to check a single gray bit (a 2-3 instruction fast path).

  • Immortal internals - Core always-present LuaJIT objects (main thread, registry, globals, interned keyword/error/FFI-type strings, etc.) are treated as permanent, kept alive and skipped by normal sweeping since they should always exist.

  • Smart Promotion - Certain objects in LuaJIT can be auto-set to the highest tier, in this case proto's and their constants to reduce GC overhead further in tier 0.

  • 2.1.0-beta3 base - Deliberately kept on 2.1.0-beta3 (a stable base for embedded/game-engine use) rather than rolling release, with select patches carried forward.

Image
LuaJIT x64 - Stock vs GMNGC (my new GC)
Mops/s - Memory Operations per Second
gen_churn Mops/s - 18.8 - 29.9 - 1.59x - ~59% improvement
gen_churn time - 0.27s - 0.17s - 0.63x - ~37% improvement
gen_churn peak heap - 33.4 MB - 22.5 MB - 0.67x - ~33% improvement
closure_alloc Mops/s - 20.2 - 22.5 - 1.11x - ~11% improvement
str_intern Mops/s - 15.9 - 16.8 - 1.06x - ~6% improvement
jit_numeric Mops/s - 769 - 769 - 1.00x - none
tab_alloc Mops/s - 37.6 - 31.5 - 0.84x - ~16% loss (don't have full fit allocator just yet so yea)
full_gc ms - 24.6 - 28.2 - 1.15x - ~15% loss (expected since major minor root chain but this can be improved clearly)
baseline heap - 50.2 KB - 53.9 KB - 1.07x - ~7% loss (inevitable due to bitmap overhead and headers from arena)

I am in the process of ironing out UAF & UB failures from this project before releasing here. (Currently it works but infested with time-based UAF & UB failures, that will only be found overtime as I continue to test it)

  • - Release to LJPatch OSS
  • - Add ability to unwind JIT'ed code for isolating loop crashes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-sensitiveThis issue involves architecture breaking/changing featuresenhancementNew feature or requestplatform:linuxplatform:windowsrefactorThis changes a majority of the source code, creating risks of incompatibility

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions