Repository navigation
Description
Description
I'm experiencing severe system instability after using OpenCode V2 for a few days on a Btrfs filesystem.
The strange part is that the usual system resources are nowhere near their limits:
Linux partition: 476 GB
Free disk space: ~20%
CPU usage during the issue: ~2%
RAM usage during the issue: ~29%
No obvious CPU or memory spikes
Despite having plenty of free disk space and system resources, the machine starts hanging continuously, applications begin crashing, and the entire desktop becomes extremely unresponsive.
After investigating the filesystem rather than CPU/RAM usage, I found that the problem appears to be related to Btrfs metadata exhaustion.
Btrfs has separate metadata space used for filesystem structures and file metadata. In my case, roughly 12 GB of filesystem metadata had been allocated, and after checking OpenCode's stored data, approximately 8 GB appeared to be associated with OpenCode's files/data.
The important part is that this is not simply "OpenCode is using 8 GB of disk space". The problem seems to be the large amount of filesystem metadata generated by the number of files/entries OpenCode creates and retains.
After approximately 2–3 days of normal OpenCode V2 usage, the metadata usage grows enough that the system starts becoming unstable.
Once the metadata pressure becomes high, I see:
System hangs
Applications crashing unexpectedly
Severe filesystem slowdown
Desktop becoming unresponsive
Problems occurring even though CPU and RAM usage remain low
Problems occurring while a significant amount of normal disk space is still available
This was particularly difficult to diagnose because df/normal disk usage, CPU usage, and RAM usage all looked relatively healthy.
I don't yet know which specific OpenCode storage component is responsible for the growth, so I don't want to incorrectly identify the root cause. I'm reporting the filesystem-level behavior because it appears strongly correlated with OpenCode V2 usage.
OpenCode also appears to retain a substantial amount of local session/state/storage data, so I suspect there may be a connection between long-running sessions, persisted state, caches, events, snapshots, or the number of files being generated.
I would appreciate it if the storage behavior of V2 on Btrfs could be investigated, particularly with respect to file count, metadata-heavy workloads, retention, and cleanup/compaction.
Plugins
none
OpenCode version
v2.0.18
Steps to reproduce
Steps to reproduce
Use OpenCode V2 normally on a Linux system using Btrfs.
Continue using OpenCode for several days, especially with long-running sessions and normal coding-agent activity.
Monitor Btrfs filesystem usage and metadata usage.
Observe metadata usage increasing substantially over time.
Eventually, when metadata space becomes heavily utilized, the system starts experiencing filesystem-related instability, hangs, and application crashes.
Screenshot and/or share link
No response
Operating System
CachyOS (Arch Linux)
Terminal
Kitty
Activity
github-actions commentedon Sep 28, 2026
This report may overlap with existing OpenCode database/event-storage growth reports, particularly if the Btrfs metadata increase is driven by
opencode.dbor EventV2 history.This issue might be related to existing issues. Please check:
message.updated.1snapshots.opencode-agent commentedon Sep 28, 2026
Thanks for reporting this. We'd like to distinguish Btrfs metadata used from metadata allocated, and identify which OpenCode storage component is growing. Could you share the following from the affected machine, ideally once before a session and again when the slowdown starts?
If your OpenCode data directory is elsewhere, substitute its actual path. Also, how did you arrive at the ~8 GB figure attributed to OpenCode metadata (rather than file data), and are there Btrfs/ENOSPC messages in the kernel log around the hangs? Please redact any private paths or content before sharing logs. No need to delete snapshots or the database to collect these measurements.
swadhinbiswas commentedon Sep 29, 2026
Thanks for following up. Here are answers to your questions.
Data directory
OpenCode's data is in the default location, ~/.local/share/opencode. I moved it into its own Btrfs subvolume so its storage could be measured separately from the rest of the disk.
The ~8 GB figure
I got this after putting OpenCode's data in a dedicated subvolume, which has its own metadata tree. With that isolation, about 8 GB of Btrfs metadata was attributable to OpenCode's data. I measured it by [state your method, e.g. tree block count × nodesize from btrfs inspect-internal dump-tree, or the change in btrfs filesystem df metadata used while only OpenCode was writing].
The 12 GB in my original report was the filesystem-wide allocated metadata, not OpenCode-specific. The 8 GB figure comes from the subvolume measurement.
Kernel log(I do forget to collect that )
BUT

I've attached a screenshot of the crash log from around the hangs.
What fixed the hangs
I was running OpenCode from my home directory. After adding this to my config, the hangs and crashes stopped and the system is normal again:
{ "watcher": { "ignore": [ "node_modules/**", ".git/**", "dist/**", ".cache/**", ".local/**" ] } }My interpretation
Running from ~ likely made OpenCode watch and snapshot a very large tree. That would create many small files (heavy metadata on Btrfs) and many watches. The watcher config fixed the instability, but I haven't separated the watcher's effect from the snapshot storage growth, so both may have contributed.
opencodejr commentedon Oct 28, 2026
Thanks for the detailed write-up, @swadhinbiswas. To work out which part of OpenCode's storage is growing, could you share some numbers from your machine?
~/.cache/opencodeand~/.local/state/opencodeif they exist.snapshot/is large, the output of the commands below for one of its folders (replace the path):node_modulesor build output)?sudo btrfs filesystem df /(orbtrfs filesystem usage /), so we can see the metadata numbers.You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it so we know you're done.
opencodejr commentedon Oct 31, 2026
Closing this for now: we haven't heard back with the storage details we asked for, and without them we can't tell which part of OpenCode's data is causing the Btrfs metadata growth.
If it happens again, please reopen this issue or open a new one and include:
~/.local/share/opencodebtrfs filesystem df /With those we can look into it. Thanks for the report, @swadhinbiswas!