Tech News
← Back to articles

Show HN: Elysia JIT "Compiler", why it's one of the fastest JavaScript framework

read original related products more articles

Are you an LLM? You can read better optimized documentation at /internal/jit-compiler.md for this page in Markdown format

JIT "Compiler" Internal ​

Elysia is fast and will likely remain one of the fastest web frameworks for JavaScript only limited by the speed of the underlying JavaScript engine.

21x faster than Express 6x faster than Fastify Elysia Bun 2,454,631 reqs/s Gin Go 676,019 Spring Java 506,087 Fastify Node 415,600 Express Node 113,117 Nest Node 105,064 Measured in requests/second. Result from TechEmpower Benchmark Round 22 (2023-10-17) in PlainText

Elysia speed is not only acheived by optimization for specific runtime eg. Bun native features like Bun.serve.routes . But also the way Elysia handles route registration and request handling.

Elysia has an JIT "compiler" embedded within its core since Elysia 0.4 (30 Mar 2023) at (src/compose.ts) using new Function(...) or also known as eval(...) .

The "compiler" is not a traditional compiler that translates code from one language to another. Instead, it dynamically generates optimized code for handling requests based on the defined routes and middleware. (Which is why we put compiler in quotes.)

When request is made to Elysia application for the first time for each route, Elysia dynamically generates optimized code specifically tailored to handle that route efficiently on the fly avoiding unnecessary overhead as much as possible.

Static Code Analysis (Sucrose) ​

"Sucrose" is the nick name for the static code analysis module living alongside Elysia's JIT "compiler" at (src/sucrose.ts).

... continue reading