From 9dc802c7aac3048a93677e498e346002d25ead68 Mon Sep 17 00:00:00 2001 From: Nitin Gangahar Date: Mon, 6 Oct 2025 10:25:07 -0700 Subject: [PATCH] Add logging to io.cc on failed write and read. This should provide insights into any failures. PiperOrigin-RevId: 815784482 --- io/io.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/io/io.cc b/io/io.cc index d19ec10..9363b07 100644 --- a/io/io.cc +++ b/io/io.cc @@ -106,7 +106,13 @@ class FilePosix : public File { for (;;) { // pread seems to be faster than lseek + read when parallelized. const auto bytes_read = pread(fd_, bytes + pos, size - pos, offset + pos); - if (bytes_read <= 0) break; + if (bytes_read <= 0) { + HWY_WARN( + "Read failure at pos %zu within size %zu with offset %zu and " + "errno %d\n", + pos, size, offset, errno); + break; + } pos += bytes_read; HWY_ASSERT(pos <= size); if (pos == size) break; @@ -120,7 +126,13 @@ class FilePosix : public File { for (;;) { const auto bytes_written = pwrite(fd_, bytes + pos, size - pos, offset + pos); - if (bytes_written <= 0) break; + if (bytes_written <= 0) { + HWY_WARN( + "Write failure at pos %zu within size %zu with offset %zu and " + "errno %d\n", + pos, size, offset, errno); + break; + } pos += bytes_written; HWY_ASSERT(pos <= size); if (pos == size) break;