Description
Bug: Snapshot directory fills disk during git gc --prune=7.days (disk drops 40GB in 2 hours)
Description
The snapshot cleanup feature (git gc --prune=7.days) can cause massive disk space spikes that temporarily require 2x the final pack size, potentially filling the entire disk.
In my case: Available disk space dropped from 75GB to 35GB in about 2 hours, and I had to kill the git process to prevent complete disk exhaustion.
Steps to Reproduce
- Use OpenCode for 7+ days with frequent file edits (each triggers
git add .)
- Allow the hourly
git gc --prune=7.days task to run
- Observe disk space rapidly depleting as Git creates a huge pack file
Root Cause Analysis
Based on logs in ~/.local/share/opencode/log/:
- Every file edit triggers
git add . - OpenCode tracks all changes in ~/.local/share/opencode/snapshot/global/
- 7 days of changes accumulate - After 7 days, thousands of loose Git objects exist
- When
git gc runs:
- Reads all loose objects
- Writes a huge pack file (requires 2x temporary space because loose objects + new pack coexist)
- Only deletes loose objects after pack is complete
The critical issue: If free space is less than the estimated pack size, the system can run out of disk mid-process.
Evidence
- Before gc: 75GB available
- During gc: Dropped to 35GB (40GB pack file being created)
- Had to kill git process to prevent complete disk fill
- Logs show two 2.1GB pack files and one 54MB pack were created
Related Issues
User Impact (Current Limitations)
Users currently have no control over:
- The prune interval (hardcoded 7 days)
- Disk space checking before gc
- Maximum pack file size
- Manual cleanup of old snapshots
Proposed Fixes
- Add disk space check - Abort if free space < (estimated pack size + 10GB buffer)
- Use
--max-pack-size - Split large packs into e.g., 1GB chunks to reduce temporary space needs
- Make prune interval configurable - Allow users to set 1-30 days via env var (e.g.,
OPENCODE_SNAPSHOT_DAYS)
- Add monitoring/warning - Log warnings before space runs out; optionally notify user
- Implement cleanup for old snapshots - Currently they're never deleted even after prune
Environment
- OS: macOS 12.6
- OpenCode version: 1.2.4
- Git version: 2.39.5
- Total disk: 234GB APFS
Plugins
No response
OpenCode version
OpenCode Desktop v1.2.25
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Description
Bug: Snapshot directory fills disk during git gc --prune=7.days (disk drops 40GB in 2 hours)
Description
The snapshot cleanup feature (
git gc --prune=7.days) can cause massive disk space spikes that temporarily require 2x the final pack size, potentially filling the entire disk.In my case: Available disk space dropped from 75GB to 35GB in about 2 hours, and I had to kill the git process to prevent complete disk exhaustion.
Steps to Reproduce
git add .)git gc --prune=7.daystask to runRoot Cause Analysis
Based on logs in
~/.local/share/opencode/log/:git add .- OpenCode tracks all changes in~/.local/share/opencode/snapshot/global/git gcruns:The critical issue: If free space is less than the estimated pack size, the system can run out of disk mid-process.
Evidence
Related Issues
User Impact (Current Limitations)
Users currently have no control over:
Proposed Fixes
--max-pack-size- Split large packs into e.g., 1GB chunks to reduce temporary space needsOPENCODE_SNAPSHOT_DAYS)Environment
Plugins
No response
OpenCode version
OpenCode Desktop v1.2.25
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response