-
Notifications
You must be signed in to change notification settings - Fork 25.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(platform-server): Add an ssr benchmark setup. #57647
base: main
Are you sure you want to change the base?
Conversation
09f7a37
to
a3d87fc
Compare
|
This PR does impact all the packages because of visibility changes, @josephperrott's approval should be enough for those. |
df3c3a3
to
3b906fc
Compare
3b906fc
to
15a1ec6
Compare
In order to investigate the performances of SSR, this commit introduces a benchmark suite which will measure several step of the rendering.
15a1ec6
to
a9c2e7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for implementing this @JeanMeche 👍 Just left a few comments.
@alan-agius4 could you please take a look at this change when you get a chance?
| @@ -20,6 +20,9 @@ import { Version } from '@angular/core'; | |||
| // @public | |||
| export const BEFORE_APP_SERIALIZED: InjectionToken<readonly (() => void | Promise<void>)[]>; | |||
|
|
|||
| // @public (undocumented) | |||
| export const ENABLE_DOMINO: InjectionToken<boolean>; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should prevent exposing those extra symbols into the public API (use the ɵ in their names).
| render, | ||
| initData, | ||
| PERFORMANCE_MARK_PREFIX, | ||
| } from '../../dist/out/darwin_arm64-fastbuild/bin/modules/ssr-benchmarks/build/server/main.server.mjs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this path would always be stable (probably not, depending on OS). Is there a different option to reference that? // cc @alan-agius4
| this.finishTask = this.pendingTasks.add(); | ||
| } | ||
|
|
||
| data$ = (this.getObservableFromTransferState() ?? from(testData())).pipe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question: why do we need to use observables here? I think it'd be great to keep this logic synchronous, so we don't measure this extra time in benchmarks.
| import {TRANSFER_STATE_SERIALIZATION_PROVIDERS} from './transfer_state'; | ||
|
|
||
| export const INTERNAL_SERVER_PLATFORM_PROVIDERS: StaticProvider[] = [ | ||
| {provide: DOCUMENT, useFactory: _document, deps: [Injector]}, | ||
| {provide: PLATFORM_ID, useValue: PLATFORM_SERVER_ID}, | ||
| {provide: PLATFORM_ID, useValue: PLATFORM_SERVER_ID}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a duplicate of a previous line.
| @@ -57,8 +63,13 @@ export const INTERNAL_SERVER_PLATFORM_PROVIDERS: StaticProvider[] = [ | |||
| ]; | |||
|
|
|||
| function initDominoAdapter() { | |||
| const enableDomino = inject(ENABLE_DOMINO, {optional: true}) ?? true; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have it in 2 places and use a default value (of true), it'd be great to extract this logic into a separate function to make sure the default value remains the same in all places.
| @@ -89,11 +100,14 @@ export class ServerModule {} | |||
|
|
|||
| function _document(injector: Injector) { | |||
| const config: PlatformConfig | null = injector.get(INITIAL_CONFIG, null); | |||
| const enableDomino = injector.get(ENABLE_DOMINO, true); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like another location for the default value, we can also replace that with a utility function (see previous comment).
In order to investigate the performances of SSR, this commit introduces a benchmark suite which will measure several step of the rendering.