Skip to content

Commit 02bf51b

Browse files
AdaAibabyadababysjakubno
authored
fix(nbd): change NBD status poll sleep from 100ns to 100µs to avoid useless busy spinning (#2884)
fix(nbd): adjust status poll sleep from 100ns to 100µs Optimize NBD connected check polling interval: - Original 100ns causes useless busy spin since nbdnl.Connect() is sync netlink call; - New 100µs yields CPU safely without any functional regression; - Open/Close path have ctx & 30s timeout guard, rootfs start runs in separate goroutine, no side effect for sandbox rootfs lifecycle. /cc @jakubno @dobrac @ValentaTomas Would appreciate your review on this change, thanks! Co-authored-by: AdaAibaby <shaolila@buaa.edu.cn> Co-authored-by: Jakub Novák <jakub@e2b.dev>
1 parent 36055e1 commit 02bf51b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/orchestrator/pkg/sandbox/nbd/path_direct.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func (d *DirectPathMount) Open(ctx context.Context) (retDeviceIndex uint32, err
232232
break
233233
}
234234

235-
time.Sleep(100 * time.Nanosecond)
235+
time.Sleep(100 * time.Microsecond)
236236
}
237237

238238
telemetry.ReportEvent(ctx, "connected to NBD")
@@ -325,7 +325,7 @@ func disconnectNBDWithTimeout(ctx context.Context, deviceIndex uint32, timeout t
325325
if err == nil && !s.Connected {
326326
break
327327
}
328-
time.Sleep(100 * time.Nanosecond)
328+
time.Sleep(100 * time.Microsecond)
329329
}
330330

331331
return nil

0 commit comments

Comments
 (0)