Skip to content

Fast-path UserData member access via ILuaUserData.TryIndex. #234#316

Open
ModMaker101 wants to merge 1 commit into
nuskey8:mainfrom
ModMaker101:feat/234-faster-iluauserdata-indexing
Open

Fast-path UserData member access via ILuaUserData.TryIndex. #234#316
ModMaker101 wants to merge 1 commit into
nuskey8:mainfrom
ModMaker101:feat/234-faster-iluauserdata-indexing

Conversation

@ModMaker101

Copy link
Copy Markdown

Description

Add a TryIndex fast path to ILuaUserData that bypasses the metatable chain for known member lookups. Overall reducing overhead for proerty and method access on Userdata types.

Changes

  • Add TryIndex to ILuaUserData.
  • Wire TryIndex into all four VM slow-path methods.
  • Emit TryIndex in the [LuaObject] source gens.
  • Implement TryIndex on FileHandle for less overhead method dispatch.

Results

Before with the DoString benchmark (on my computer) I got a result of 10.56 ms, after my update it went down to 9.16 ms, or a +13.2% gain. Likewise, with DoFileAsync, I got a result of 9.627 ms, afterwards 9.22, or a gain of +4.2%. Now granted this speedup is on smaller functions, if this speedup was applied on heavier workloads, it would most likely perform much better.

All 267 tests pass. Ready for review

Related

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.

Faster ILuaUserData indexing.

1 participant