IssueRaiser

Improve the performance of the GDScript VM through offline compilation

### Describe the project you are working on Godot ### Describe the problem or limitation you are having in your project Many users have complained for a long time about the performance in GDScript. For the GDScript 2.0 rewrite, a lot of work was put into making sure the VM has all the information required to generate optimized code, including type information, strict type checking, better addressing modes and the ability to access every operator, utility function, etc. as a C function pointer. This can be evidenced by the new [codegen class](https://github.com/godotengine/godot/blob/master/modules/gdscript/gdscript_codegen.h) used to emit code. Unfortunately, just the changes to the parser and compiler ended up being very significant so almost no optimization work could take place for the VM. ### Describe the feature / enhancement and how it helps to overcome the problem or limitation The idea is to use the the new type information as well as all the C function pointers to engine to generate direct executable code and bypass the VM, allowing for much greater performance when typed code is used. This is challenging to do in a practical way, however. Because of it, this is more of an open discussion on evaluating different alternatives. ### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams There are a few general approaches that could be taken to optimize GDScript: * JIT * real-time AOT * offline compilation. The problem with J

Posted by reduz on Jan 1, 2023, 8:45 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

github (Software)

Improve the performance of the GDScript VM through offline compilation

reduzJan 1, 2023, 8:45 AM

### Describe the project you are working on Godot ### Describe the problem or limitation you are having in your project Many users have complained for a long time about the performance in GDScript. For the GDScript 2.0 rewrite, a lot of work was put into making sure the VM has all the information required to generate optimized code, including type information, strict type checking, better addressing modes and the ability to access every operator, utility function, etc. as a C function pointer. This can be evidenced by the new [codegen class](https://github.com/godotengine/godot/blob/master/modules/gdscript/gdscript_codegen.h) used to emit code. Unfortunately, just the changes to the parser and compiler ended up being very significant so almost no optimization work could take place for the VM. ### Describe the feature / enhancement and how it helps to overcome the problem or limitation The idea is to use the the new type information as well as all the C function pointers to engine to generate direct executable code and bypass the VM, allowing for much greater performance when typed code is used. This is challenging to do in a practical way, however. Because of it, this is more of an open discussion on evaluating different alternatives. ### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams There are a few general approaches that could be taken to optimize GDScript: * JIT * real-time AOT * offline compilation. The problem with J

Comments (0)

No comments yet. Start the discussion.

Comment on this issue