Skip to content

Extract parent proxy handlers and simplify parent-member lookup#2384

Open
PJacek wants to merge 2 commits into
PathOfBuildingCommunity:devfrom
PJacek:fix-new-tracing
Open

Extract parent proxy handlers and simplify parent-member lookup#2384
PJacek wants to merge 2 commits into
PathOfBuildingCommunity:devfrom
PJacek:fix-new-tracing

Conversation

@PJacek

@PJacek PJacek commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Description of the problem being solved:

JIT traces were aborting due to per-instance dynamic metamethods and anonymous closures created for parent lookups and constructor calls.

Example trace aborts:

[TRACE --- (969/3) ModStore.lua:99 -- NYI: bytecode FNEW   at Common.lua:131]
[TRACE --- CalcPerform.lua:41 -- inner loop in root trace at Common.lua:123]
[TRACE --- (165/2) ModList.lua:87 -- NYI: bytecode FNEW   at Common.lua:131]
[TRACE --- PassiveSpec.lua:1199 -- inner loop in root trace at Common.lua:104]
[TRACE --- PassiveSpec.lua:1121 -- inner loop in root trace at Common.lua:104]
[TRACE --- Common.lua:102 -- inner loop in root trace at Common.lua:104]
[TRACE --- CalcSetup.lua:890 -- inner loop in root trace at Common.lua:104]
[TRACE --- (997/2) ModList.lua:87 -- NYI: bytecode FNEW   at Common.lua:131]
[TRACE --- Common.lua:122 -- NYI: bytecode FNEW   at Common.lua:131]
[TRACE --- (997/2) ModList.lua:87 -- NYI: bytecode FNEW   at Common.lua:131]
[TRACE --- (997/2) ModList.lua:87 -- NYI: bytecode FNEW   at Common.lua:131]

Changes made:

  • Extracted reusable local helper functions parentIndex and parentCall.
  • Updated proxy metatables to store _parent and _object and reuse the extracted handlers instead of creating new anonymous closures per parent.
  • Simplified parent-to-child member resolution to avoid dynamic per-object __index logic.

Impact:

  • Behaviour is unchanged for normal usage but members added to a parent after child classes are created will no longer automatically become visible to existing children.
  • No more FNEW trace aborts (verified using jit.v). While the exact counts vary between runs due to non-deterministic nature of the JIT, I observed fewer abort and more successful traces in Common.lua.
  • Possible slight performance increase. Because of run-to-run variance I’m not presenting hard numbers, but I believe this change is a net positive for interaction with the rest of the codebase.

@PJacek PJacek added pob1 Should also be merged into PoB1 Repo technical Hidden from release notes labels Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pob1 Should also be merged into PoB1 Repo technical Hidden from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant