[PR #137] [CLOSED] perf: parallelize thread data fetching to improve sidebar loading performance #441

Closed
opened 2026-02-16 07:19:38 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/open-swe/pull/137
Author: @bracesproul
Created: 6/12/2025
Status: Closed

Base: mainHead: open-swe/54d8331c-6f43-406c-b55a-c8245c269e66


📝 Commits (3)

📊 Changes

2 files changed (+64 additions, -30 deletions)

View changed files

📝 apps/web/src/lib/polling/thread-poller.ts (+19 -9)
📝 apps/web/src/providers/Thread.tsx (+45 -21)

📄 Description

Problem

The thread sidebar was experiencing slow loading times due to sequential API calls when fetching thread history and states. The bottleneck occurred in multiple functions where thread details and states were being fetched one by one in for loops, causing each thread to wait for the previous thread's API calls to complete.

Solution

Refactored thread data fetching to use parallel execution with Promise.all() across multiple functions:

Changes Made

1. refreshThreads function

  • Replaced sequential for loop with parallel Promise.all() execution
  • Created separate promise arrays for thread details and thread states
  • Maintained error handling to ensure individual thread failures don't break the entire operation

2. getThread function

  • Eliminated sequential await calls for thread details and state fetching
  • Implemented Promise.all() with individual error handling for each operation
  • Preserved existing logic where thread data is required but state data is optional

3. ThreadPoller.pollThreads method

  • Updated polling mechanism to fetch thread updates in parallel instead of sequentially

Performance Impact

These changes eliminate the sequential bottleneck by fetching all thread data concurrently, which should significantly improve sidebar loading performance, especially when multiple threads need to be loaded simultaneously.

Testing

  • Existing error handling patterns are preserved
  • Individual thread failures won't affect other threads
  • All original functionality remains intact

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/open-swe/pull/137 **Author:** [@bracesproul](https://github.com/bracesproul) **Created:** 6/12/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `open-swe/54d8331c-6f43-406c-b55a-c8245c269e66` --- ### 📝 Commits (3) - [`20a20f2`](https://github.com/langchain-ai/open-swe/commit/20a20f206d8c5e584ab5fade5b1e0806cf0274d0) Apply patch - [`9198608`](https://github.com/langchain-ai/open-swe/commit/9198608a646037aece6bc2244c55d815ce79c079) Apply patch - [`27b2802`](https://github.com/langchain-ai/open-swe/commit/27b280242f0cf7e17866493e22e789ec5b18d955) Apply patch ### 📊 Changes **2 files changed** (+64 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `apps/web/src/lib/polling/thread-poller.ts` (+19 -9) 📝 `apps/web/src/providers/Thread.tsx` (+45 -21) </details> ### 📄 Description ## Problem The thread sidebar was experiencing slow loading times due to sequential API calls when fetching thread history and states. The bottleneck occurred in multiple functions where thread details and states were being fetched one by one in for loops, causing each thread to wait for the previous thread's API calls to complete. ## Solution Refactored thread data fetching to use parallel execution with `Promise.all()` across multiple functions: ### Changes Made **1. `refreshThreads` function** - Replaced sequential for loop with parallel `Promise.all()` execution - Created separate promise arrays for thread details and thread states - Maintained error handling to ensure individual thread failures don't break the entire operation **2. `getThread` function** - Eliminated sequential `await` calls for thread details and state fetching - Implemented `Promise.all()` with individual error handling for each operation - Preserved existing logic where thread data is required but state data is optional **3. `ThreadPoller.pollThreads` method** - Updated polling mechanism to fetch thread updates in parallel instead of sequentially ## Performance Impact These changes eliminate the sequential bottleneck by fetching all thread data concurrently, which should significantly improve sidebar loading performance, especially when multiple threads need to be loaded simultaneously. ## Testing - Existing error handling patterns are preserved - Individual thread failures won't affect other threads - All original functionality remains intact --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 07:19:38 -05:00
yindo closed this issue 2026-02-16 07:19:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/open-swe#441