Skip to content

Extension crashes and performance issues due to excessive globalState usage for task history #3784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KJ7LNW opened this issue May 21, 2025 · 0 comments · May be fixed by #3785
Open

Extension crashes and performance issues due to excessive globalState usage for task history #3784

KJ7LNW opened this issue May 21, 2025 · 0 comments · May be fixed by #3785
Assignees
Labels
bug Something isn't working Issue - In Progress Someone is actively working on this. Should link to a PR soon.

Comments

@KJ7LNW
Copy link
Collaborator

KJ7LNW commented May 21, 2025

Problem

The current task history persistence mechanism stores all history items directly in VSCode's globalState, which is causing several critical issues:

  1. VSCode Warnings: The extension triggers VSCode warnings about excessive globalState usage:

    WARN [mainThreadStorage] large extension state detected (extensionId: RooVeterinaryInc.roo-cline, global: true): 6173.2822265625kb. Consider to use 'storageUri' or 'globalStorageUri' to store this data on disk instead.
    
  2. Extension Crashes and UI Issues: Users experience various issues that may be related to memory management and globalState limitations:

    • Complete extension crashes or grey/white screens
    • Memory leaks consuming all available RAM
    • Possible globalState race conditions between VS Code instances leading to hangs, crashes, and VS Code instability
  3. Performance Degradation: Even before crashing, the extension suffers from performance issues due to loading and processing large amounts of history data at once.

  4. globalState Thrashing: The current implementation loads and replaces the entire array of task history items in globalState every time a single task is created or modified. This causes:

    • Excessive memory usage as the entire array is loaded into memory
    • Significant performance overhead for each task operation
    • Potential race conditions when multiple operations attempt to modify the array simultaneously
    • Increased risk of data corruption if a write operation is interrupted
    • Unnecessary network/disk I/O as the entire state is serialized and persisted repeatedly
  5. Scale Problem: A busy developer can accumulate tens of thousands of tasks over the course of a year. At this scale, the globalState approach becomes completely unsustainable:

    • The size of the globalState can grow to many megabytes
    • Loading and processing this amount of data becomes increasingly slow
    • The likelihood of crashes and performance issues increases dramatically
    • VSCode's globalState was never designed to handle this volume of data

Possibly Related Issues

Proposed Solution

Implement a file-based storage system for task history:

  1. Store individual history items as JSON files in a directory structure organized by year and month.
  2. Use globalState only for monthly indexes to enable efficient lookups.
  3. Modify the frontend to fetch history data incrementally by month rather than all at once.

This approach will:

  • Eliminate VSCode warnings about excessive globalState usage
  • Prevent extension crashes due to memory limitations
  • Improve performance by loading history data in smaller chunks
  • Avoid race conditions between VS Code instances by using the filesystem for storage
  • Eliminate globalState thrashing by operating on individual files instead of the entire history array
  • Scale efficiently to handle tens of thousands of tasks accumulated over time
@hannesrudolph hannesrudolph moved this from New to Issue [Unassigned] in Roo Code Roadmap May 22, 2025
@hannesrudolph hannesrudolph added the Issue - Unassigned / Actionable Clear and approved. Available for contributors to pick up. label May 23, 2025
@daniel-lxs daniel-lxs moved this from Issue [Unassigned] to Issue [In Progress] in Roo Code Roadmap May 26, 2025
@daniel-lxs daniel-lxs added bug Something isn't working Issue - In Progress Someone is actively working on this. Should link to a PR soon. and removed Issue - Unassigned / Actionable Clear and approved. Available for contributors to pick up. labels May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Issue - In Progress Someone is actively working on this. Should link to a PR soon.
Projects
Status: Issue [In Progress]
Development

Successfully merging a pull request may close this issue.

3 participants