benilla-re systems structs docs

SetGcThreshold

function · lua · primitive

Address
0x6fae00 · 139 bytes, up to 0x6fae8a
Signature
void __fastcall (lua_State *L)
Meaning
Sets the next threshold to the count plus the larger of a quarter of it and the headroom, capped by pool space
Confidence
verified, proof one
Finding
lua/pools#the-threshold-a-collection-leaves
Test
lua::next_threshold_whole

Finding: The threshold a collection leaves in lua: block pools

The client replaces 5.0's threshold of twice the bytes in use with 0x6fae00(L), which checkSizes jumps to at the end of a collection. The headroom is the threshold [G+0x24] less the bytes in use [G+0x28] (luaM_irealloc's running sum of size changes), in 32 bits, lowered to the free bytes of each pool: its block size times its chunks' free counts summed, compared unsigned. The new threshold is the count plus the larger of the headroom and a quarter of the count, count >> 2. A pool with no chunk has no free bytes, so until every pool has a chunk the threshold is the count and a quarter.

The derivation is in the doc.

Callers 1

Callees 0

None by a direct call or jump.

Calls and jumps by a bare address, from tables/calls.tsv.