Skip to content

ESP32 JIT compiler. #9943

Closed
Closed
@RSC-Games

Description

@RSC-Games

I am aware that JIT was previously mentioned in #4085, but I'm willing to work on this, so please hear me out.

I'm in the process of building a game console that utilizes MicroPython. I started over a year ago and I'm getting close to done but I have a few issues. I've been puzzling for a while how to make MicroPython faster. I know I can write C modules for certain functionality and APIs, but game developers only have access to natmod, and the viper and native decorators. I could be wrong, but I noticed that the code compiled by the viper and native decorators sticks around long after its needed. Also, I can only fit small amounts of code into IRAM. So when using large amounts of code that needs to run natively and at the same time, you run out of RAM.

So, after a few weeks of thought (and a lot of time spent playing on emulated consoles), I finally got an idea: a JIT Compiler. It will definitely increase memory usage and code size but it would result in significant speed boosts in certain cases.

So, if I'm remembering correctly, a JIT consists of the following components:

  1. Compiler (Already mostly implemented for xtensawin thanks to the viper and native decorators)
  2. Code analyzer. I feel like this would take a lot of memory and CPU time, but there's probably a way to minimize this.
  3. Cache. This would take a lot of RAM so this may need to be limited in size/entries or just not exist.
  4. Linker. If "hot" code is compiled by the JIT then we need to execute the instructions and not the bytecode. Then we'll have to relink it once this code is evicted from cache.
  5. Code pools. This is where we store the actively executing code.

This looks like a pretty complex system (and I'm sure the current compiler takes an input file to compile and not just a function but I could be wrong) and it would take a lot of time and effort to make a decent JIT.

I'm willing to do most if not all of the work on this. If @dpgeorge you have any suggestions please let me know. And if this JIT turns out to work pretty well, then I'll submit a PR to merge this into MicroPython as an optional component because I'm sure most people don't need a JIT and it will take a lot of memory (especially IRAM).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, new feature implementations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy