mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
perf: reduce browsing rerenders and startup cost (#1189)
* chore(profiling): collect serializable react-scan reports * perf(routing): rerender only when directory winner changes * perf(zustand): remove shallow warning hot path * perf(state): narrow directory lifecycle updates * perf(home): avoid redundant stats render work * perf(posts): isolate live loading subscriptions * perf(chrome): skip unchanged shell rerenders * fix(profiling): drop unsupported render metric * perf(feeds): skip unchanged loading state renders * perf(home): stop resolved stats collector renders * chore(agent run): record rerender verification * perf(home): defer stats requests until metadata resolves * perf(startup): load protocol modules on demand * chore(agent run): record acquisition and startup profiles
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
{
|
||||
"task": "excessive-rerenders",
|
||||
"last_updated": "2026-07-30",
|
||||
"items": [
|
||||
{
|
||||
"id": "F001",
|
||||
"priority": 1,
|
||||
"status": "verified",
|
||||
"description": "Add serializable React profiling and establish route baselines for /biz, /all, /all/catalog, and the homepage.",
|
||||
"verification": [
|
||||
"Profile fresh isolated Chromium sessions with window.__getReactScanReport().",
|
||||
"Confirm the branch-scoped Portless URL is served by exactly one dev server."
|
||||
],
|
||||
"files": [
|
||||
"src/lib/react-scan.ts"
|
||||
],
|
||||
"notes": "Committed as 0f0b6118c. Baselines captured before optimization."
|
||||
},
|
||||
{
|
||||
"id": "F002",
|
||||
"priority": 2,
|
||||
"status": "verified",
|
||||
"description": "Narrow routing, directory, feed, post, shell, and homepage state subscriptions so unchanged lifecycle ticks do not rerender unrelated UI.",
|
||||
"verification": [
|
||||
"yarn test",
|
||||
"yarn lint",
|
||||
"yarn type-check",
|
||||
"yarn build",
|
||||
"yarn doctor --scope changed --base master"
|
||||
],
|
||||
"files": [],
|
||||
"notes": "Implemented incrementally in commits 912e1bf00 through 066e64a7d."
|
||||
},
|
||||
{
|
||||
"id": "F003",
|
||||
"priority": 3,
|
||||
"status": "verified",
|
||||
"description": "Derive multi-community loading text from primitive store selectors so hidden and visible feed footers stop rerendering on unchanged state.",
|
||||
"verification": [
|
||||
"yarn test",
|
||||
"yarn lint",
|
||||
"yarn type-check",
|
||||
"yarn build",
|
||||
"Fresh /all profile reaches the first post and records an untouched idle sample.",
|
||||
"Fresh /all/catalog plus back/forward checks preserve ordering, anchoring, scroll restoration, and mobile width."
|
||||
],
|
||||
"files": [
|
||||
"src/hooks/use-state-string.ts",
|
||||
"src/hooks/__tests__/use-state-string.test.tsx",
|
||||
"src/lib/bitsocial-internals/utils.ts"
|
||||
],
|
||||
"notes": "Committed as a72054e5d. /all first post improved from 42.21s to 3.88s; cached /all idle improved from 260 commits/5.03s to zero."
|
||||
},
|
||||
{
|
||||
"id": "F004",
|
||||
"priority": 4,
|
||||
"status": "verified",
|
||||
"description": "Stop resolved homepage community-stat collectors from subscribing to full community lifecycle objects while preserving stat refresh when statsCid changes.",
|
||||
"verification": [
|
||||
"Add focused collector lifecycle regression tests.",
|
||||
"Profile the homepage until community stats have loaded, then collect an untouched idle sample.",
|
||||
"Run yarn test, yarn lint, yarn type-check, yarn build, and scoped React Doctor."
|
||||
],
|
||||
"files": [
|
||||
"src/hooks/use-communities-stats.ts",
|
||||
"src/hooks/__tests__/use-communities-stats.test.ts"
|
||||
],
|
||||
"notes": "Committed as d6f2fa8b6. With 64 boards displayed, the loaded homepage improved from 235-260 commits per two seconds to zero commits across five seconds."
|
||||
},
|
||||
{
|
||||
"id": "F005",
|
||||
"priority": 5,
|
||||
"status": "verified",
|
||||
"description": "Run final advisory reviews, low-spec Chromium verification, cross-browser UI checks, and summarize remaining non-regression performance opportunities.",
|
||||
"verification": [
|
||||
"Run both React best-practice reviews and the effect review for new hook usage.",
|
||||
"Run the code-quality-review skill.",
|
||||
"Run a throttled Chromium pass plus desktop and mobile Firefox/WebKit verification.",
|
||||
"Confirm a clean worktree and incremental local commits."
|
||||
],
|
||||
"files": [],
|
||||
"notes": "React and effect reviews found no new issue. Code-quality review found no high-confidence advisory finding. Mid-tier throttled Chromium plus current Firefox/WebKit desktop and mobile checks passed without an app exception or horizontal overflow."
|
||||
},
|
||||
{
|
||||
"id": "F006",
|
||||
"priority": 6,
|
||||
"status": "verified",
|
||||
"description": "Reduce homepage acquisition-phase React commits while decentralized community stats resolve, without changing the displayed results.",
|
||||
"verification": [
|
||||
"Capture a fresh homepage acquisition baseline with component and commit timings.",
|
||||
"Add focused regression tests for any subscription or batching change.",
|
||||
"Reprofile through the loaded-board condition, compare the first twenty seconds, and record an untouched idle sample."
|
||||
],
|
||||
"files": [
|
||||
"src/hooks/use-communities-stats.ts",
|
||||
"src/hooks/__tests__/use-communities-stats.test.ts",
|
||||
"src/views/home/home.tsx",
|
||||
"src/views/home/__tests__/home.test.tsx"
|
||||
],
|
||||
"notes": "Committed as 28fda1ce3. First-twenty-second commits improved from 1,211 to 862 (-29%), and CommunityStatsRequest renders from 1,569 to 491 (-69%). All 64 boards resolved at 21.06s, about one second after the baseline run, then the next five seconds recorded zero commits."
|
||||
},
|
||||
{
|
||||
"id": "F007",
|
||||
"priority": 7,
|
||||
"status": "verified",
|
||||
"description": "Measure representative production cold startup under constrained CPU and network, then reduce only verified application-owned bottlenecks.",
|
||||
"verification": [
|
||||
"Separate Vite development-module overhead from a production build served locally.",
|
||||
"Record production navigation, LCP, long-task, transfer, and bundle evidence under the mid-tier throttle.",
|
||||
"Rebuild and remeasure after any retained optimization."
|
||||
],
|
||||
"files": [
|
||||
"vite.config.js"
|
||||
],
|
||||
"notes": "Committed as 0de61ac56. In a Brotli production build with the service worker blocked for a controlled A/B, first content improved from 8.31s to 4.66s, LCP from 8.37s to 4.72s, DOMContentLoaded from 4.97s to 1.07s, and long-task time from 1.85s to 1.51s. The PWA precache fell from 4.06 MiB to 439.45 KiB. Production Chrome, Firefox, and WebKit retained the full board list, active stats resolution, mobile width, and no app error boundary."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
# Progress Log
|
||||
|
||||
## 2026-07-30 00:04 HKT
|
||||
|
||||
- Item: F003
|
||||
- Summary: Resumed after the permission interruption and completed controlled post-fix `/all` and `/all/catalog` profiling. The selector-scoped loading text fix removes the hidden and visible footer loops while preserving feed ordering, scroll anchoring, exact back/forward restoration, mobile width, and search interaction.
|
||||
- Files: `src/hooks/use-state-string.ts`, `src/hooks/__tests__/use-state-string.test.tsx`, `src/lib/bitsocial-internals/utils.ts`
|
||||
- Verification: `./scripts/agent-init.sh --smoke`; fresh Chromium `/all` load and five-second idle profile; `/all` ordering and 15-second anchor check; fresh `/all/catalog` idle and cached back/forward profile; desktop and mobile Firefox/WebKit smoke checks
|
||||
- Blockers: none
|
||||
- Next: Complete F004 by making homepage community-stat collectors dormant after resolving the current `statsCid`, then reprofile the loaded homepage.
|
||||
|
||||
## 2026-07-30 00:17 HKT
|
||||
|
||||
- Item: F004, F005
|
||||
- Summary: Split homepage stat collection into a CID-selecting wrapper and a request component that unmounts after the current stats CID resolves. A changed CID remounts the request and ignores the previous CID's cached result until the data hook publishes a fresh object. The 64-board homepage is now fully idle instead of continuously committing collector updates.
|
||||
- Files: `src/hooks/use-communities-stats.ts`, `src/hooks/__tests__/use-communities-stats.test.ts`
|
||||
- Verification: `corepack yarn test --configLoader runner`; `corepack yarn lint`; `corepack yarn type-check`; `corepack yarn build`; `corepack yarn doctor --scope changed --base master`; React best-practice and effect reviews; code-quality review; fresh Chromium homepage profiling; mid-tier throttled Chromium homepage and `/all`; desktop and 390px mobile Firefox/WebKit homepage smoke checks
|
||||
- Blockers: none
|
||||
- Next: Keep acquisition-phase decentralized provider work and cold bundle loading as separate follow-up opportunities; this task's excessive steady-state rerender loops are resolved.
|
||||
|
||||
## 2026-07-30 01:06 HKT
|
||||
|
||||
- Item: F006
|
||||
- Summary: Added one shared homepage metadata loader and held each stats request until its stable stats CID exists. This removes the pre-CID request lifecycles and key-driven restarts while preserving refreshes when a CID changes.
|
||||
- Files: `src/hooks/use-communities-stats.ts`, `src/hooks/__tests__/use-communities-stats.test.ts`, `src/views/home/home.tsx`, `src/views/home/__tests__/home.test.tsx`
|
||||
- Verification: focused tests; full 1,374-test suite; lint; type-check; build; scoped React Doctor; React best-practice, effect, and code-quality reviews; fresh acquisition profiles; desktop and mobile Chrome, Firefox, and WebKit homepage checks
|
||||
- Result: First-twenty-second commits improved from 1,211 to 862 (-29%), CommunityStatsRequest renders improved from 1,569 to 491 (-69%), all 64 boards resolved at 21.06s, and the following five seconds were commit-free.
|
||||
- Blockers: none
|
||||
- Next: Establish a production-build cold-start baseline before changing startup code.
|
||||
|
||||
## 2026-07-30 01:06 HKT
|
||||
|
||||
- Item: F007
|
||||
- Summary: Removed the forced whole-package protocol chunk so the browser can render the homepage from the smaller hook/core graph and load deeper decentralized protocol modules on demand.
|
||||
- Files: `vite.config.js`
|
||||
- Verification: controlled Brotli production-build A/B with service workers blocked and identical 4x CPU plus mid-tier network throttling; final production build; lint; type-check; production desktop and mobile checks in Chrome, Firefox, and WebKit
|
||||
- Result: First content improved from 8.31s to 4.66s, LCP from 8.37s to 4.72s, DOMContentLoaded from 4.97s to 1.07s, load from 5.63s to 1.83s, long-task time from 1.85s to 1.51s, and PWA precache from 4.06 MiB to 439.45 KiB. The full board list remains present while decentralized stats continue resolving.
|
||||
- Blockers: none
|
||||
- Next: None; F001-F007 are verified.
|
||||
Reference in New Issue
Block a user