Skip to content

Nest 3/4: compile hello-nest ahead of time - #8

Draft
puskuruk wants to merge 6 commits into
nest/platform-node-vendorfrom
nest/aot-hello-nest
Draft

puskuruk wants to merge 6 commits into
nest/platform-node-vendorfrom
nest/aot-hello-nest

Conversation

@puskuruk

@puskuruk puskuruk commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

apps/hello-nest (a decorated controller on NodeAdapter, @nestjs/core 12.2.0) compiles with geatsc. tools/nest/aot resolves @Module, @Controller, @Injectable and the route decorators with the TypeScript checker into a generated module function; scripts/build.mjs runs it as a compiler source-transform plugin, and reflect-metadata and the three @nestjs packages map to typed shims the generated application drives.

The app was added on 12.1.3; the last commit moves it to the 12.2.0 tarballs of Nest 2/4 and ports 12.2.0's adapter exception mapping into the core shim: an http-errors style client error (body parser, URI too long) becomes an HttpException with its status and message, a 5xx one stays an unknown exception.

Builds with the published compiler 1.0.47, which carries the four fixes this needed (geastack/compiler#7 to geastack/compiler#10). The package.json floor is still ^1.0.43; raising it is open.

  • b2c005b Add tools/nest/aot: resolve @module, @controller, @Injectable and the route decorators with the checker into a generated module function
  • ac20079 Map reflect-metadata and @nestjs/common, core and platform-node to typed shims the AOT-generated application drives
  • 3cf52e7 Rewrite a Nest entry through the AOT resolver as a compiler source-transform plugin in build.mjs
  • 843f567 Add hello-nest on NodeAdapter with platform-node 12.1.3
  • ff92b5d Add scripts/test-hello-nest.mjs comparing the compiled hello-nest against its Node oracle over eleven requests
  • df1a705 Move hello-nest to platform-node 12.2.0 and map client http-errors as the adapter does

Verification on df1a705 with 1.0.47: node scripts/test-hello-nest.mjs → HELLO_NEST_PARITY: 10 of 11 identical. The one deviation is the JSON.parse error message wording on POST /json with a malformed body, which geastack/compiler#21 fixes: built with the compiler stack https://github.com/geastack/compiler/pull/22 the same app answers 11 of 11. tools/nest check 24 tables passed; the other 32 scripts/test-*.mjs pass.

Benchmark

Same app under Node and compiled, bench/http-matrix.py (Nest 4/4), 2026-10-25, arm64 Ubuntu 24.04 container on an 8-vCPU Colima VM (Apple M1), VM and host otherwise idle, compiler 1.0.47: 2 s warmup, 8 s samples, wrk -t4 -c64, three interleaved rounds, server on vCPUs 0-3, wrk on 4-7. Not the bench host, so compare ratios, not absolute sizes, across runs.

Server 1w / 1w /json 1w PSS MiB 1w startup ms 4w / 4w /json 4w PSS MiB 4w startup ms 4w p50 4w p99
nest-gea 121,585 114,648 9.6 12 324,514 314,454 11.2 12 148 µs 736 µs
nest-node 54,336 52,106 118.5 498 175,532 165,650 350.7 924 318 µs 1.66 ms
hono-gea 153,784 121,440 6.4 7 376,158 323,931 8.5 8 128 µs 844 µs
hono-node 32,085 29,943 115.9 65 99,174 90,035 255.5 103 571 µs 2.02 ms
gea-raw 232,639 229,654 4.5 9 459,725 474,422 5.9 7 96 µs 1.68 ms
node-raw 58,188 57,713 88.1 53 180,682 177,656 182.4 76 302 µs 1.17 ms

GET /: compiled Nest 2.24× Nest on Node at one worker and 1.85× at four, 1.80× bare node:http on Node, 0.86× compiled Hono; PSS 1/31; startup 12 ms against 498 ms and 924 ms. Binary 8,016,904 bytes. Raw records and the full ten-server table are in Nest 4/4.

Related

Stack: #6 (1/4) → #7 (2/4) → this PR → #9 (4/4, benchmark harness and raw records). Parity 11 of 11 needs geastack/compiler#21 (stack https://github.com/geastack/compiler/pull/22).

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@puskuruk

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@puskuruk
puskuruk force-pushed the nest/platform-node-vendor branch from be6383d to beb3f1d Compare October 20, 2026 04:33
@puskuruk
puskuruk force-pushed the nest/aot-hello-nest branch from 714d794 to f6c7b52 Compare October 20, 2026 04:33
@puskuruk
puskuruk force-pushed the nest/platform-node-vendor branch from beb3f1d to aeb89ff Compare October 23, 2026 01:48
@puskuruk
puskuruk force-pushed the nest/aot-hello-nest branch from f6c7b52 to 00d3cba Compare October 23, 2026 01:48
@puskuruk
puskuruk force-pushed the nest/platform-node-vendor branch from aeb89ff to 6dbe313 Compare October 23, 2026 09:17
@puskuruk
puskuruk force-pushed the nest/aot-hello-nest branch from 00d3cba to 2663870 Compare October 23, 2026 09:17
… the adapter does

hello-nest depends on the 12.2.0 tarballs the pinned builder now packs.

The core shim follows 12.2.0's NodeAdapter exception mapping: an
http-errors style client error (body parser, URI too long) becomes an
HttpException with its status and message (the status text when it must
not be exposed); a 5xx one stays unmapped and is answered as an unknown
exception.
@puskuruk
puskuruk force-pushed the nest/aot-hello-nest branch from 2663870 to df1a705 Compare October 25, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant