Skip to content

perf: profile and optimize Browse drag-and-drop for large collections - #997

Open
devin-ai-integration[bot] wants to merge 2 commits into
devin/1785279143-stale-refreshfrom
devin/1785280588-drag-performance
Open

perf: profile and optimize Browse drag-and-drop for large collections#997
devin-ai-integration[bot] wants to merge 2 commits into
devin/1785279143-stale-refreshfrom
devin/1785280588-drag-performance

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Closes #981. Part of epic #975. Stacked on #996.

Profiled Browse tile dragging at production scale (production build + reorder fixture, real pointer drags via Playwright/CDP — harness committed as scripts/profile_reorder_drag.py, full methodology and numbers in docs/reorder-performance.md).

Diagnosis: long-task cost scaled with tile count and clustered at drag start/end — handleDragStart/handleDragEnd set activeItem (grid state), re-rendering all mounted tiles (600+ MUI cards) because tiles were re-created inline each grid render. Steady-state pointermove/collision cost was not dominant.

Fix (memoization only — zero collision/drop-zone/activation changes, docs/drag-and-drop.md contract untouched):

  • ImageTile, CategoryTileReact.memo
  • SortableTileGrid: tiles render through a memoized GridTile with stable useCallback render props, so a tile re-renders only when its own item/index/disabled change

Measured (600-image gallery scope): drag FPS 43 → 50; long tasks 2/853 ms/486 ms → 1/368 ms; slowest pointer event 184 ms → 104 ms; heap 100 → 61 MB. The single remaining long task is dnd-kit's one-time shape measurement at drag activation; steady-state dragging has no long tasks.

Compact reorder mode: not implemented — the card grid meets responsiveness criteria at 600+ items after memoization (decision recorded in docs/reorder-performance.md).

Testing

  • New frontend/tests/components/tileMemoization.test.tsx: parent re-renders with stable props do not re-execute ImageTile/CategoryTile; prop changes still re-render.
  • Full frontend suite: 89 files / 1371 passed (3 expected fail); production build clean.
  • Baseline vs post-change profiling runs documented in docs/reorder-performance.md.
  • Pre-existing lint error in src/components/CanvasOverlay.tsx (from fix: correct Fabric text box resizing #984 on main) — untouched.

Needs human verification

  • Drag feel at the 600-image scope on real hardware (scripted drags cannot prove feel — process gate in docs/drag-and-drop.md).
  • Whether the remaining ~370 ms activation stall at 600 tiles warrants follow-up (deferred/incremental shape measurement).

Link to Devin session: https://app.devin.ai/sessions/414754bd88374dc693f47100ac269e78

…ry card

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot requested a review from kphunter as a code owner July 28, 2026 23:35

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Open in Devin Review

Comment thread frontend/src/components/SortableTileGrid.tsx
Comment thread frontend/src/components/SortableTileGrid.tsx
…oization holds

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread frontend/src/components/SortableTileGrid.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants