+ Reply to Thread
Results 1 to 5 of 5

  Click here to go to the first Rift Team post in this thread.   Thread: Lua string references within the client

  1. #1
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default Lua string references within the client

    So this is rather a technical question which can be probably answered only by the evil overlord himself:

    Does the client keep Lua references to the strings which are returned by the API, like the .type member from Inspect.Item.Detail(), (for example using luaL_ref/luaL_unref) or are the Lua strings only temporary and created/dumped on each call? This is quite important to me in order to decide on whether (and if so, how) to cache stuff coming from the API. Especially when it comes to GC lifetimes. It might also be relevant to the performance impact of some API methods. Maybe.
    Author of the Imhothar's Bags addon.

  2.   Click here to go to the next Rift Team post in this thread.   #2
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by Imhothar View Post
    So this is rather a technical question which can be probably answered only by the evil overlord himself:

    Does the client keep Lua references to the strings which are returned by the API, like the .type member from Inspect.Item.Detail(), (for example using luaL_ref/luaL_unref) or are the Lua strings only temporary and created/dumped on each call? This is quite important to me in order to decide on whether (and if so, how) to cache stuff coming from the API. Especially when it comes to GC lifetimes. It might also be relevant to the performance impact of some API methods. Maybe.
    At the moment, created and dumped on each call - it wouldn't surprise me if _ref/_unref were actually slower.

    Obviously this may change without warning :V

  3. #3
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Quote Originally Posted by ZorbaTHut View Post
    At the moment, created and dumped on each call - it wouldn't surprise me if _ref/_unref were actually slower.

    Obviously this may change without warning :V
    Well it depends I guess. One could keep some (very) frequently occurring strings (especially the enumeration values, like .bind, .category, .stats, etc which have fixed values) persisted in the Lua envirnoment, which is then a simple rawgeti() instead of pushstring(), but that would only work if the values inside the client were mapped integers and not strings as otherwise that would make the whole procedure just shift to a different location.

    I was actually hoping to have at least the itemid/abilityid/etc strings ref'ed in Lua so one could make use of some weak reference magic, but alas it seems not.
    Author of the Imhothar's Bags addon.

  4.   This is the last Rift Team post in this thread.   #4
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by Imhothar View Post
    Well it depends I guess. One could keep some (very) frequently occurring strings (especially the enumeration values, like .bind, .category, .stats, etc which have fixed values) persisted in the Lua envirnoment, which is then a simple rawgeti() instead of pushstring(), but that would only work if the values inside the client were mapped integers and not strings as otherwise that would make the whole procedure just shift to a different location.
    The problem is that this requires polluting the global registry table rather badly. I'm not sure that's even supported, to be honest, I think you're intended to make tables within that table.

  5. #5
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Quote Originally Posted by ZorbaTHut View Post
    The problem is that this requires polluting the global registry table rather badly. I'm not sure that's even supported, to be honest, I think you're intended to make tables within that table.
    That isn't really a problem at all as you can use ref/unref for any table you like, it's not required to be LUA_REGISTRYINDEX. The second parameter to luaL_ref specifies the table in which the reference should be stored, and that can be any valid table specifier (including a table on the stack at index -2 for example). Even if LUA_REGISTRYINDEX was used I wouldn't call it "polluting" as that table was specifically created for exactly this purpose
    Author of the Imhothar's Bags addon.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts