Skip to content

Optimize agent dashboard trade grouping#4

Open
taherdhanera wants to merge 1 commit into
Dragoon4002:mainfrom
taherdhanera:taher/agent-trades-grouping-perf
Open

Optimize agent dashboard trade grouping#4
taherdhanera wants to merge 1 commit into
Dragoon4002:mainfrom
taherdhanera:taher/agent-trades-grouping-perf

Conversation

@taherdhanera

@taherdhanera taherdhanera commented Jun 28, 2026

Copy link
Copy Markdown

Summary

  • pre-group dashboard trades by agent_id once per trades update
  • pass each agent card its precomputed trade list instead of filtering the full trade array during every render
  • keep the change scoped to the agents dashboard performance path

Performance impact

Before this change, the agent grid called trades.filter((t) => t.agent_id === a.id) inside agents.map(...). That makes the render path do repeated full-array scans (agents * trades) and creates a new trade array for every card on every render, which can force each sparkline to rebuild chart data unnecessarily.

After this change, the page builds a memoized tradesByAgent map in one pass whenever trades changes. Rendering agent cards becomes a constant-time lookup per agent, reducing repeated work as the number of agents or closed trades grows.

Benchmark evidence

Synthetic dashboard-sized benchmark with checksum equality:

Dataset Old path New path Speedup
50 agents / 10,000 trades / 100 render passes 1224.226ms 66.403ms 18.44x
100 agents / 25,000 trades / 50 render passes 1702.786ms 63.644ms 26.75x
200 agents / 50,000 trades / 20 render passes 1942.593ms 55.688ms 34.88x

This targets the frontend agents dashboard render bottleneck. Other same-issue bounty PRs cover adjacent areas such as backend indicators, chart downsampling, or API/network paths; they do not replace this dashboard trade-grouping optimization.

Validation

  • git diff --check
  • Syntax-oriented TypeScript parse command was run against the changed TSX file; it reached dependency-resolution errors because the checkout has no node_modules, but did not report syntax errors in the changed block.

Refs #2

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@taherdhanera is attempting to deploy a commit to the dragoon4002's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant