Skip to content

perf: add TTL caching for @latest plugin resolution to reduce startup time #23143

Closed as not planned

Description

@mrosnerr

Problem

Every OpenCode startup runs Npm.add() for each plugin in the config, even when packages are already installed and cached. For plugins using @latest (or bare names that resolve to @latest via resolvePluginTarget()), this triggers Arborist's full reify() path on every launch.

Measured impact: ~11-15 seconds of startup time spent in npm install for 2 plugins (opencode-claude-auth@latest + oh-my-openagent@latest).

Log evidence:

17:08:53 service=plugin name=mg loading internal plugin
17:08:57 +4118ms service=plugin path=opencode-claude-auth@latest loading plugin
17:08:57 service=npm pkg=opencode-claude-auth@latest installing package
17:08:57 service=npm pkg=oh-my-openagent@latest installing package
17:09:09 +11441ms service=bus type=* subscribing

Current Behavior

  1. resolvePluginTarget() in plugin/shared.ts appends @latest for bare plugin names
  2. Npm.add() in npm/index.ts attempts loadVirtual() (fast path) but falls through to reify()
  3. This happens unconditionally on every startup — no TTL, staleness check, or skip mechanism

Proposed Solution

Add a TTL-based cache for @latest plugin resolution:

  • On startup, check the mtime of the plugin's package-lock.json (or a dedicated cache marker file)
  • If last resolved within a configurable TTL (e.g., 24 hours), use the cached version — just run loadVirtual() without reify()
  • If stale, do the full resolution + reify
  • Optionally expose a config option like plugin_update_interval or a CLI flag like --update-plugins to force a fresh check

This preserves the "always latest" behavior while eliminating the 11+ second tax on every startup.

Related Issues

Environment

  • macOS (darwin arm64)
  • OpenCode 1.4.7
  • Plugins: opencode-claude-auth@latest, oh-my-openagent@latest
  • Package cache: ~/.cache/opencode/packages/

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Apr 17, 2026
  2. github-actions commented on Apr 17, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. This issue must use one of the three templates: Bug Report, Feature Request, or Question. Since this is a feature/performance improvement request, it should use the Feature Request template, which requires a title starting with [FEATURE]: and a verification checkbox confirming you've searched for existing issues.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. github-actions commented on Apr 17, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)perfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions