Skip to content

Question about determinism #601

Closed
Closed

Description

@encloinc

I looked into LUAU but couldn't find any information pertaining to this. Does mlua provide a way to interpret a script OP_CODE by OP_CODE?

Example: lets say I wanted to deterministically run lua scripts where I can guarantee the output on any machine, and I assign each opcode a "cost" and have a "max cost" for the script - which all machines respect. How would I go about this with mlua?

I know theres ways to terminate a lua script after x time with LUAU, but even then I cant guarantee determinism because different machines might deviate from how much is actually ran during this window of time.

Thanks in advance!

Activity

  1. khvzak commented on Jun 18, 2025

    @khvzak
    Member

    Luau has debug api (lua_singlestep) that allow to stop execution after each instruction.
    mlua does not support yet this api through safe interface, as it's designed for debugging only and the costs would be huge.

    Most practical option with low overhead would be using interrupts and stop execution (or yield) if time limit is exceeded. This is supported by mlua.
    I'm sure that interrupts are run at specific deterministic points that are machine independent.

  2. locked and limited conversation to collaborators on Jun 25, 2025
  3. converted this issue into a discussion #608 on Jun 25, 2025
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