Skip to content

How much more optimization is possible? #70

Open

Description

@oxysoft

Hello! we have used MoonSharp extensively in our game and the poor performance are starting to catch up onto us. Calls like Script.DoString result in a long chain of statement objects that unfold recursively. It seems that each opcode and structural element is an object! Crazy! In WattleScript, I notice that the statement objects are still class, so I am wondering what is the work that has been done in optimization so far, and whether we can do more as well, and what are some of the limitations. The DynValue is a very convenient type used all over MoonSharp, and turning it into a struct seems like it would require a fundamental rewrite.
Cheers!

Activity

  1. CallumDev commented on Nov 3, 2024

    @CallumDev
    Contributor

    Hi,

    The main optimizations applied on top of MoonSharp are:

    As you've noticed, statement is still a class - but statement is part of the syntax tree used when compiling to opcodes. You have the option of dumping bytecode to a binary format used by wattle, which you can load at runtime without compiling the script again. This format is not stable, however, and it may be best for stability's sake to continue using DoString.

    I would strongly recommend dropping in WattleScript and swapping your namespace references around to see the difference in performance and evaluate if that is enough for you. The low hanging fruit have pretty much all been picked, and further performance gains would probably come from rewriting the stack based bytecode compiler to be register based like Lua.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions