Skip to content

perf(model): construct model instances without the DI resolve + reflective invoke - #3464

Merged
bpamiri merged 1 commit into
developfrom
perf/model-create-fast-path-3213
Aug 31, 2026
Merged

bpamiri merged 1 commit into
developfrom
perf/model-create-fast-path-3213

Conversation

@bpamiri

@bpamiri bpamiri commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Part of #3213 — the third and final hot-path cut on model materialization.

What changed

  1. $createObjectFromRoot model fast path — the $initModelObject branch now does a direct CreateObject + structured call and runs onDIcomplete manually, skipping the DI container's resolve/auto-wire ($resolveInitArguments metadata scan) and the reflective Invoke() on the framework's hottest path. Models explicitly mapped in the container keep the legacy path via the new Injector.hasExplicitMapping().
  2. $initModelObject class read without the lock — application.wheels.models[name] is only written after the class is fully built, so a present entry is always complete; the per-instance $simpleLock was pure overhead (concurrent first loads still go through the locked slow path).

Measured (#3213 rig, Lucee 7, H2, warmed)

Verification

…ctive invoke

Two more #3213 hot-path cuts on top of the #3462 inheritance fast path:

1. $createObjectFromRoot's model-instance branch ($initModelObject) now
   does a direct CreateObject + structured $initModelObject call and runs
   onDIcomplete manually — skipping the DI container's resolveMapping /
   $resolveInitArguments auto-wiring and the reflective Invoke() on the
   hottest path in the framework. Models explicitly mapped in the
   container (map/to/toFactory/asSingleton/asRequestScoped) keep the
   legacy path via the new Injector.hasExplicitMapping().

2. $initModelObject's cached-class read no longer takes a $simpleLock:
   application.wheels.models[name] is only written after the class is
   fully built (config() + column processing), so a present entry is
   always complete and concurrent first loads are handled by the slow
   path.

Measured on the #3213 rig (Lucee 7, H2, warmed): 3,000 x model().new()
went from ~745 ms (#3462) to ~508 ms; the full chain 4.0.3 -> now is
~1,290 ms -> ~508 ms. RocketUnit suite ~180 ms.

InjectorInterface declares hasExplicitMapping(); InjectorSpec pins its
contract (false for unmapped names, true after map/to/toFactory/
asSingleton/asRequestScoped).

Verification: local Lucee full suite 5554 pass/0 fail; RustCFML at
baseline; boxlang matrix PASS; adobe2023 matrix shows only the known
pre-existing failures (bcrypt #3463 + package-hardener symlink flake).

Signed-off-by: Peter Amiri <peter@alurium.com>
@bpamiri
bpamiri merged commit 7e7b51a into develop Aug 31, 2026
12 checks passed
@bpamiri
bpamiri deleted the perf/model-create-fast-path-3213 branch August 31, 2026 16:52
bpamiri added a commit that referenced this pull request Oct 1, 2026
…grades and install (#3932)

* docs(guides): correct stale 4.1 statements on error email, reload, upgrades and install

- production-config: errorEmailAddress defaults to "" since 4.1.2 (GHSA-8gcv-3v9h-7gj2);
  with no recipient no error email is sent and a one-time warning goes to wheels.log
- environments-and-configuration: an empty reloadPassword fails closed since 4.0.4
  (#3062); #3059 is fixed, not open
- performance-notes: describe the released fixes (4.0.6 #3236, 4.1.0 #3461/#3462/#3464,
  4.1.1 #3656) instead of pointing at bleeding-edge
- manual-installation: use the 4.1.2 release asset names and tag
- upgrade: document the 4.1.0 app template drift advisory (#3379)
- 3x-to-4x: the wheels.Testbox upgrade-check rule shipped in 4.0.4
- manual-upgrades: caution that the 4.1.1 .env boolean fix (#3641) must be applied by
  hand to the app-owned public/Application.cfc

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>

* docs(guides): give the full error-email sender fallback order

errorEmailFromAddress, then errorEmailAddress, then the recipient (EventMethods.cfc). Review nit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>

---------

Signed-off-by: Peter Amiri <peter@alurium.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant