返回提示词目录第 1377 页

网站全链路性能瓶颈审计

追踪前后端关键耗时链路,区分实测问题与代码风险,输出瓶颈报告及优化验证计划。

完整提示词

I want you to perform a maximally deep, systematic, and evidence-first analysis of web performance across the entire project.

Main objective:

> Identify concrete bottlenecks that measurably degrade loading, rendering, interaction, network latency, or backend response times, and explain their real-world impact without resorting to generic checklists.

This is not:

- a generic Lighthouse checklist
- a list of "optimize your bundle" tips
- an automated refactor
- guesswork about how many concurrent users the system can handle
- a blanket recommendation to memoize everything
- a hunt for micro-benchmarks

The focus is squarely on genuine bottlenecks.

Priority:

**measurable impact > reproducible bottleneck > architectural risk > micro-optimization**

In the absence of runtime telemetry, strictly separate:

**CODE-LEVEL RISK**

from:

**MEASURED PERFORMANCE PROBLEM**

---

# 1. ESTABLISH STACK AND RUNTIME

Before analyzing, determine:

- framework
- React/Vue/Angular/Svelte version
- SSR/CSR/SSG model
- bundler
- deployment platform
- backend architecture
- database
- CDN
- image pipeline
- font loading
- caching layers
- analytics
- third-party scripts
- monitoring / APM tooling

Review:

- `package.json`
- build configuration
- route structure
- entry points
- shared layouts
- global providers
- asset loading strategy
- API client
- database queries
- server handlers
- deployment configuration

---

# 2. CONSTRUCT PERFORMANCE MAP

For critical pages, trace the request-to-interactive timeline:

```text
DNS
↓
connection
↓
HTML / initial response
↓
critical CSS
↓
JavaScript
↓
fonts
↓
images
↓
hydration
↓
data fetching
↓
interactive UI
```

If SSR is used:

```text
request
↓
server render
↓
DB/API calls
↓
HTML/RSC
↓
browser
↓
hydration
```

If CSR is used:

```text
HTML shell
↓
JS bundle
↓
app bootstrap
↓
API calls
↓
render
```

For each critical flow, pinpoint exactly where time is lost.

---

# 3. DO NOT OPTIMIZE BLINDLY

Before filing a finding, consider:

- execution frequency
- data volume processed
- presence on the critical path
- whether it blocks user interaction
- whether it runs only once
- whether the defect is visible or merely theoretical

Do not report:

```text
O(n)
```

as an issue if `n` is realistically 10.

---

# 4. INITIAL LOAD

Analyze what must be transferred and executed before the first meaningful paint.

Look for:

- oversized JavaScript bundles
- render-blocking CSS
- font-display blocking
- heavy hero images
- un-deferred third-party scripts
- cascading route data dependencies
- server TTFB latency

Ask:

> What does the user truly need to see immediately?

Everything else is a candidate for deferral, provided UX is not impaired.

---

# 5. JAVASCRIPT BUNDLE

If tooling allows, inspect bundle composition.

Look for:

- bloated dependencies
- duplicate packages across versions
- full-library imports
- bundled locale files
- un-optimized icon packs
- heavy editors
- charting libraries
- map engines
- PDF generators
- analytics SDKs
- admin-only logic leaked into public bundles

Do not recommend package replacements solely based on raw byte size.

Provide concrete trade-offs and alternatives.

---

# 6. TREE SHAKING

Inspect import patterns.

Example:

```ts
import _ from "lodash"
```

versus targeted imports.

Verify actual bundler behavior before declaring an issue.

Do not assume an entire package is bundled without checking emitted artifacts or bundler configs.

---

# 7. CODE SPLITTING

Evaluate bundle boundaries.

Look for:

- features used on a single sub-route bundled into the global entry
- admin workflows shipped to public visitors
- rich text, charting, or video libraries loaded on initial landing
- modal features that are rarely opened

Do not lazy-load tiny, critical components purely for the sake of splitting.

---

# 8. DYNAMIC IMPORTS

Review existing dynamic imports.

Look for:

- loading too late in the user flow
- layout flashes on dynamic chunk arrival
- downstream waterfalls
- chunks needed almost immediately upon landing

Lazy loading can degrade performance if it inserts an unnecessary network round trip on the critical path.

---

# 9. HYDRATION COST

If using SSR, evaluate how much DOM must be hydrated with client JavaScript.

Look for:

- massive Client Component subtrees
- heavy global context providers
- interactivity boundaries placed too high in the tree
- static markup unnecessarily converted into client-hydrated code

Only report where a cleaner boundary provides measurable savings.

---

# 10. CLIENT COMPONENT OVERUSE

If the framework supports React Server Components, verify whether too much code is bundled for the browser.

Search for:

```text
"use client"
```

at elevated levels of the tree.

Assess:

- bundle size impact
- hydration CPU overhead
- serialization penalties
- duplicated server/client fetching

---

# 11. RENDER PERFORMANCE

Identify components that render frequently and execute significant computation.

Look for:

- large array `.map` operations
- nested iteration
- in-render sorting
- filtering
- parsing
- formatting
- heavy calculations

Do not flag every re-render.

A finding requires:

- an expensive component
- high element count
- high render frequency
- perceptible UI stutter / jank
- or other demonstrable impact

---

# 12. UNNECESSARY RE-RENDERS

Determine root causes:

- Context value reference changes
- parent re-rendering
- unstable inline object creation
- unstable callback definitions
- un-memoized store selectors
- prop referential instability

Do not default to wrapping everything in `React.memo`.

Verify whether memoization genuinely prevents expensive work.

---

# 13. CONTEXT PERFORMANCE

When substantial parts of the app depend on a single Context, verify:

```text
context value changes
↓
large subtree rerenders
```

Specifically when Context bundles disparate, frequently changing values together.

---

# 14. GLOBAL STORE SELECTORS

If using Zustand, Redux, or similar stores:

- inspect selector granularities
- check for selectors returning new object references
- verify custom equality functions
- check for overly broad subscriptions

Look for components subscribing to the entire store when consuming only a single property.

---

# 15. LIST PERFORMANCE

For large lists check:

- render count
- stable keys
- pagination
- virtualization
- total DOM node count

Do not recommend virtualization for a list of 20 items.

---

# 16. VIRTUALIZATION

If virtualization is utilized, check:

- item height calculation
- measurement overhead
- overscan sizing
- scrolling performance
- dynamic heights
- accessibility implications

Virtualization carries its own complexity and CPU overhead.

---

# 17. SORTING AND FILTERING

Identify client-side sorting and filtering performed over large datasets.

Ask:

- what is the realistic record count
- how often does the computation execute
- can the database or API handle this more efficiently
- is the exact same operation repeated on every render

---

# 18. SEARCH PERFORMANCE

For search inputs check:

- debouncing
- keystroke request frequency
- aborting stale requests
- backend indexing
- response payload sizing
- local search filtering

Flag requests dispatched on every keystroke if they produce tangible server or UI strain.

---

# 19. EVENT HANDLERS

Review high-frequency event listeners:

- scroll
- resize
- mousemove
- pointermove
- input
- drag

Look for heavy synchronous computation lacking:

- throttling
- debouncing
- `requestAnimationFrame`

only where the work is genuinely expensive.

---

# 20. MAIN THREAD BLOCKING

Identify synchronous operations that can freeze the main thread:

- JSON parsing of massive payloads
- client-side PDF generation
- image manipulations
- encryption / hashing
- compression
- large iteration loops
- data shape transformations

Assess whether work should be offloaded to:

- backend
- Web Worker
- chunked microtasks
- asynchronous streams

---

# 21. WEB WORKERS

If CPU-intensive client processing is identified, assess whether a Web Worker is justified.

Do not introduce workers for lightweight operations.

---

# 22. NETWORK WATERFALLS

Map:

```text
request A
↓
A response
↓
request B
↓
B response
↓
request C
```

