Glob search uses 100% of CPU #3390

Open
opened 2026-02-16 17:39:53 -05:00 by yindo · 21 comments
Owner

Originally created by @ArmoredBear on GitHub (Dec 7, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Everytime i use opencode to do something on my system, regarless of what it is, if it needs to search for a file it uses glob, or the RG process. This uses 100% of my CPU, i dont know why.

OpenCode version

OpenCode 1.0.134

Steps to reproduce

1-Open opencode.
2-Ask to search and open or edit a file
3-It uses Glob for the task
4-Using btop as a task manager a RG process appears and uses 100% of CPU.

Screenshot and/or share link

No response

Operating System

Im using Garuda Linux

Terminal

Cool Retro Term or Kitty Terminal

Originally created by @ArmoredBear on GitHub (Dec 7, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description Everytime i use opencode to do something on my system, regarless of what it is, if it needs to search for a file it uses glob, or the RG process. This uses 100% of my CPU, i dont know why. ### OpenCode version OpenCode 1.0.134 ### Steps to reproduce 1-Open opencode. 2-Ask to search and open or edit a file 3-It uses Glob for the task 4-Using btop as a task manager a RG process appears and uses 100% of CPU. ### Screenshot and/or share link _No response_ ### Operating System Im using Garuda Linux ### Terminal Cool Retro Term or Kitty Terminal
yindo added the bugperf labels 2026-02-16 17:39:53 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 7, 2025):

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

  • #4804: High CPU usage when idle or switching sessions
  • #811: Text rendering is VERY slow with high CPU usage even when idle
  • #2083: High CPU usage from text animation/rendering, affecting all cores
  • #3176: High CPU usage from git operations (session snapshots with git add)

These issues describe similar symptoms of excessive CPU usage in OpenCode. Feel free to check if any of these address your specific case or if yours is a distinct issue with the glob/RG process specifically.

@github-actions[bot] commented on GitHub (Dec 7, 2025): This issue might be a duplicate of existing performance-related issues. Please check: - #4804: High CPU usage when idle or switching sessions - #811: Text rendering is VERY slow with high CPU usage even when idle - #2083: High CPU usage from text animation/rendering, affecting all cores - #3176: High CPU usage from git operations (session snapshots with git add) These issues describe similar symptoms of excessive CPU usage in OpenCode. Feel free to check if any of these address your specific case or if yours is a distinct issue with the glob/RG process specifically.
Author
Owner

@ry2009 commented on GitHub (Dec 8, 2025):

@ArmoredBear @rekram1-node a couple questions on the topic:

  • Does CPU stay at 100% for several seconds, or is it just a brief spike? Rough duration?
  • What are the biggest directories in the repo (e.g., node_modules, .cache, vendor, build/output dirs)?
  • Please run from project root and share outputs:
    • time rg --files --hidden --glob '!.git/*'
    • find . -maxdepth 3 | wc -l
  • Which task triggered it (/read, /open, /edit, etc.), and the exact prompt if possible?

I also have an open PR if you have time you can checkout into it and see if it solves (its a mitigation rn instead of perf fix bc there could be many ways to take this deep dive): https://github.com/sst/opencode/pull/5266

@ry2009 commented on GitHub (Dec 8, 2025): @ArmoredBear @rekram1-node a couple questions on the topic: - Does CPU stay at 100% for several seconds, or is it just a brief spike? Rough duration? - What are the biggest directories in the repo (e.g., node_modules, .cache, vendor, build/output dirs)? - Please run from project root and share outputs: - time rg --files --hidden --glob '!.git/*' - find . -maxdepth 3 | wc -l - Which task triggered it (/read, /open, /edit, etc.), and the exact prompt if possible? I also have an open PR if you have time you can checkout into it and see if it solves (its a mitigation rn instead of perf fix bc there could be many ways to take this deep dive): https://github.com/sst/opencode/pull/5266
Author
Owner

@ArmoredBear commented on GitHub (Dec 8, 2025):

Its not a spike, or for several seconds, when i tell opencode using grok code fast to search for a file it does recursively and keeps my CPU at 100% until either a ask it to stop, kill opencode or restart my computer! Most of the time i need to restart my computer!

There is no exact prompt, when i simply tell opencode to edit a file and add some text or search for something and open this happens! And its random! sometime s it happens and when it does opencode hangs, as like its thinking and nothing happens for a long time and then CPU its a 100%. then i kill it or restar my computer and then it does not happen again for some time, but its very frequent. Like for 5 prompts 3 of them happen.

@ArmoredBear commented on GitHub (Dec 8, 2025): Its not a spike, or for several seconds, when i tell opencode using grok code fast to search for a file it does recursively and keeps my CPU at 100% until either a ask it to stop, kill opencode or restart my computer! Most of the time i need to restart my computer! There is no exact prompt, when i simply tell opencode to edit a file and add some text or search for something and open this happens! And its random! sometime s it happens and when it does opencode hangs, as like its thinking and nothing happens for a long time and then CPU its a 100%. then i kill it or restar my computer and then it does not happen again for some time, but its very frequent. Like for 5 prompts 3 of them happen.
Author
Owner

@ry2009 commented on GitHub (Dec 9, 2025):

@ArmoredBear
I am taking a deep dive into the CPU/glob I might have found the issue but I cannot reproduce this on my side for some reason so I am wondering if you can checkout into my open PR and still see if you reproduce the errors from your side.

Please at your earliest chance try and checkout into branch feat/glob-cpu-cap and run your normal ‘search/open/edit’ flow. Do you still get sustained 100% CPU? If yes, did you enable follow?If so disable it and try again. If it only happens with follow, I’ll ship a safe follow implementation next. How big of a codebase are you searching / any patterns like "" / "/*" in parallel?

Where I think error is in --follow tag(symlink looping):
https://unix.stackexchange.com/questions/99159/is-there-an-algorithm-to-decide-if-a-symlink-loops
https://stackoverflow.com/questions/14569390/why-do-i-have-an-infinite-recursion-loop-happening-with-these-symlinks
https://github.com/nextcloud/desktop/issues/6711

If this is true I will not rely on rg --follow and create a walk with lstat to keep track of symlink inodes visited to not continuously loop/chase forever... however if it is not pls let me know any more info you can on this issue, ty!

@ry2009 commented on GitHub (Dec 9, 2025): @ArmoredBear I am taking a deep dive into the CPU/glob I might have found the issue but I cannot reproduce this on my side for some reason so I am wondering if you can checkout into my open PR and still see if you reproduce the errors from your side. Please at your earliest chance try and checkout into branch feat/glob-cpu-cap and run your normal ‘search/open/edit’ flow. Do you still get sustained 100% CPU? If yes, did you enable follow?If so disable it and try again. If it only happens with follow, I’ll ship a safe follow implementation next. How big of a codebase are you searching / any patterns like "**" / "**/*" in parallel? Where I think error is in --follow tag(symlink looping): https://unix.stackexchange.com/questions/99159/is-there-an-algorithm-to-decide-if-a-symlink-loops https://stackoverflow.com/questions/14569390/why-do-i-have-an-infinite-recursion-loop-happening-with-these-symlinks https://github.com/nextcloud/desktop/issues/6711 If this is true I will not rely on rg --follow and create a walk with lstat to keep track of symlink inodes visited to not continuously loop/chase forever... however if it is not pls let me know any more info you can on this issue, ty!
Author
Owner

@ArmoredBear commented on GitHub (Dec 16, 2025):

Look, im really a beginner on this stuff, so i dont know how to do what you asking. Sorry. Im just using the tool to help me with developing a game with C#, but when i ask to search for a script or file the problem keeps happening, ill tell you that it only happens when Glob, RipGrep or Grep are used, in which checking for usage of CPU using btop on my terminal it shows RG process consuming 100% of CPU and does not stop until i kill the process, basically every time i need to use the tool i need to specify for it to not use anything that uses rg process. Now, the commands "list" and "find" when not using rg process get a bit slow on the search itself which is fine by me, but it does not lag anything and does not use 100% of CPU. Also, when rg is used the tool hangs and does nothing for a long period of time, then stops, does not find what i want and CPU keeps at 100%. Sorry i will not be able to do what you want, so i hope this information will help you

@ArmoredBear commented on GitHub (Dec 16, 2025): Look, im really a beginner on this stuff, so i dont know how to do what you asking. Sorry. Im just using the tool to help me with developing a game with C#, but when i ask to search for a script or file the problem keeps happening, ill tell you that it only happens when Glob, RipGrep or Grep are used, in which checking for usage of CPU using btop on my terminal it shows RG process consuming 100% of CPU and does not stop until i kill the process, basically every time i need to use the tool i need to specify for it to not use anything that uses rg process. Now, the commands "list" and "find" when not using rg process get a bit slow on the search itself which is fine by me, but it does not lag anything and does not use 100% of CPU. Also, when rg is used the tool hangs and does nothing for a long period of time, then stops, does not find what i want and CPU keeps at 100%. Sorry i will not be able to do what you want, so i hope this information will help you
Author
Owner

@jchan1e commented on GitHub (Dec 19, 2025):

I'm having the same issue. I don't think it's finding a symlink loop, because there are no symlinks in the project directory I was testing in. I asked it to search for any documentation in a folder with only a couple of python files in it and no subdirectories. It executed *Glob "path/to/project/**/*.md" and then hung there indefinitely while fully utilizing 12 threads. When I killed the rg process, OpenCode immediately re-executed the tool with the same wildcards in the path and the result was the same 1200% process utilization hanging indefinitely. I'm not able to reproduce this behavior using the ripgrep tool itself from the terminal, but I haven't tried exhausting all possible permutations of options and conditions.

@jchan1e commented on GitHub (Dec 19, 2025): I'm having the same issue. I don't think it's finding a symlink loop, because there are no symlinks in the project directory I was testing in. I asked it to search for any documentation in a folder with only a couple of python files in it and no subdirectories. It executed `*Glob "path/to/project/**/*.md"` and then hung there indefinitely while fully utilizing 12 threads. When I killed the rg process, OpenCode immediately re-executed the tool with the same wildcards in the path and the result was the same 1200% process utilization hanging indefinitely. I'm not able to reproduce this behavior using the ripgrep tool itself from the terminal, but I haven't tried exhausting all possible permutations of options and conditions.
Author
Owner

@rekram1-node commented on GitHub (Dec 19, 2025):

what os?

@rekram1-node commented on GitHub (Dec 19, 2025): what os?
Author
Owner

@jchan1e commented on GitHub (Dec 19, 2025):

I'm on Ubuntu Studio 25.10. I installed OpenCode via the bash script. It reports itself as version 1.0.170. I haven't changed the config files from the default except to add a self-hosted model endpoint.

@jchan1e commented on GitHub (Dec 19, 2025): I'm on Ubuntu Studio 25.10. I installed OpenCode via the bash script. It reports itself as version 1.0.170. I haven't changed the config files from the default except to add a self-hosted model endpoint.
Author
Owner

@specter119 commented on GitHub (Jan 4, 2026):

I also met this opencode was installed by bun, and my system is archlinux.

@specter119 commented on GitHub (Jan 4, 2026): I also met this opencode was installed by bun, and my system is archlinux.
Author
Owner

@jeeruff commented on GitHub (Jan 6, 2026):

same here, cachyos, installed opencode with curl bash link

@jeeruff commented on GitHub (Jan 6, 2026): same here, cachyos, installed opencode with curl bash link
Author
Owner

@DxTa commented on GitHub (Jan 7, 2026):

I got similar behaviour with rg process in opencode 1.1.4 and ubuntu 25.10

@DxTa commented on GitHub (Jan 7, 2026): I got similar behaviour with `rg` process in opencode 1.1.4 and ubuntu 25.10
Author
Owner

@PhilippPolterauer commented on GitHub (Jan 8, 2026):

same on my machine
Windows 11, wsl ubuntu 24.04
Image
some AIs call a very generic blob, and i have a node_modules folder with many files. which i think is the reason it is so slow.

Image

maybe the harness could put a reasonable (configurable) timeout on the glob command, e.g. 1 sec or similar

@PhilippPolterauer commented on GitHub (Jan 8, 2026): same on my machine Windows 11, wsl ubuntu 24.04 <img width="2515" height="434" alt="Image" src="https://github.com/user-attachments/assets/53b11559-e519-41dd-b25c-8b7e59c361fb" /> some AIs call a very generic blob, and i have a node_modules folder with many files. which i think is the reason it is so slow. <img width="405" height="196" alt="Image" src="https://github.com/user-attachments/assets/2bf1cccb-58da-493d-b80a-78e7ac8c1d1e" /> maybe the harness could put a reasonable (configurable) timeout on the glob command, e.g. 1 sec or similar
Author
Owner

@Material-Scientist commented on GitHub (Jan 9, 2026):

Same here. I even tried restricting its permissions, but it ignores those:

  "permission": {
    "glob": {
      "*": "deny",
      "pattern=/root/.local/share/opencode/storage/projects/*": "allow"
    }
  }

It always tries to do pattern=**/* and CPU use goes to 100% and hangs.

This is really annoying...

Nomad job:

job "opencode" {
  group "opencode" {
    network {
      mode = "bridge"
      port "envoy-metrics" {}
      port "plannotator" {
        static = 9999
        to = 9999
      }
    }
    volume "opencode" {
      type            = "csi"
      read_only       = false
      source          = "opencode"
      access_mode     = "single-node-writer"
      attachment_mode = "file-system"
    }    
    constraint {
      attribute = "${attr.unique.hostname}"
      operator  = "regexp"
      value     = "SMTRL-P05"
    }
    service {
      name     = "opencode"
      port     = "3000"
      meta {
        envoy_metrics_port = "${NOMAD_HOST_PORT_envoy_metrics}" # make envoy metrics port available in Consul
      }
      tags = [
				"traefik.http.routers.opencode.middlewares=https-headers@file",
      ]
      connect {
        sidecar_service {
          proxy {
            transparent_proxy {
              exclude_outbound_ports = [53,8600,443]
              exclude_outbound_cidrs = ["172.26.64.0/20","127.0.0.0/8"]
            }
            expose {
              path {
                path = "/metrics"
                protocol = "http"
                local_path_port = 9102
                listener_port = "envoy-metrics"
              }
            }
          }
        }
      }
      check {
        expose = true
        type     = "http"
        path     = "/global/health"
        interval = "15s"
        timeout  = "1s"
      }
    }
    task "opencode" {
      driver = "docker"
      config {
        image = "ghcr.io/anomalyco/opencode" # latest
        command = "web"
        args = [
          "--port=3000",
          "--hostname=0.0.0.0",
          "--print-logs",
          "--log-level=DEBUG"
          #"--mdns=true"
        ]
        volumes = [
          "local/custom-config.json:/root/.config/opencode/opencode.json",
          "local/AGENTS.md:/root/.config/opencode/AGENTS.md",
        ]
        work_dir = "/root/.local/share/opencode/storage/projects"
      }
      volume_mount {
        volume      = "opencode"
        destination = "/root/.local/share/opencode/storage"
        read_only = false
      }      
      resources {
        cpu = 1024
        memory = 1024
        memory_max = 4096
      }
      template {
        destination = "local/custom-config.json"
        data = <<EOH
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["@plannotator/opencode@latest"],
	"mcp": {
    "web": {
      "type": "remote",
      "url": "http://n8n.virtual.consul/mcp/8cc2af19-111a-45a5-a282-1548f1ea2892",
      "enabled": true
    }
  },
  "permission": {
    "edit": {
      "*": "deny",
      "/root/.local/share/opencode/storage/projects/*": "allow"
    },
    "glob": {
      "*": "deny",
      "pattern=/root/.local/share/opencode/storage/projects/*": "allow"
    },
    "list": {
      "*": "deny",
      "/root/.local/share/opencode/storage/projects/*": "allow"
    },
    "write": {
      "*": "deny",
      "/root/.local/share/opencode/storage/projects/*": "allow"
    }
  },
  "provider": {
    "llama.cpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "llama-server (local)",
      "options": {
        "baseURL": "http://local-ai.virtual.consul/v1"
      },
      "models": {
        "gpt-oss-120b-GGUF": {
          "id": "gpt-oss-120b-GGUF",
          "name": "gpt-oss-120b-GGUF",
          "tool_call": true,
          "reasoning": true,
          "limit": {
            "context": 128000,
            "output": 128000
          }
        },
				"Qwen3-8B-128k-GGUF": {
          "id": "Qwen3-8B-128k-GGUF",
          "name": "Qwen3-8B-128k-GGUF",
          "tool_call": true,
          "reasoning": false,
          "limit": {
            "context": 128000,
            "output": 128000
          }
        },
      }
    }
  },
  "model": "llama-server/gpt-oss-120b-GGUF",
  "agent": {
    "build": {
      "description": "Default coding mode with only Opencode tools.",
      "tools": {
        "read": true,
        "write": true,
        "edit": true,
        "bash": true,
        "grep": true,
        "glob": false,
        "list": true,
        "webfetch": false,
        "patch": true,
        "todoread": true,
        "todowrite": true,
        "submit_plan": true
      },
      "prompt": "{file:./AGENTS.md}"
    }
  },
  "instructions": ["AGENTS.md"]
}        
EOH        
      }
      template {
        destination = "local/AGENTS.md"
        data = <<EOH
# Tooling rules for Opencode
- Use Opencode tools only: read, write, edit, list, glob, grep, webfetch, bash, task, todowrite, todoread, submit_plan.
- Do NOT call non-existent tools like Repo_browser.*.
- Prefer `edit` for modifying existing files; use `read` to inspect before editing.
- For any search engine queries, and extracting specific info from pages, utilize the web MCP server.
EOH        
      }
      template {
        destination = "secrets/.env"
        env = true
        data = <<EOH
PLANNOTATOR_PORT=9999
PLANNOTATOR_REMOTE=1
#OPENCODE_CONFIG=/path/to/my/custom-config.json
#HTTPS_PROXY=http://username:{{ key "secrets/firecrawl/proxy.pw" }}@192.168.178.87:3128
#https_proxy=http://username:{{ key "secrets/firecrawl/proxy.pw" }}@192.168.178.87:3128        
EOH
      }
    }
  }
}
@Material-Scientist commented on GitHub (Jan 9, 2026): Same here. I even tried restricting its permissions, but it ignores those: ```json "permission": { "glob": { "*": "deny", "pattern=/root/.local/share/opencode/storage/projects/*": "allow" } } ``` It always tries to do `pattern=**/*` and CPU use goes to 100% and hangs. This is really annoying... Nomad job: ```hcl job "opencode" { group "opencode" { network { mode = "bridge" port "envoy-metrics" {} port "plannotator" { static = 9999 to = 9999 } } volume "opencode" { type = "csi" read_only = false source = "opencode" access_mode = "single-node-writer" attachment_mode = "file-system" } constraint { attribute = "${attr.unique.hostname}" operator = "regexp" value = "SMTRL-P05" } service { name = "opencode" port = "3000" meta { envoy_metrics_port = "${NOMAD_HOST_PORT_envoy_metrics}" # make envoy metrics port available in Consul } tags = [ "traefik.http.routers.opencode.middlewares=https-headers@file", ] connect { sidecar_service { proxy { transparent_proxy { exclude_outbound_ports = [53,8600,443] exclude_outbound_cidrs = ["172.26.64.0/20","127.0.0.0/8"] } expose { path { path = "/metrics" protocol = "http" local_path_port = 9102 listener_port = "envoy-metrics" } } } } } check { expose = true type = "http" path = "/global/health" interval = "15s" timeout = "1s" } } task "opencode" { driver = "docker" config { image = "ghcr.io/anomalyco/opencode" # latest command = "web" args = [ "--port=3000", "--hostname=0.0.0.0", "--print-logs", "--log-level=DEBUG" #"--mdns=true" ] volumes = [ "local/custom-config.json:/root/.config/opencode/opencode.json", "local/AGENTS.md:/root/.config/opencode/AGENTS.md", ] work_dir = "/root/.local/share/opencode/storage/projects" } volume_mount { volume = "opencode" destination = "/root/.local/share/opencode/storage" read_only = false } resources { cpu = 1024 memory = 1024 memory_max = 4096 } template { destination = "local/custom-config.json" data = <<EOH { "$schema": "https://opencode.ai/config.json", "plugin": ["@plannotator/opencode@latest"], "mcp": { "web": { "type": "remote", "url": "http://n8n.virtual.consul/mcp/8cc2af19-111a-45a5-a282-1548f1ea2892", "enabled": true } }, "permission": { "edit": { "*": "deny", "/root/.local/share/opencode/storage/projects/*": "allow" }, "glob": { "*": "deny", "pattern=/root/.local/share/opencode/storage/projects/*": "allow" }, "list": { "*": "deny", "/root/.local/share/opencode/storage/projects/*": "allow" }, "write": { "*": "deny", "/root/.local/share/opencode/storage/projects/*": "allow" } }, "provider": { "llama.cpp": { "npm": "@ai-sdk/openai-compatible", "name": "llama-server (local)", "options": { "baseURL": "http://local-ai.virtual.consul/v1" }, "models": { "gpt-oss-120b-GGUF": { "id": "gpt-oss-120b-GGUF", "name": "gpt-oss-120b-GGUF", "tool_call": true, "reasoning": true, "limit": { "context": 128000, "output": 128000 } }, "Qwen3-8B-128k-GGUF": { "id": "Qwen3-8B-128k-GGUF", "name": "Qwen3-8B-128k-GGUF", "tool_call": true, "reasoning": false, "limit": { "context": 128000, "output": 128000 } }, } } }, "model": "llama-server/gpt-oss-120b-GGUF", "agent": { "build": { "description": "Default coding mode with only Opencode tools.", "tools": { "read": true, "write": true, "edit": true, "bash": true, "grep": true, "glob": false, "list": true, "webfetch": false, "patch": true, "todoread": true, "todowrite": true, "submit_plan": true }, "prompt": "{file:./AGENTS.md}" } }, "instructions": ["AGENTS.md"] } EOH } template { destination = "local/AGENTS.md" data = <<EOH # Tooling rules for Opencode - Use Opencode tools only: read, write, edit, list, glob, grep, webfetch, bash, task, todowrite, todoread, submit_plan. - Do NOT call non-existent tools like Repo_browser.*. - Prefer `edit` for modifying existing files; use `read` to inspect before editing. - For any search engine queries, and extracting specific info from pages, utilize the web MCP server. EOH } template { destination = "secrets/.env" env = true data = <<EOH PLANNOTATOR_PORT=9999 PLANNOTATOR_REMOTE=1 #OPENCODE_CONFIG=/path/to/my/custom-config.json #HTTPS_PROXY=http://username:{{ key "secrets/firecrawl/proxy.pw" }}@192.168.178.87:3128 #https_proxy=http://username:{{ key "secrets/firecrawl/proxy.pw" }}@192.168.178.87:3128 EOH } } } } ```
Author
Owner

@7ac9d42 commented on GitHub (Jan 10, 2026):

I also encountered this issue, where the rg process completely saturated the CPU for up to 20 minutes, forcing me to manually kill the process.
rg is invoked using the command:
/usr/bin/rg --files --glob=!.git/* --follow --hidden --glob=**/*hypr*log*.
The call chain is:
systemd (pid 1) → bash (pid 6127) → kitty (pid 6128) → fish (pid 83468) → opencode (pid 83603) → rg (pid 96123).
Can I mitigate this issue through some configuration?
Using archlinux opencode 1.1.12

@7ac9d42 commented on GitHub (Jan 10, 2026): I also encountered this issue, where the `rg` process completely saturated the CPU for up to 20 minutes, forcing me to manually kill the process. `rg` is invoked using the command: `/usr/bin/rg --files --glob=!.git/* --follow --hidden --glob=**/*hypr*log*`. The call chain is: `systemd (pid 1) → bash (pid 6127) → kitty (pid 6128) → fish (pid 83468) → opencode (pid 83603) → rg (pid 96123)`. Can I mitigate this issue through some configuration? Using archlinux opencode 1.1.12
Author
Owner

@Cynary commented on GitHub (Jan 12, 2026):

I've been hitting this frequently - the agent completely hangs waiting for rg while rg takes up 1000% CPU :/ I feel like it's looking for patterns in places with a lot of files (for example, latest one hit while it was looking in .cache) - maybe just having a limit on how many files it can search, or a timeout would be enough of a fix?

...

and 1 minute after I posted this it did it again :/
globbing in .local/share , .cache, and .local/state

@Cynary commented on GitHub (Jan 12, 2026): I've been hitting this frequently - the agent completely hangs waiting for rg while rg takes up 1000% CPU :/ I feel like it's looking for patterns in places with a lot of files (for example, latest one hit while it was looking in .cache) - maybe just having a limit on how many files it can search, or a timeout would be enough of a fix? ... and 1 minute after I posted this it did it again :/ globbing in .local/share , .cache, and .local/state
Author
Owner

@troychn commented on GitHub (Jan 17, 2026):


Title
High CPU usage caused by stuck rg processes when performing search-related operations

Description
I'm experiencing a similar issue. When I ask OpenCode to perform any search-related task, multiple rg (ripgrep) processes spawn and consume extremely high CPU resources. These processes run indefinitely without completing, and OpenCode becomes completely unresponsive.
The only way to recover is to manually force-kill the rg processes.
Environment

  • OS: macOS
  • OpenCode version: v1.1.25
    Steps to Reproduce
  1. Start OpenCode
  2. Ask the assistant to perform any search-related operation (e.g., searching for files, finding code patterns, exploring the codebase)
  3. Observe system processes
    Expected Behavior
    The rg processes should complete in a reasonable time and return results to OpenCode.
    Actual Behavior
  • Multiple rg processes appear in the process list
  • CPU usage spikes to very high levels
  • The rg processes run indefinitely and never terminate
  • OpenCode UI becomes unresponsive
  • Manual termination of the rg processes is required to regain control
    Additional Context
    This issue seems to be related to the ripgrep subprocess not properly terminating or hitting some edge case that causes it to hang.
@troychn commented on GitHub (Jan 17, 2026): --- Title High CPU usage caused by stuck rg processes when performing search-related operations --- Description I'm experiencing a similar issue. When I ask OpenCode to perform any search-related task, multiple rg (ripgrep) processes spawn and consume extremely high CPU resources. These processes run indefinitely without completing, and OpenCode becomes completely unresponsive. The only way to recover is to manually force-kill the rg processes. Environment - OS: macOS - OpenCode version: v1.1.25 Steps to Reproduce 1. Start OpenCode 2. Ask the assistant to perform any search-related operation (e.g., searching for files, finding code patterns, exploring the codebase) 3. Observe system processes Expected Behavior The rg processes should complete in a reasonable time and return results to OpenCode. Actual Behavior - Multiple rg processes appear in the process list - CPU usage spikes to very high levels - The rg processes run indefinitely and never terminate - OpenCode UI becomes unresponsive - Manual termination of the rg processes is required to regain control Additional Context This issue seems to be related to the ripgrep subprocess not properly terminating or hitting some edge case that causes it to hang.
Author
Owner

@alexeydubinin commented on GitHub (Jan 18, 2026):

Same on macOS. killall rg works as a quick fix. Unfortunately, OpenCode has become unusable for me.

@alexeydubinin commented on GitHub (Jan 18, 2026): Same on macOS. killall rg works as a quick fix. Unfortunately, OpenCode has become unusable for me.
Author
Owner

@ry2009 commented on GitHub (Jan 18, 2026):

@alexeydubinin @troychn and anyone else that can and is willing to test it out, this perf issue is very hard to replicate/see but I have once again tried to resolve it... if you can see if you can replicate it on my PR/branch (or hopefully not) that would be wonderful my version should be up to date with most recent OC commit -- check it out here: https://github.com/anomalyco/opencode/pull/9220

@ry2009 commented on GitHub (Jan 18, 2026): @alexeydubinin @troychn and anyone else that can and is willing to test it out, this perf issue is very hard to replicate/see but I have once again tried to resolve it... if you can see if you can replicate it on my PR/branch (or hopefully not) that would be wonderful my version should be up to date with most recent OC commit -- check it out here: https://github.com/anomalyco/opencode/pull/9220
Author
Owner

@alexeydubinin commented on GitHub (Jan 18, 2026):

@ry2009 I checked the same prompt with Codex, and all rg calls were performed without the --hidden and --follow flags.

@alexeydubinin commented on GitHub (Jan 18, 2026): @ry2009 I checked the same prompt with Codex, and all rg calls were performed without the --hidden and --follow flags.
Author
Owner

@Newbbsss commented on GitHub (Jan 28, 2026):

@ArmoredBear I am taking a deep dive into the CPU/glob I might have found the issue but I cannot reproduce this on my side for some reason so I am wondering if you can checkout into my open PR and still see if you reproduce the errors from your side.

Please at your earliest chance try and checkout into branch feat/glob-cpu-cap and run your normal ‘search/open/edit’ flow. Do you still get sustained 100% CPU? If yes, did you enable follow?If so disable it and try again. If it only happens with follow, I’ll ship a safe follow implementation next. How big of a codebase are you searching / any patterns like "" / "/*" in parallel?

Where I think error is in --follow tag(symlink looping): https://unix.stackexchange.com/questions/99159/is-there-an-algorithm-to-decide-if-a-symlink-loops https://stackoverflow.com/questions/14569390/why-do-i-have-an-infinite-recursion-loop-happening-with-these-symlinks nextcloud/desktop#6711

If this is true I will not rely on rg --follow and create a walk with lstat to keep track of symlink inodes visited to not continuously loop/chase forever... however if it is not pls let me know any more info you can on this issue, ty!

Use kimi k2 and ask it to glob something on your machine even after session closes the cpu usage is still high

@Newbbsss commented on GitHub (Jan 28, 2026): > [@ArmoredBear](https://github.com/ArmoredBear) I am taking a deep dive into the CPU/glob I might have found the issue but I cannot reproduce this on my side for some reason so I am wondering if you can checkout into my open PR and still see if you reproduce the errors from your side. > > Please at your earliest chance try and checkout into branch feat/glob-cpu-cap and run your normal ‘search/open/edit’ flow. Do you still get sustained 100% CPU? If yes, did you enable follow?If so disable it and try again. If it only happens with follow, I’ll ship a safe follow implementation next. How big of a codebase are you searching / any patterns like "**" / "**/*" in parallel? > > Where I think error is in --follow tag(symlink looping): https://unix.stackexchange.com/questions/99159/is-there-an-algorithm-to-decide-if-a-symlink-loops https://stackoverflow.com/questions/14569390/why-do-i-have-an-infinite-recursion-loop-happening-with-these-symlinks [nextcloud/desktop#6711](https://github.com/nextcloud/desktop/issues/6711) > > If this is true I will not rely on rg --follow and create a walk with lstat to keep track of symlink inodes visited to not continuously loop/chase forever... however if it is not pls let me know any more info you can on this issue, ty! Use kimi k2 and ask it to glob something on your machine even after session closes the cpu usage is still high
Author
Owner

@konovalov-nk commented on GitHub (Jan 30, 2026):

Please read this comment

@konovalov-nk commented on GitHub (Jan 30, 2026): Please read this [comment](https://github.com/anomalyco/opencode/issues/9676#issuecomment-3827198492)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3390