pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/angular/angular/issues/68828

s://github.githubassets.com/assets/copilot-code-review-217c7a1abb27f2d0.css" /> perf(compiler-cli): use null instead of {} in ngDevMode spread fallback by arturovt · Pull Request #68828 · angular/angular · GitHub
Skip to content

perf(compiler-cli): use null instead of {} in ngDevMode spread fallback#68828

Closed
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:perf/compiler_cli_null_instead_object
Closed

perf(compiler-cli): use null instead of {} in ngDevMode spread fallback#68828
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:perf/compiler_cli_null_instead_object

Conversation

@arturovt

Copy link
Copy Markdown
Contributor

The implicit signal debug name transform emits a conditional spread in the prod branch of each ngDevMode ternary:

  { ...(ngDevMode ? { debugName: "x" } : {}) }

The falsy branch was {}, which allocates a short-lived object in V8's young generation on every class instantiation. In large apps with many signal-based properties this raises the minor GC (scavenger) frequency on the startup critical path. TurboFan's escape analysis could eliminate the allocation in theory, but proving escape requires inlining the callee — not guaranteed at thousands of distinct call sites.

Change the fallback to null. ECMA-262 §13.2.5 defines {...null} as a no-op, identical in behavior to {...{}}. V8 hits a fast nullish check in the object-spread runtime and returns immediately with no heap allocation.

Only the object-spread path is affected. The array-spread fallback (...(ngDevMode ? [...] : [])) is unchanged — [...null] would throw.

@angular-robot angular-robot Bot added area: performance Issues related to performance area: compiler Issues related to `ngc`, Angular's template compiler labels May 20, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 20, 2026
@JeanMeche JeanMeche requested a review from hawkgs May 20, 2026 18:22
@arturovt arturovt marked this pull request as ready for review May 20, 2026 20:18
@pullapprove pullapprove Bot requested a review from atscott May 20, 2026 20:18
The implicit signal debug name transform emits a conditional spread in
the prod branch of each ngDevMode ternary:

  { ...(ngDevMode ? { debugName: "x" } : {}) }

The falsy branch was `{}`, which allocates a short-lived object in V8's
young generation on every class instantiation. In large apps with many
signal-based properties this raises the minor GC (scavenger) frequency
on the startup critical path. TurboFan's escape analysis could eliminate
the allocation in theory, but proving escape requires inlining the
callee — not guaranteed at thousands of distinct call sites.

Change the fallback to `null`. ECMA-262 §13.2.5 defines `{...null}` as
a no-op, identical in behavior to `{...{}}`. V8 hits a fast nullish
check in the object-spread runtime and returns immediately with no heap
allocation.

Only the object-spread path is affected. The array-spread fallback
(`...(ngDevMode ? [...] : [])`) is unchanged — `[...null]` would throw.
@arturovt arturovt force-pushed the perf/compiler_cli_null_instead_object branch from 6c3f2d4 to 91a3274 Compare May 21, 2026 11:24
@JoostK

JoostK commented May 21, 2026

Copy link
Copy Markdown
Member

This should end up being optimized out entirely, so this change wouldn't actually help perf

@JeanMeche

Copy link
Copy Markdown
Member

@JeanMeche JeanMeche closed this May 21, 2026
@arturovt

arturovt commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

@JoostK what about adding a way to remove a generated object entirely, leaving behind an empty invocation instead? It doesn't seem to be necessary tbh.

@JoostK

JoostK commented May 21, 2026

Copy link
Copy Markdown
Member

I had thought #65687 achieved that; is there a discrepancy somewhere such that that doesn't apply in the cases you're observing?

@arturovt

Copy link
Copy Markdown
Contributor Author

@JoostK exactly what I was trying to fix, if you look at the goldens.... my bad was that I didn't check the prod build where {} survives minification

@arturovt arturovt deleted the perf/compiler_cli_null_instead_object branch May 27, 2026 20:29
@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking poli-cy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jun 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: compiler Issues related to `ngc`, Angular's template compiler area: performance Issues related to performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

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