GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Performance: inefficient O(N^2) ripgrep callback · Issue #37869 · anomalyco/opencode

Performance: inefficient O(N^2) ripgrep callback #37869

New issue
Copy link
New issue
Copy link
Closed
Closed
Performance: inefficient O(N^2) ripgrep callback#37869
Copy link
Assignees
nexxeln

Description

@quark-zju
quark-zju
opened on Jul 20, 2026
Issue body actions

Description

Inefficient code:

opencode/packages/core/src/filesystem/search.ts

Lines 41 to 46 in 2db96c9

Effect.sync(() => {
state.files.push(entry.path)
const parts = entry.path.split("/")
parts.slice(0, -1).forEach((_, index) => directories.add(parts.slice(0, index + 1).join("/") + path.sep))
state.directories = Array.from(directories)
}),

Array.from(directories) called per file. So O(files * dirs).

The path split-then-join also seems optimizable to avoid joins.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions
    assigned
    nexxeln
    on Jul 20, 2026
  2. AceRothstein71 commented on Sep 17, 2026

    @AceRothstein71
    AceRothstein71
    on Sep 17, 2026
    More actions

    The per-entry Array.from(directories) plus repeated prefix joins made the initial filesystem scan O(files × directories). Directories now accumulate in place in a set and materialize once per query. The fix and coverage are on the branch of PR #48638.

  3. AceRothstein71 commented on Sep 17, 2026

    @AceRothstein71
    AceRothstein71
    on Sep 17, 2026
    More actions

    Fixed on the branch of PR #48638: state.directories is now a Set that accumulates prefixes in place (no per-entry Array.from, no per-prefix re-joins) and is materialized once per query.

  4. neriousy commented on Oct 19, 2026

    @neriousy
    neriousy
    on Oct 19, 2026
    Member
    More actions

    The quadratic directory materialization is fixed in v2: the scan accumulates files and directories in Maps, and only materializes candidates when a search runs. Path-prefix split/join operations remain, but the per-file Array.from(directories) is gone.

  5. neriousy
    closed this as completedon Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @nexxeln
    nexxeln

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.