Ask:

> Does B genuinely depend on the data returned by A?

If not, parallelization is indicated.

---

# 23. SERVER WATERFALLS

Trace dependencies on the server side:

```ts
const a = await getA()
const b = await getB()
const c = await getC()
```

where operations are mutually independent.

Do not force `Promise.all` where genuine data dependencies exist.

---

# 24. DUPLICATE FETCHING

Look for the exact same resource fetched repeatedly:

- in a layout
- in a page
- in a child component
- re-fetched client-side on hydration

Verify framework request deduplication (e.g. `fetch` memoization) before reporting.

---

# 25. API RESPONSE SIZE

For critical endpoints review:

- total field count
- deep nested objects
- unbounded arrays
- redundant metadata

Ask:

> How much of this response does the UI actually consume?

---

# 26. OVERFETCHING

Look for:

```text
SELECT *
```

or APIs returning an entire database record when the UI displays only 3 fields.

Assess:

- network bandwidth
- JSON serialization cost
- database query overhead
- privacy/security exposure

---

# 27. UNDERFETCHING

The inverse problem:

```text
list
↓
N individual detail requests
```

Identify instances where granular endpoints trigger N+1 round trips over the network.

---

# 28. API CHATTER

Count requests executed to render a single screen.

If loading a dashboard requires dozens of micro-requests, evaluate:

- request batching
- endpoint aggregation
- backend-for-frontend (BFF) composition
- edge caching

Do not create unwieldy mega-endpoints without clear architectural justification.

---

# 29. N+1 DATABASE QUERIES

For an array of N entities, check if code executes:

```text
1 query for list
+
N queries for details
```

Particularly across:

- relational joins
- aggregation counts
- authorization checks
- metadata lookups

---

# 30. DATABASE INDEXES

For performance-critical queries, inspect:

- WHERE clauses
- JOIN predicates
- ORDER BY columns
- GROUP BY columns

Do not guess missing indexes without reviewing schemas and query execution plans.

---

# 31. UNBOUNDED QUERIES

Look for:

- `findMany()` without limits
- dumping entire database collections
- full-table CSV exports on the main thread
- unbounded admin data tables

Explain the degradation curve as records grow.

---

# 32. PAGINATION

Check:

- offset pagination
- cursor-based pagination
- page size limits
- index-backed sorting

Deep offset pagination can become very slow on large tables.

Provide realistic growth contexts.

---

# 33. DATABASE CONNECTIONS

In serverless architectures, inspect:

- connection pooling
- pool exhaustion limits
- connection re-use across warm invocations
- ORM connection handling

Look for risks of exhausting database connections under load spikes.

---

# 34. EXTERNAL API LATENCY

Map third-party API dependencies on the critical rendering path.

Example:

```text
page request
↓
server
↓
external provider
↓
page cannot render until provider responds
```

Evaluate:

- caching strategies
- aggressive timeouts
- static or cached fallbacks
- asynchronous background updates

---

# 35. TIMEOUTS

Every remote network call must be examined for unbounded waiting.

Verify:

- fetch timeouts
- SDK client timeouts
- database query timeouts
- retry timeouts

---

# 36. RETRIES

Retries enhance reliability but can dramatically increase tail latency.

Look for:

```text
request
↓
timeout
↓
retry
↓
timeout
↓
retry
```

occurring on user-facing synchronous request paths.

Calculate worst-case client wait time.

---

# 37. RETRY STORMS

Under heavy load, aggressive retries can amplify outages.

Check for:

- exponential backoff
- randomized jitter
- max retry limits

Do not flag this if traffic scale does not warrant the concern.

---

# 38. CACHE STRATEGY

Map caching layers:

- browser HTTP cache
- CDN edge cache
- framework cache
- application server cache
- client query cache
- Redis / memory stores
- database query cache

For critical resources determine:

- TTL
- invalidation mechanism
- ownership

---

# 39. MISSING CACHE

Look for expensive read operations that execute repeatedly with rarely changing data:

- static app configurations
- public product catalogs
- heavy analytical aggregations

Do not cache user-private or rapidly mutating data carelessly.

---

# 40. OVER-CACHING

Excessive caching can create performance issues through:

- memory exhaustion
- invalidation stampedes
- serving stale data
- serialization and deserialization overhead

Do not assume more cache equals better performance.

---

# 41. CACHE STAMPEDE

If a frequently accessed cache key expires and concurrent requests simultaneously trigger the expensive recomputation, evaluate stampede risk.

Relevant only for sufficiently high-traffic and compute-heavy paths.

---

# 42. STATIC GENERATION

If the framework supports SSG or prerendering, verify whether public, static pages are needlessly rendering on-demand per request.

Factor in:

- personalization requirements
- freshness constraints
- deployment build times

---

# 43. DYNAMIC RENDERING

Look for accidental dynamic rendering triggered by:

- reading cookies
- reading request headers
- dynamic route functions
- missing export configurations

If a minor dependency forces an entire route to render dynamically, evaluate the impact.

---

# 44. SERVER RESPONSE TIME

Deconstruct TTFB (Time to First Byte):

```text
routing
↓
auth
↓
DB
↓
external API
↓
render
↓
serialization
```

Do not blame the framework for delays rooted in slow database queries.

---

# 45. SERIALIZATION

Large server-to-client payloads incur heavy JSON parsing and serialization costs.

Look for:

- giant JSON payloads
- duplicated relational records
- embedded base64 strings
- oversized RSC payloads

---

# 46. COMPRESSION

Verify whether the CDN or hosting platform automatically applies Gzip or Brotli compression.

Do not suggest manual compression libraries if the infrastructure layer already handles it.

---

# 47. IMAGES

For large and critical images check:

- modern format (WebP, AVIF)
- intrinsic vs display dimensions
- responsive `srcset` / `sizes`
- compression levels
- loading strategy (`priority` vs `lazy`)
- CDN optimization pipeline

---

# 48. LCP IMAGE

Identify the primary candidate for the Largest Contentful Paint (LCP) element.

If it is an image:

- is it preloaded when appropriate
- is it oversized
- is discovery delayed by CSS or JavaScript
- does it include correct `sizes` attributes

Do not claim measured LCP milliseconds without real telemetry.

---

# 49. LAZY LOADING IMAGES

Do not lazy-load above-the-fold hero images.

Conversely, do not eagerly load all off-screen images.

Audit viewport positioning.

---

# 50. IMAGE DIMENSIONS

Omission of explicit `width` and `height` attributes causes Cumulative Layout Shift (CLS).

Verify framework and styling handling.

---

# 51. FONTS

Analyze:

- font family count
- weights requested
- character subsets
- format (WOFF2)
- preload hints
- self-hosting vs third-party CDNs
- `font-display` behavior

---

# 52. FONT OVERLOAD

If an application loads:

```text
100
200
300
400
500
600
700
800
900
```

while consuming only three weights, report unnecessary bandwidth waste.

---

# 53. ICONS

Review icon strategy:

- entire icon library imported
- SVG sprite system
- inline SVGs
- icon web fonts

Do not optimize icons if the byte savings are negligible.

---

# 54. CSS

Look for:

- massive monolithic global CSS files
- duplicate style declarations
- dead/unused CSS
- runtime CSS-in-JS injection overhead
- expensive CSS selectors only if they produce measurable style recalculation delays

---

# 55. CRITICAL CSS

If the framework inlines critical CSS automatically, do not recommend complex custom tooling.

---

# 56. THIRD-PARTY SCRIPTS

Map all third-party scripts:

- size
- render-blocking impact
- main-thread execution cost
- necessity
- loading strategy (`async`, `defer`, web workers)
- failure resilience

Examples:

- analytics
- advertisements
- live chat widgets
- heatmaps and session replay
- tag managers
- social embeds

---

# 57. ANALYTICS

Ensure analytics SDK initialization does not delay Time to Interactive or critical paints.

Look for duplicate SDK initializations and duplicate event listeners.

---

# 58. ADVERTISEMENTS

When ads are present, separate:

- business requirements
- performance cost

Audit layout reservation to prevent ad-induced CLS.

---

# 59. EMBEDS

Embedded YouTube players, maps, and social widgets are notoriously heavy.

Evaluate facade patterns (e.g. lite-youtube) where appropriate.

---

# 60. CORE WEB VITALS

Audit code-level risks for:

- LCP
- CLS
- INP

Never fabricate metric numbers.

If real-user or lab measurements are absent:

```text
Status: NOT MEASURED
```

---

# 61. LCP RISKS

Identify potential causes:

- high TTFB
- render-blocking resources
- heavy hero graphics
- client-only rendering cascades
- late-arriving data dependencies
- delayed CSS delivery

---

# 62. CLS RISKS

Look for:

- images and videos without explicit aspect ratios
- ads or embeds without reserved layout containers
- dynamic content injected above existing elements
- late font swaps causing FOIT/FOUT layout shifts
- dynamic banners pushing content downwards
- hydration markup divergence causing layout repositioning

---

# 63. INP RISKS

Look for:

- heavy synchronous click/input handlers
- large, un-memoized component tree re-renders
- long synchronous calculations on the main thread
- long tasks exceeding 50ms
- massive DOM mutations triggered by user interaction

---

# 64. LONG TASKS

Without runtime profiling data, label candidates strictly as code-level risks.

Do not present them as measured long tasks.

---

# 65. DOM SIZE

An excessively large DOM tree degrades:

- style calculations
- layout reflows
- memory consumption

Scrutinize:

- large un-virtualized data tables
- deeply nested trees
- mega menus
- duplicate hidden DOM structures

---

# 66. HIDDEN UI

Look for desktop and mobile component trees both rendered in the DOM, with CSS toggling visibility (`display: none`).

This can duplicate:

- DOM nodes
- effect executions
- data fetching
- event listeners

---

# 67. MODALS AND PORTALS

Rendering heavy modal content while closed consumes unnecessary memory and CPU.

Verify library behavior before concluding.

---

# 68. ANIMATIONS

Look for animations animating:

- `top`
- `left`
- `width`
- `height`

at high frequencies where `transform` and `opacity` would utilize GPU composite layers.

Do not flag minor static CSS transitions.

---

# 69. SCROLL PERFORMANCE

Inspect:

- scroll event listeners
- parallax implementations
- sticky navigation logic
- infinite scroll triggers
- synchronous layout reads/writes

Look for forced synchronous layout only when code reveals it.

---

# 70. LAYOUT THRASHING

The pattern:

```text
read layout
write DOM
read layout
write DOM
```

inside a loop is devastating to frame rates.

Report only with concrete code evidence.

---

# 71. INFINITE SCROLL

Inspect:

- unbounded DOM growth
- pagination logic
- memory retention
- duplicate request triggering
- IntersectionObserver cleanup

---

# 72. PREFETCHING

Evaluate route and data prefetching strategies.

Too little:

- sluggish navigation delays

Too much:

- wasted user bandwidth
- server overload on hover spikes

Assess against actual user navigation paths.

---

# 73. PRELOAD HINTS

Preload hints should be reserved strictly for resources guaranteed to be needed immediately.

Overuse creates bandwidth contention on the critical path.

---

# 74. PRIORITY HINTS

If used:

- `fetchpriority="high"`
- `rel="preload"`
- priority props

ensure they are assigned only to true critical path assets.

---

# 75. SERVICE WORKERS

If a service worker exists:

- precache volume
- runtime cache strategy
- serving stale assets
- network contention
- offline fallbacks

A service worker accelerates repeat visits, but improper configuration can delay initial boots or trap users on stale assets.

---

# 76. MEMORY LEAKS

Look for browser memory leaks that degrade performance during prolonged sessions:

- leaked event listeners
- uncleared intervals and timeouts
- open WebSocket/SSE connections
- retained detached DOM references
- un-revoked object URLs
- unbounded in-memory caches

---

# 77. CLIENT CACHE SIZE

Query and store caches can grow indefinitely.

Check:

- key cardinality
- garbage collection (`gcTime`)
- cache clearing on logout/user switch
- paginated data accumulation

---

# 78. LARGE FILE PROCESSING

If the browser handles:

- CSV parsing
- PDF generation
- image resizing
- video encoding

check for memory bloat and main-thread freezing.

---

# 79. MOBILE PERFORMANCE

Factor in mobile device constraints:

- slower single-core CPU
- weaker GPU
- restricted RAM
- cellular network latency and packet loss

Desktop responsiveness does not prove mobile performance.

---

# 80. SLOW NETWORKS

Mentally simulate:

- high round-trip latency (300ms+)
- restricted bandwidth (3G/4G)
- intermittent packet loss

Determine which elements block the UI.

---

# 81. COLD STARTS

If using serverless or edge functions, inspect initialization overhead:

- ORM connections
- large SDK imports
- heavy configuration parsing

Do not claim cold start figures without runtime telemetry.

---

# 82. SERVER MEMORY

Look for:

- unbounded in-memory caches
- loading entire datasets into RAM
- oversized Node buffers
- memory leaks in long-lived server processes

---

# 83. SERVER CPU

Identify CPU-intensive operations on the request path:

- synchronous cryptographic hashing
- dynamic image manipulation
- server-side PDF generation
- compression
- heavy iterative loops

---

# 84. BACKGROUND JOBS

If a synchronous request waits for work that does not need to finish before responding to the user, evaluate background queues or async processing.

Account for serverless execution boundaries.

---

# 85. DATABASE VS APPLICATION LOGIC

Do not blindly push all logic to the database or all logic to JavaScript.

Evaluate optimal placement:

- filtering, sorting, and aggregations over large datasets belong in the DB
- complex business rules with small payloads may belong in application code

---

# 86. ALGORITHMIC COMPLEXITY

Identify obvious algorithmic hazards:

- O(n²) operations
- repeated full-array scans
- nested lookups

specifically where `n` can grow large.

---

# 87. DATA STRUCTURES

Example:

```ts
array.find(...)
```

inside an iteration loop becomes O(n²).

If datasets expand, evaluate Maps or Sets.

Do not flag this for small, bounded lists.

---

# 88. DUPLICATE COMPUTATIONS

Look for expensive calculations performed multiple times during a single request or render lifecycle.

---

# 89. FORM PERFORMANCE

For large, complex forms:

- re-rendering every field on each keystroke
- global form watch subscriptions
- running schema validation on every change
- massive schema parsing overhead

Analyze only when forms have substantial field counts.

---

# 90. TABLE PERFORMANCE

For data-dense tables verify:

- server-side pagination
- sorting and filtering delegation
- table row virtualization
- cell rendering memoization

---

# 91. DASHBOARD PERFORMANCE

Dashboards frequently mount numerous parallel widgets.

Map:

```text
widget A
widget B
widget C
widget D
```

Determine:

- what is critical
- what can stream via Suspense
- what should lazy load below the fold
- what can be cached

---

# 92. AUTHENTICATION PERFORMANCE

Verify whether every single request executes expensive auth overhead:

- redundant database lookups
- remote OAuth provider round trips
- complex permission tree traversals

Security must not be compromised for performance, but auth verification should be optimized and cached securely.

---

# 93. PERMISSION CHECK N+1

If a list displays 100 resources and each resource initiates a standalone permission check query, a severe database bottleneck is created.

---

# 94. LOGGING OVERHEAD

Look for:

- giant synchronous JSON logging
- logging inside tight loops
- serializing massive object graphs

Do not remove essential production observability without cause.

---

# 95. DEVELOPMENT VS PRODUCTION

Distinguish:

- development tooling overhead
- React Strict Mode double execution
- source map generation
- Hot Module Replacement (HMR)

from true production runtime characteristics.

---

# 96. BUILD PERFORMANCE

Decouple build-time speed from runtime performance.

If builds are slow, investigate:

- volume of static page generation
- asset optimization pipelines
- TypeScript typechecking depth
- complex dependency graphs

Do not conflate slow builds with user latency.

---

# 97. PERFORMANCE TESTS

Check for the existence of:

- Lighthouse CI
- Web Vitals monitoring
- automated load tests
- micro-benchmarks
- bundle size budgets

Do not assume tests exist if they are not configured.

---

# 98. PERFORMANCE BUDGETS

If the project lacks performance budgets, propose them only where project scope justifies it:

- route JS limits
- image size caps
- API latency thresholds
- LCP/INP targets
- bundle expansion alerts

Do not fabricate target thresholds without establishing a baseline.

---

# 99. FINDING EVIDENCE

Every serious finding must include:

```text
ID:
Severity:
Category:
Confidence:
Status:

User flow:
Location:
File:
Function/Component:

Bottleneck:

Evidence:

Execution flow:

Why it is expensive:

Frequency:

Data size / scale assumption:

User-visible impact:

Recommended remediation:

How to measure improvement:

Complexity:
XS / S / M / L / XL
```

---

# 100. SEVERITY

Use:

## P1 - HIGH

- severe degradation blocking primary user journeys
- extremely sluggish critical path
- major scalability bottleneck with active production impact

## P2 - MEDIUM

- perceptible bottleneck on an important flow
- genuine latency issue with bounded scope

## P3 - LOW

- minor inefficiency with measurable impact

## P4 - IMPROVEMENT

- optimization opportunity without current perceptible user penalty

P0 is reserved strictly for performance failures causing complete system crashes or total operational breakdown.

---

# 101. CONFIDENCE

Use:

```text
HIGH
MEDIUM
LOW
```

HIGH:

backed by runtime profiling or an indisputable, directly demonstrable bottleneck.

MEDIUM:

strong code-level evidence lacking live production metrics.

LOW:

contingent on traffic scale, dataset size, or production infrastructure variables.

---

# 102. MEASUREMENT

For each P1/P2 finding, define how to measure before and after the fix:

```text
Metric:
Current:
Target:
Measurement method:
Environment:
```

If `Current` is unknown:

```text
Current: NOT MEASURED
```

Do not invent baseline figures.

---

# 103. TOOLS

Where available, leverage:

- browser performance profiler
- React Profiler
- bundle analyzers
- Lighthouse
- Web Vitals library
- database query logs
- EXPLAIN ANALYZE
- load testing tools
- distributed tracing

If unavailable, clearly state what has not been confirmed in runtime.

---

# 104. DO NOT OPTIMIZE CODE DURING AUDIT

During this audit:

- do not modify source code
- do not change bundle configurations
- do not alter cache headers
- do not add database indexes
- do not install dependencies

Complete the audit first.

---

# 105. OUTPUT - WEB_PERFORMANCE_AUDIT.md

Structure the final report as:

## 1. Executive Summary

- architecture
- critical performance path
- primary bottlenecks identified
- measured vs inferred state

## 2. Performance Architecture

## 3. Critical Page Load Flows

## 4. Bundle Audit

## 5. Rendering Audit

## 6. Hydration Audit

## 7. Network Audit

## 8. API Audit

## 9. Database Performance Audit

## 10. Cache Audit

## 11. Image Audit

## 12. Font Audit

## 13. Third-Party Script Audit

## 14. Core Web Vitals Risk Audit

## 15. Mobile Performance

## 16. Server Performance

## 17. Serverless / Cold Start

## 18. Memory Audit

## 19. Findings Summary

| ID | Severity | Layer | Bottleneck | Evidence | Confidence |
|---|---|---|---|---|---|

## 20. Detailed Findings

## 21. Quick Wins

Only genuine low-effort / high-impact candidates.

## 22. Architectural Bottlenecks

## 23. Things Already Done Well

## 24. Unknown / Not Measured

## 25. Measurement Plan

---

