perf: avoid blocking hop for owned disk writes (#3004)

* perf: avoid blocking hop for owned disk writes

* fix(ecstore): sync owned write path
This commit is contained in:
安正超
2026-05-19 10:27:14 +08:00
committed by GitHub
parent ecb6704679
commit a9e62dc2c2
+3 -8
View File
@@ -1179,14 +1179,9 @@ impl LocalDisk {
f.write_all(buf).await.map_err(to_file_error)?; f.write_all(buf).await.map_err(to_file_error)?;
} }
InternalBuf::Owned(buf) => { InternalBuf::Owned(buf) => {
// Reduce one copy by using the owned buffer directly. f.write_all(buf.as_ref()).await.map_err(to_file_error)?;
// It may be more efficient for larger writes. // Ensure write errors are observed before returning for owned buffers.
let mut f = f.into_std().await; f.sync_all().await.map_err(to_file_error)?;
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??;
} }
} }