Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JeanMeche
Copy link
Member

In order to investigate the performances of SSR, this commit introduces a benchmark suite which will measure several step of the rendering.

@JeanMeche JeanMeche force-pushed the ssr-benchmark branch 4 times, most recently from 09f7a37 to a3d87fc Compare September 10, 2024 22:43
@JeanMeche JeanMeche marked this pull request as ready for review September 10, 2024 22:43
@JeanMeche
Copy link
Member Author

This PR does impact all the packages because of visibility changes, @josephperrott's approval should be enough for those.

In order to investigate the performances of SSR, this commit introduces a benchmark suite which will measure several step of the rendering.
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a 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>;
Copy link
Contributor

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';
Copy link
Contributor

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(
Copy link
Contributor

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},
Copy link
Contributor

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;
Copy link
Contributor

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);
Copy link
Contributor

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).

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.

2 participants