# 106. BOTTLENECK CHAIN ANALYSIS

For the slowest or most critical user journey, map the chain:

```text
User request
↓
network
↓
server
↓
database
↓
external API
↓
serialization
↓
browser
↓
render
↓
interactive
```

For each link classify:

```text
MEASURED
LIKELY BOTTLENECK
LOW RISK
NOT VERIFIED
```

This prevents optimizing the wrong layer of the system.

---

# 107. 10X SCALE PASS

Mentally simulate what happens when:

- record count increases 10x
- concurrent user count increases 10x
- dashboard widget count increases 10x
- list item count increases 10x
- API call frequency increases 10x

Do not assert guaranteed crashes.

Pinpoint exactly where complexity or resource exhaustion climbs non-linearly.

---

# 108. SLOW DEVICE PASS

Assume:

- constrained mobile CPU
- slow storage
- restricted RAM

Ask:

> Which client-side operations degrade first?

---

# 109. SLOW NETWORK PASS

Assume:

- high latency (300ms+)
- limited bandwidth

Ask:

> Which network waterfalls or large assets dominate the critical path?

---

# 110. COLD CACHE PASS

Analyze a brand-new visitor with:

- empty browser cache
- empty CDN edge cache
- cold application cache
- cold query cache

What is the true first-load cost?

---

# 111. WARM CACHE PASS

Then evaluate repeat visitors.

Ask:

> What data or assets are being needlessly re-fetched or re-computed?

---

# 112. FAILURE PERFORMANCE PASS

Performance issues frequently arise when external dependencies fail.

Example:

```text
provider timeout
↓
3 sequential retries
↓
fallback
```

If the failure path takes 45 seconds to resolve, that is a severe performance issue.

---

# 113. ROI RANKING

For remediation, compile a priority matrix:

| Finding | Expected impact | Effort | Confidence | Measurement |
|---|---|---|---|---|

Do not invent arbitrary percentage gains without benchmarks.

Use relative tiers:

- HIGH
- MEDIUM
- LOW

---

# 114. FINAL SECOND PASS

Once the audit is complete, perform a second pass asking:

> What is the user waiting for that they should not have to wait for?

Re-check:

- initial load
- route transitions
- form submissions
- search queries
- dashboard mounts
- file operations
- authentication
- third-party APIs

Then ask:

> What is the browser computing that the server could handle more efficiently?

And:

> What is the server computing synchronously that does not need to block the response?

And:

> What data is transferred or computed redundantly?

---

# FINAL QUALITY GATE

Before returning your answer, verify:

- you did not report a re-render without proof that it is expensive
- you did not blindly recommend memoization
- you did not flag a large bundle without identifying the culprit packages
- you did not report an N+1 query without reconstructing the query flow
- you did not propose caching without detailing invalidation strategy
- you did not recommend lazy-loading critical above-the-fold content
- you did not confuse dev-mode overhead with production performance
- you did not fabricate Core Web Vitals numbers
- you did not invent system capacity figures
- every P1/P2 defect specifies a concrete bottleneck
- every proposed optimization includes a method of verification
- network, server, database, and browser were audited as a unified system

---

# FINAL RULE

Do not return a report like:

> Use lazy loading, memoization, caching, and optimize images.

That is not a performance audit.

Answer the fundamental question:

> Where is the user actually losing time, and why?

For every serious defect, you must document:

```text
operation
↓
expensive step
↓
why expensive
↓
how often
↓
what user waits for
↓
how to prove it
↓
how to improve it
```

Performance is an end-to-end system property.

Do not optimize a line of code until you understand the critical path.

If something has not been benchmarked:

**NOT MEASURED.**

If it represents only potential risk:

**CODE-LEVEL RISK.**

If evidence is insufficient:

**NOT VERIFIED.**

The objective is an actionable performance audit that translates directly into measurable optimizations, reproducible benchmarks, and automated regression tests.

分类与标签

编程开发、网站性能、全链路审计、性能测量、前后端优化

前往 AI 图片创作