You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
structuredClone regression causes high CPU/heat in v1.2.9+ #14458
Commits 8ad60b1 and 01d5187 replaced remeda.clone() with native structuredClone(), causing significant performance degradation. This results in sustained high CPU usage (40%+) and laptop overheating even during idle periods.
Benchmark results show structuredClone is 20-33x slower for large session data and 1.8x slower overall:
Small data: 1.3x faster (acceptable)
Large data: 0.05x slower (20x slowdown - critical)
Realistic workload: 246ms vs 134ms (1.8x slower)
The performance regression affects all background operations that process session data, including history management, message streaming, and scheduled cleanup tasks.
OpenCode version
v1.2.9, v1.2.10
Steps to reproduce
Upgrade to v1.2.9 or v1.2.10
Use opencode normally with typical session sizes (>50 messages)
Observe Activity Monitor showing sustained 40%+ CPU during idle
Laptop heats up significantly even when not actively using opencode
Operating System
macOS (observed), likely affects all platforms
Terminal
N/A - affects both TUI and background server processes
Thanks for updating the issue! It now follows the contributing guidelines with the required template structure, description, reproduction steps, and system context. Removing the compliance flag.
Benchmark code used to verify the performance regression:
#!/usr/bin/env bun
/** * Benchmark comparing structuredClone vs previous implementation * Tests actual use cases from opencode codebase */import{clone}from"remeda"// Generate realistic mock data similar to opencode's message structuresconstgenerateMessage=(id: number,size: "small"|"medium"|"large")=>{consttextContent={small: "Hello, this is a short message.",medium: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ".repeat(50),large: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ".repeat(500),}[size]return{
id,info: {
id,role: id%2===0 ? "user" : "assistant",time: Date.now(),name: null,},parts: [{type: "text",text: textContent,ignored: false,synthetic: false,},],}}// Benchmark runnerconstbenchmark=async<T>(name: string,fn: ()=>T,iterations: number,): Promise<{avgMs: number}>=>{conststart=performance.now()for(leti=0;i<iterations;i++)fn()return{avgMs: (performance.now()-start)/iterations}}construnBenchmarks=async()=>{constresults=[]for(constsizeof["small","medium","large"]asconst){constmessages=Array.from({length: 20},(_,i)=>generateMessage(i,size))constoldImpl=awaitbenchmark("old impl",()=>clone(messages),10000)constnewImpl=awaitbenchmark("structuredClone",()=>structuredClone(messages),10000)results.push({ size,oldImpl: oldImpl.avgMs,newImpl: newImpl.avgMs})}console.table(results)}runBenchmarks()
Run with:
bun run benchmark/clone.ts
bun run --expose-gc benchmark/clone.ts (for memory stats)
The benchmark simulates opencode's actual data structures (session messages, prompt history) with realistic sizes. Results show structuredClone becomes exponentially slower as data size increases.
May or may not be a red herring (could also be all of the FS stuff we're doing to make stuff platform agnostic). This one was the most obvious one I found this week.
The clone call is incredibly expensive. I suspect due to the reference saving mechanism and linear lookup:
https://github.com/remeda/remeda/blob/047c93e314bb9351b3ab93b34ce4b6cf67df7b1d/packages/remeda/src/clone.ts#L80
Replacing it with const sessionMessages = structuredClone(msgs) call directly is much faster. Still takes 1352ms in this case, suggesting a large msgs object.
My colleague does experience higher CPU. I see it with really long conversation threads + a ton of subagents; but otherwise, it's pretty okay at the moment. Might need to look in deeper.
Activity
github-actions commentedon Feb 20, 2026
Thanks for updating the issue! It now follows the contributing guidelines with the required template structure, description, reproduction steps, and system context. Removing the compliance flag.
monotykamary commentedon Feb 20, 2026
Benchmark code used to verify the performance regression:
Run with:
bun run benchmark/clone.tsbun run --expose-gc benchmark/clone.ts(for memory stats)The benchmark simulates opencode's actual data structures (session messages, prompt history) with realistic sizes. Results show structuredClone becomes exponentially slower as data size increases.
monotykamary commentedon Feb 20, 2026
May or may not be a red herring (could also be all of the FS stuff we're doing to make stuff platform agnostic). This one was the most obvious one I found this week.
rekram1-node commentedon Feb 20, 2026
Are u sure??
rekram1-node commentedon Feb 20, 2026
are u using any plugins?
monotykamary commentedon Feb 20, 2026
my opencode is virgin
monotykamary commentedon Feb 20, 2026
My colleague does experience higher CPU. I see it with really long conversation threads + a ton of subagents; but otherwise, it's pretty okay at the moment. Might need to look in deeper.
github-actions commentedon Apr 22, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.