[RUM] The Logs page is 2% of views but 31% of >500ms main-thread frames — a non-virtualized, index-keyed table re-renders every row per live flush

Đang mở
#2,083 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript
Lĩnh vực
frontend, performance

Hướng nghiên cứu

Start with src/features/instance/log/LogsDataTable.tsx, then read src/features/instance/log/hooks/mergeReadLogs.ts and src/features/instance/log/hooks/useInstanceLogs.ts to trace row identity and update frequency. Check the table's row keys and rendering behavior with live log updates, then investigate TanStack virtualization. Done means the table keeps updates responsive at the stated log limits and production RUM blocking time improves after release.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

rum

Summary

The instance Logs page (/<org>/<cluster>/logs and …/instance/<id>/logs) is Studio's worst main-thread hotspot in production RUM. It is about 2% of production views but produces 31% of all long-animation frames with more than 500ms of blocking time. Single frames reach 10–20s of blocking, so the tab freezes.

Datadog RUM findings (production fabric.harper.fast, last 15 days)

Long-task data only goes back ~15 days, so there is no older baseline. This is a measured hotspot, not a proven regression.

Logs views Every other view
Views 140 7,120
Frames with >500ms blocking (@long_task.blocking_duration) 122 272
Sessions with such a frame 17 of 80 Logs sessions (21%) —
  • Logs-view p95 blocking_duration: 808ms over 2026-10-26 → 11-09. 3,026ms in the 24h ending 2026-11-10, but that window had only 2 sessions.
  • Daily heavy-frame counts on Logs are bursty: 2 / 5 / 3 / 0 / 0 / 0 / 0 / 42 / 0 / 33 / 3 / 0 / 0 / 34 (10-26 → 11-10). Each burst comes from a long-open Logs tab.
  • Attribution of frames where scripts[] names exactly one host, as in #1684:
    • Studio's own bundle: 35 frames, 14 sessions, 78.8s total blocking. Mostly vendor-tanstack-*.js (@tanstack/query-core notifyManager in the dev file names) and vendor-react-*.js. On every other view, Studio's own bundle never produces more than 3 such frames per view.
    • www.redditstatic.com/ads/pixel.js (loaded by GTM): 52 frames, 4 sessions, 60.5s. In 15 days, every heavy Reddit-pixel frame landed on the Logs view and none on any other view. The pixel is not slow in general. Something about this page makes it slow.
    • Multi-host frames of 10–20s that mix fbevents.js, gtm.js, vendor-datadog, vendor-react and vendor-tanstack.

Likely cause (hypothesis, not yet verified in a browser)

LogsDataTable renders every entry (default limit 1,000, live retention up to max(2000, limit) in useInstanceLogs) into a table that is not virtualized. useTable gets no getRowId, so row ids, and therefore React keys, are array indexes.

mergeReadLogs returns the list newest-first. Each new line is prepended, which shifts every index. React then rewrites the text of every cell in every row, not just the new one. The SSE tail does this up to every 250ms (FLUSH_INTERVAL_MS), and the polling fallback every 5s.

That explains both signals:

  • Studio's own cost: reconciling and committing about 1–2k rows × N cells per flush.
  • The third-party cost: whole-table DOM churn feeds every MutationObserver/DOM-scanning tag that GTM injects (Reddit pixel, Facebook). That would explain why the Reddit pixel only blocks here.

Suggested fix

  1. Pass getRowId to useTable, built from the identity mergeReadLogs already computes (logKey). A prepend then mounts only the new rows and leaves existing DOM nodes untouched.
  2. Virtualize the table body, e.g. @tanstack/react-virtual, which fits the TanStack Table that is already in use. This bounds DOM size whatever the limit.
  3. Re-measure Logs-view blocking_duration p95 and heavy-frame share after the fix ships. The Reddit-pixel frames should disappear as well if the hypothesis holds.

Related: #1684 (marketing tags on /sign-in), #1762 (Reo double-load).

Reproduce the numbers
pup rum aggregate --query "@application.id:<studio> @type:long_task @view.url_host:fabric.harper.fast @view.url_hash:*logs @long_task.blocking_duration:>500000000" --compute count --from 15d --to now
pup rum events   --query "… same, without the view filter" --from 30d --to now --limit 5000   # then group by single-host scripts[].source_url

🤖 Generated by Claude Code (Claude Opus 5.5); posted via @dawsontoth.

Ngôn ngữ chính
TypeScript
Star
5
Fork
4
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
60

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của HarperFast/studio

Tất cả issue của HarperFast/studio

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.