Repository navigation
perf: start the landing feed request from index.html (4G first feed render 1299 → 997 ms) - #951
Open
matthewguerra-cog wants to merge 1 commit into
Open
matthewguerra-cog wants to merge 1 commit into
matthewguerra-cog wants to merge 1 commit into
Conversation
…trap Co-Authored-By: Matthew Guerra <matthew.guerra@cognition.ai>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
There was a problem hiding this comment.
🔍 Missing required contributor credit
The PR omits the contributor-list update required by the contribution checklist. Neither credited author appears in the contributors list.
Was this helpful? React with 👍 or 👎 to provide feedback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First feed render on a cold load waited on a waterfall: HTML →
main(79 kB gzip) → bootstrap → router →FeedComponent→ feed request. An inline script insrc/index.htmlnow starts the landing feed request as soon as the HTML is parsed, andHackerNewsAPIService.fetchFeedtakes that response over (once, matched by URL) instead of fetching again.Behaviour is unchanged: same endpoint and URL, still one feed request per load, and the item/user routes and later navigations go through
lazyFetchas before. Angular is still 9.0.1 and there are no new dependencies.Promise.resolve(prefetch.data)brings the native promise into the Angular zone, so change detection runs.Before / after
Production build (
ng build --prod, Node 12), served with gzip and the SPA fallback likefirebase.json. Each run used a fresh browser context with a cold cache. Numbers are the median of 5 runs under Lighthouse mobile 4G (150 ms RTT, 1.6 Mbps down / 750 kbps up), and first feed render is the moment the firstli.post a.titleappears.main)main-es2015raw / gzipRender is now limited by
maindownload and bootstrap (mainfinishes at about 930 ms), not by the API.Baseline bundles, raw / gzip in kB: main-es2015 278.2 / 79.4, main-es5 330.7 / 85.5, polyfills-es2015 36.6 / 12.3, polyfills-es5 129.7 / 44.0, runtime 2.4 / 1.2, styles 10.7 / 1.3, item-details (lazy) 10.8 / 3.2, user (lazy) 3.9 / 1.6.
Looked at, not changed
maincontents (source-map-explorer): @angular/core 112 kB, router 69 kB, common 13 kB, platform-browser 12 kB, service-worker 5 kB. App code and RxJS are small.rxjs-compatadds 0 bytes tomain, because the deep imports resolve to the same RxJS 6 modules, so Drop rxjs-compat by importing from rxjs directly #946 is cleanup only and not a size win. Nothing unused in main is large enough to matter without changing behaviour.analytics.jsalready loads async, and dropping it would change behaviour./*.jsprefetch group (which includes the es5 bundles) does not compete with first load. SW-allowed numbers are in the table.Overlap
hackernews-api.service.tsimports. This PR leaves those lines alone and importsSubscriptionfromrxjs, so the two should merge cleanly in either order.How to reproduce
nvm use 12 && npx ng build --prod. Servedist/angular-hnpwawith gzip and the SPA fallback, then run a Playwright script that opens/in a fresh context with 4G throttling and records the time the firstli.post a.titleappears. The bench scripts are in the Latency Optimizer's memory underfiles/angular2-hn-latency/.Devin-Org: engineering
Implemented in session Speed up angular2-hn first load
Review with Devin · Open in Devin Desktop