Skip to content

Batch thread lifecycle commands instead of one index rewrite per thread #521

Description

@Tryanks

Summary

Bulk thread operations issue one command per thread, and every command rewrites the whole index, so cost grows with the square of the thread count.

Where

  • Store::upsert_meta / RemoveSession re-read and rewrite all of sessions.json (2 MB for ~2.7k threads on the maintainer's machine) for each change (crates/services/src/store.rs).
  • Settings → Delete all archived sends one DeleteSession per thread (the loop in crates/ui/src/settings_page.rs carries a "ponytail" note about exactly this), and each delete also calls persist_settings.
  • Sidebar "Archive all" sends one ArchiveSession per thread (crates/ui/src/sidebar.rs).
  • delete_project loops over delete_session; archive_session_ids persists each id of a subtree separately (crates/runtime/src/app/sessions.rs).

Proposal

  • Protocol: ArchiveSessions { session_ids }, UnarchiveSessions { session_ids }, DeleteSessions { session_ids, remove_worktrees }. Single-id commands become thin wrappers or are removed.
  • Store writer: UpsertMetas(Vec<SessionMeta>) and RemoveSessions(Vec<String>), one index write and one settings write per command.
  • Cascades (archive subtree, delete subtree, delete project) use the batched writes.

This is independent of the storage-engine change and should land first; the redb index later makes each write cheap, but the batched command shape stays.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestperformanceRuntime performance, latency, resource footprint

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions