From a9e62dc2c212ddc8b2989c13245243cd16353b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Tue, 19 May 2026 10:27:14 +0800 Subject: [PATCH] perf: avoid blocking hop for owned disk writes (#3004) * perf: avoid blocking hop for owned disk writes * fix(ecstore): sync owned write path --- crates/ecstore/src/disk/local.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/ecstore/src/disk/local.rs b/crates/ecstore/src/disk/local.rs index 5fba72685..a7baa18b3 100644 --- a/crates/ecstore/src/disk/local.rs +++ b/crates/ecstore/src/disk/local.rs @@ -1179,14 +1179,9 @@ impl LocalDisk { f.write_all(buf).await.map_err(to_file_error)?; } InternalBuf::Owned(buf) => { - // Reduce one copy by using the owned buffer directly. - // It may be more efficient for larger writes. - let mut f = f.into_std().await; - let task = tokio::task::spawn_blocking(move || { - use std::io::Write as _; - f.write_all(buf.as_ref()).map_err(to_file_error) - }); - task.await??; + f.write_all(buf.as_ref()).await.map_err(to_file_error)?; + // Ensure write errors are observed before returning for owned buffers. + f.sync_all().await.map_err(to_file_error)?; } }