Skip to content

Conversation

@cte
Copy link
Collaborator

@cte cte commented Apr 23, 2025

Context

TODO:

  • Migrate from old to new file format

I was surprised at how well the pure JSON approach works for huge conversation histories. In short, there are definitely real wins with JSONL, but I'm not sure it matters in practice. I also tried YAML but the JSON parser is way faster natively.

Here's what Roo Code came up with:

Recommendation

Strongly recommend adopting the JSONL implementation for task message storage for the following reasons:

  1. Superior Performance: Significantly faster, especially for sequential operations that mirror real-world usage patterns (6.56x speedup)

  2. Better Scaling: Performance remains consistent regardless of conversation size

  3. Lower Memory Footprint: Only needs to process the new message, not the entire conversation history

  4. Append-Optimized: Perfectly suited for chat applications where new messages are frequently added

  5. Streaming Compatibility: Easier to implement streaming reads for large conversation histories

The performance advantage of JSONL becomes increasingly significant as conversations grow larger, making it the clear choice for a chat-based application like Roo Code.

Implementation

Screenshots

before after

How to Test

Get in Touch


Important

Add JSONL implementation for task message storage with improved performance and adjust cache settings.

  • JSONL Implementation:
    • Adds readTaskMessages, writeTaskMessages, and appendTaskMessage functions in taskMessages.jsonl.ts for handling task messages in JSONL format.
    • Utilizes readline for efficient line-by-line reading and fs for file operations.
  • Performance:
    • JSONL format offers superior performance, better scaling, lower memory usage, and is append-optimized.
  • Misc:
    • Adjusts taskSizeCache TTL to 30 seconds and check period to 5 minutes in taskMetadata.ts.

This description was created by Ellipsis for fc9d4f5. You can customize this summary. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Apr 23, 2025

🦋 Changeset detected

Latest commit: fc9d4f5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
roo-cline Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 23, 2025
@ellipsis-dev
Copy link
Contributor

ellipsis-dev bot commented Apr 23, 2025

The changes in this pull request are cohesive and related to implementing and benchmarking a JSONL format for task message storage. Therefore, it does not need to be split into smaller pull requests. The benchmark results, script, and storage utilities are all part of this implementation and should remain together.

@dosubot dosubot bot added the enhancement New feature or request label Apr 23, 2025
cte and others added 3 commits April 22, 2025 22:35
@samhvw8
Copy link
Contributor

samhvw8 commented Apr 23, 2025

can't wait to see this merged 💪🏻

@mrubens
Copy link
Collaborator

mrubens commented Apr 23, 2025

Do you think jsonl is less likely to get corrupted if the process is force closed or dies?

@cte
Copy link
Collaborator Author

cte commented Apr 23, 2025

Yes - that's definitely a benefit.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 23, 2025
Base automatically changed from cte/task-persistence to main April 23, 2025 19:09
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Apr 23, 2025
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Apr 23, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Apr 23, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Apr 23, 2025
import { getTaskDirectoryPath } from "../../shared/storagePathManager"

const taskSizeCache = new NodeCache({ stdTTL: 5 * 60, checkperiod: 30 })
const taskSizeCache = new NodeCache({ stdTTL: 30, checkperiod: 5 * 60 })
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I swapped these original; the TTL should be 30s and the check period doesn't really matter.

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Apr 23, 2025
@sachasayan
Copy link
Contributor

Any blockers here?

@cte
Copy link
Collaborator Author

cte commented Apr 28, 2025

Any blockers here?

Current blocker is a migration function to convert the old format to the new format, similar to this: https://github.com/RooVetGit/Roo-Code/blob/main/src/core/task-persistence/apiMessages.ts#L26

@cte cte marked this pull request as draft May 5, 2025 17:29
@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to PR [Draft/WIP] in Roo Code Roadmap May 10, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Draft / In Progress] to TEMP in Roo Code Roadmap May 26, 2025
@daniel-lxs daniel-lxs moved this from TEMP to PR [Draft / In Progress] in Roo Code Roadmap May 26, 2025
@hannesrudolph
Copy link
Collaborator

stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Draft / In Progress size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants