-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
Windows: lstat bottleneck causes 2-3x slower performance vs Mac (59% of CPU time) #85262
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Priority
None yet
Problem
OpenClaw on Windows is 2-3x slower than on Mac. CPU profiling (120s full flow) reveals lstat system calls as the dominant bottleneck:
lstatsafeRealpathSync/isPathInsideWithRealpathcalled ~48,000 times → ~976,000lstatcallscacheparameter, causing the same path prefixes to be repeatedly resolved with identical resultslstat: 49µs vs Mac 1.1µs (45x slower per call) — multiplied by ~1M calls = 47sRoot Cause
Three re-export modules (
path-safety.ts,path-guards.ts,boundary-path.ts) forwardsafeRealpathSyncandisPathInsideWithRealpathfrom@openclaw/fs-safe/pathwithout any cross-call caching. Each invocation starts fresh, even for identical path prefixes that were just resolved moments ago.Proposed Fix
Inject a global
Map<string, string>cache at the re-export layer:path-safety.ts: WrapsafeRealpathSyncwith a dual-layer cache (global + caller-local)path-guards.ts: Import frompath-safety.js(instead of directly from@openclaw/fs-safe/path) so all 25 importing files benefit from the global cacheboundary-path.ts: Add input→output result cache forresolvePathViaExistingAncestorSyncRewrite
isPathInsideWithRealpathto call the cachedsafeRealpathSyncfrom its own module.Benchmark Results (120s CPU Profile, before → after)
Implementation
fix/windows-lstat-global-cache