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

Use shared `DomElementSchemaRegistry` instance for `ServerRendererFactory2` #28150

Closed
bmeurer opened this Issue Jan 15, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@bmeurer
Copy link
Contributor

bmeurer commented Jan 15, 2019

Relevant Package

This performance improvement is for @angular/platform-server.

Problem

Right now the ServerRendererFactory2 creates a new instance of the DomElementSchemaRegistry for each and every request, which is quite costly (for the Tour of Heroes SSR example this takes around 15% of the overall execution time).

A 0x flamegraph illustrates the problem:

image

Solution

Since the schema is never modified, but only used in a read-only fashion, it should be possible to re-use a single instance instead, which avoids quite a bit of overhead per request.

We can verify the improvement using another 0x flamegraph:

image

bmeurer added a commit to bmeurer/angular that referenced this issue Jan 15, 2019

perf(platform-server): use shared `DomElementSchemaRegistry` instance (
…angular#28150)

Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **15%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **17%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close angular#28150
@MarkPieszak

This comment has been minimized.

Copy link
Member

MarkPieszak commented Jan 15, 2019

This is excellent @bmeurer, really great catch here!

@ngbot ngbot bot added this to the needsTriage milestone Jan 15, 2019

bmeurer added a commit to bmeurer/angular that referenced this issue Jan 15, 2019

perf(platform-server): use shared `DomElementSchemaRegistry` instance (
…angular#28150)

Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **30%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **33%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close angular#28150

AndrewKushnir added a commit that referenced this issue Jan 15, 2019

perf(platform-server): use shared `DomElementSchemaRegistry` instance (
…#28150) (#28151)

Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **30%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **33%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close #28150

PR Close #28151

AndrewKushnir added a commit that referenced this issue Jan 16, 2019

perf(platform-server): use shared `DomElementSchemaRegistry` instance (
…#28150) (#28151)

Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **30%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **33%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close #28150

PR Close #28151

wKoza added a commit to wKoza/angular that referenced this issue Jan 18, 2019

perf(platform-server): use shared `DomElementSchemaRegistry` instance (
…angular#28150) (angular#28151)

Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **30%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **33%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close angular#28150

PR Close angular#28151

wKoza added a commit to wKoza/angular that referenced this issue Jan 18, 2019

perf(platform-server): use shared `DomElementSchemaRegistry` instance (
…angular#28150) (angular#28151)

Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **30%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **33%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close angular#28150

PR Close angular#28151

ngfelixl added a commit to ngfelixl/angular that referenced this issue Jan 28, 2019

perf(platform-server): use shared `DomElementSchemaRegistry` instance (
…angular#28150) (angular#28151)

Right now the `ServerRendererFactory2` creates a new instance of the
`DomElementSchemaRegistry` for each and every request, which is quite
costly (for the Tour of Heroes SSR this takes around **30%** of the
overall execution time). Since the schema is never modified, but only
used in a read-only fashion, it should be possible to re-use a single
instance instead.

Naive performance testing with 100 concurrent connections and 1000
requests in total shows an approximate **33%** improvement in Req/Sec
on the Tour of Heroes SSR example.

PR Close angular#28150

PR Close angular#28151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.