Skip to content

perf: enable faster Ace bootstrap with targeted exports - #5146

Open
RomainLanz wants to merge 1 commit into
7.xfrom
perf/targeted-bootstrap-exports
Open

perf: enable faster Ace bootstrap with targeted exports#5146
RomainLanz wants to merge 1 commit into
7.xfrom
perf/targeted-bootstrap-exports

Conversation

@RomainLanz

Copy link
Copy Markdown
Member

Hey! 👋

Importing bootstrap primitives from @adonisjs/core evaluates the root entrypoint and its aggregated error namespaces. Light Ace commands therefore load modules they never use.

This PR adds coherent targeted exports:

  • @adonisjs/core/ignitor exports Ignitor and prettyPrintError
  • @adonisjs/core/generators exports indexEntities
  • @adonisjs/core/config now also exports configProvider

All root exports remain available for backward compatibility. The add command also imports prettyPrintError directly from its owning module.

Measured impact

The benchmark uses the official Hypermedia starter generated with:

npm create adonisjs@3.4.0 perf-adonis-hypermedia -- --kit=hypermedia --pkg=npm --skip-migrations

The optimized fixture switches the generated bootstrap files, adonisrc.ts, Auth, and Session away from the root export. Those consumer changes will be proposed separately.

Values are wall-clock medians with [p05, p95].

Runtime Command Before After Delta Peak RSS
Node 24.20 node ace --help 359.47 ms [319.53, 394.04] 285.68 ms [250.89, 314.37] -73.79 ms (-20.5%) -10.20 MiB
Node 26.5 node ace --help 359.86 ms [307.99, 396.53] 280.98 ms [251.82, 313.49] -78.88 ms (-21.9%) -10.49 MiB
Node 24.20 node ace test --help 360.76 ms [323.46, 396.24] 293.91 ms [256.57, 324.01] -66.85 ms (-18.5%) -10.46 MiB
Node 26.5 node ace test --help 353.14 ms [317.27, 394.58] 285.85 ms [252.44, 312.68] -67.29 ms (-19.1%) -10.21 MiB

Each variant ran in 50 fresh processes after 5 warmups. Execution order was randomized with a fixed seed, processes were pinned to one CPU, output was discarded, and no outliers were removed. Wall time and peak RSS came from perf_counter_ns and wait4.

An isolated import of Ignitor, prettyPrintError, and indexEntities drops from 209.02 ms to 89.64 ms on Node 24 and from 203.96 ms to 83.06 ms on Node 26. Unique loaded ESM modules drop from 181 to 58.

The signal is intentionally scoped to light CLI startup. A full list:routes boot improves by 4.0% on Node 24 and 1.8% on Node 26, where timing distributions overlap. A real test run was inconclusive, so this does not claim faster tests or production server startup.

Resolver tracing found two root imports during ace --help and six during list:routes before the consumer changes, and none afterward.

Validation

  • npm run build
  • npm run typecheck
  • 16 focused Ignitor, generator, and error-printer tests
  • 32 add and configure tests with the CI version of pnpm
  • packed tarball imported successfully under Node 24.20 and 26.5, with root and targeted exports preserving symbol identity

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